sentdm

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

Sent Dm Go API Library

Go Reference

The Sent Dm Go library provides convenient access to the Sent Dm REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/sentdm/sent-dm-go" // imported as sentdm
)

Or to pin the version:

go get -u 'github.com/sentdm/sent-dm-go@v0.7.0'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/sentdm/sent-dm-go"
	"github.com/sentdm/sent-dm-go/option"
)

func main() {
	client := sentdm.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("SENT_DM_API_KEY")
	)
	response, err := client.Messages.Send(context.TODO(), sentdm.MessageSendParams{
		Channel: []string{"sms", "whatsapp"},
		Template: sentdm.MessageSendParamsTemplate{
			ID:   sentdm.String("7ba7b820-9dad-11d1-80b4-00c04fd430c8"),
			Name: sentdm.String("order_confirmation"),
			Parameters: map[string]string{
				"name":     "John Doe",
				"order_id": "12345",
			},
		},
		To: []string{"+14155551234", "+14155555678"},
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
}

Request fields

The sentdm library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, sentdm.String(string), sentdm.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := sentdm.ExampleParams{
	ID:   "id_xxx",             // required property
	Name: sentdm.String("..."), // optional property

	Point: sentdm.Point{
		X: 0,             // required field will serialize as 0
		Y: sentdm.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: sentdm.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[sentdm.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := sentdm.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Messages.Send(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *sentdm.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Messages.Send(context.TODO(), sentdm.MessageSendParams{
	Channel: []string{"sms"},
	Template: sentdm.MessageSendParamsTemplate{
		ID:   sentdm.String("7ba7b820-9dad-11d1-80b4-00c04fd430c8"),
		Name: sentdm.String("order_confirmation"),
		Parameters: map[string]string{
			"name":     "John Doe",
			"order_id": "12345",
		},
	},
	To: []string{"+14155551234"},
})
if err != nil {
	var apierr *sentdm.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v3/messages": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Messages.Send(
	ctx,
	sentdm.MessageSendParams{
		Channel: []string{"sms"},
		Template: sentdm.MessageSendParamsTemplate{
			ID:   sentdm.String("7ba7b820-9dad-11d1-80b4-00c04fd430c8"),
			Name: sentdm.String("order_confirmation"),
			Parameters: map[string]string{
				"name":     "John Doe",
				"order_id": "12345",
			},
		},
		To: []string{"+14155551234"},
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper sentdm.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := sentdm.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Messages.Send(
	context.TODO(),
	sentdm.MessageSendParams{
		Channel: []string{"sms"},
		Template: sentdm.MessageSendParamsTemplate{
			ID:   sentdm.String("7ba7b820-9dad-11d1-80b4-00c04fd430c8"),
			Name: sentdm.String("order_confirmation"),
			Parameters: map[string]string{
				"name":     "John Doe",
				"order_id": "12345",
			},
		},
		To: []string{"+14155551234"},
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
response, err := client.Messages.Send(
	context.TODO(),
	sentdm.MessageSendParams{
		Channel: []string{"sms"},
		Template: sentdm.MessageSendParamsTemplate{
			ID:   sentdm.String("7ba7b820-9dad-11d1-80b4-00c04fd430c8"),
			Name: sentdm.String("order_confirmation"),
			Parameters: map[string]string{
				"name":     "John Doe",
				"order_id": "12345",
			},
		},
		To: []string{"+14155551234"},
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: sentdm.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := sentdm.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (SENT_DM_API_KEY, SENT_DM_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type APIError added in v0.7.0

type APIError struct {
	// Machine-readable error code (e.g., "RESOURCE_001")
	Code string `json:"code"`
	// Additional validation error details (field-level errors)
	Details map[string][]string `json:"details,nullable"`
	// URL to documentation about this error
	DocURL string `json:"doc_url,nullable"`
	// Human-readable error message
	Message string `json:"message"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Details     respjson.Field
		DocURL      respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Error information

func (APIError) RawJSON added in v0.7.0

func (r APIError) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIError) UnmarshalJSON added in v0.7.0

func (r *APIError) UnmarshalJSON(data []byte) error

type APIMeta added in v0.7.0

type APIMeta struct {
	// Unique identifier for this request (for tracing and support)
	RequestID string `json:"request_id"`
	// Response time in milliseconds (optional)
	ResponseTimeMs int64 `json:"response_time_ms,nullable"`
	// Server timestamp when the response was generated
	Timestamp time.Time `json:"timestamp" format:"date-time"`
	// API version used for this request
	Version string `json:"version"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		RequestID      respjson.Field
		ResponseTimeMs respjson.Field
		Timestamp      respjson.Field
		Version        respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Request and response metadata

func (APIMeta) RawJSON added in v0.7.0

func (r APIMeta) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIMeta) UnmarshalJSON added in v0.7.0

func (r *APIMeta) UnmarshalJSON(data []byte) error

type APIResponseBrandWithKYC added in v0.7.0

type APIResponseBrandWithKYC struct {
	// The response data (null if error)
	Data BrandWithKYC `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseBrandWithKYC) RawJSON added in v0.7.0

func (r APIResponseBrandWithKYC) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseBrandWithKYC) UnmarshalJSON added in v0.7.0

func (r *APIResponseBrandWithKYC) UnmarshalJSON(data []byte) error

type APIResponseContact added in v0.7.0

type APIResponseContact struct {
	// The response data (null if error)
	Data Contact `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseContact) RawJSON added in v0.7.0

func (r APIResponseContact) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseContact) UnmarshalJSON added in v0.7.0

func (r *APIResponseContact) UnmarshalJSON(data []byte) error

type APIResponseOfProfileDetail added in v0.7.0

type APIResponseOfProfileDetail struct {
	// The response data (null if error)
	Data ProfileDetail `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseOfProfileDetail) RawJSON added in v0.7.0

func (r APIResponseOfProfileDetail) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseOfProfileDetail) UnmarshalJSON added in v0.7.0

func (r *APIResponseOfProfileDetail) UnmarshalJSON(data []byte) error

type APIResponseOfUser added in v0.7.0

type APIResponseOfUser struct {
	// The response data (null if error)
	Data UserResponse `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseOfUser) RawJSON added in v0.7.0

func (r APIResponseOfUser) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseOfUser) UnmarshalJSON added in v0.7.0

func (r *APIResponseOfUser) UnmarshalJSON(data []byte) error

type APIResponseTcrCampaignWithUseCases added in v0.7.0

type APIResponseTcrCampaignWithUseCases struct {
	// The response data (null if error)
	Data TcrCampaignWithUseCases `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseTcrCampaignWithUseCases) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*APIResponseTcrCampaignWithUseCases) UnmarshalJSON added in v0.7.0

func (r *APIResponseTcrCampaignWithUseCases) UnmarshalJSON(data []byte) error

type APIResponseTemplate added in v0.7.0

type APIResponseTemplate struct {
	// The response data (null if error)
	Data Template `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseTemplate) RawJSON added in v0.7.0

func (r APIResponseTemplate) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseTemplate) UnmarshalJSON added in v0.7.0

func (r *APIResponseTemplate) UnmarshalJSON(data []byte) error

type APIResponseWebhook added in v0.7.0

type APIResponseWebhook struct {
	// The response data (null if error)
	Data WebhookResponse `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (APIResponseWebhook) RawJSON added in v0.7.0

func (r APIResponseWebhook) RawJSON() string

Returns the unmodified JSON received from the API

func (*APIResponseWebhook) UnmarshalJSON added in v0.7.0

func (r *APIResponseWebhook) UnmarshalJSON(data []byte) error

type BaseDto added in v0.7.0

type BaseDto struct {
	// Unique identifier
	ID        string    `json:"id" format:"uuid"`
	CreatedAt time.Time `json:"createdAt" format:"date-time"`
	UpdatedAt time.Time `json:"updatedAt,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		UpdatedAt   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BaseDto) RawJSON added in v0.7.0

func (r BaseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*BaseDto) UnmarshalJSON added in v0.7.0

func (r *BaseDto) UnmarshalJSON(data []byte) error

type BrandCampaignDeleteParams added in v0.7.0

type BrandCampaignDeleteParams struct {
	BrandID string `path:"brandId,required" format:"uuid" json:"-"`
	// Request to delete a campaign from a brand
	Body BrandCampaignDeleteParamsBody
	// contains filtered or unexported fields
}

func (BrandCampaignDeleteParams) MarshalJSON added in v0.7.0

func (r BrandCampaignDeleteParams) MarshalJSON() (data []byte, err error)

func (*BrandCampaignDeleteParams) UnmarshalJSON added in v0.7.0

func (r *BrandCampaignDeleteParams) UnmarshalJSON(data []byte) error

type BrandCampaignDeleteParamsBody added in v0.7.0

type BrandCampaignDeleteParamsBody struct {
	MutationRequestParam
}

Request to delete a campaign from a brand

func (BrandCampaignDeleteParamsBody) MarshalJSON added in v0.7.0

func (r BrandCampaignDeleteParamsBody) MarshalJSON() (data []byte, err error)

type BrandCampaignListResponse added in v0.7.0

type BrandCampaignListResponse struct {
	// The response data (null if error)
	Data []TcrCampaignWithUseCases `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (BrandCampaignListResponse) RawJSON added in v0.7.0

func (r BrandCampaignListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrandCampaignListResponse) UnmarshalJSON added in v0.7.0

func (r *BrandCampaignListResponse) UnmarshalJSON(data []byte) error

type BrandCampaignNewParams added in v0.7.0

type BrandCampaignNewParams struct {
	// Campaign data
	Campaign CampaignDataParam `json:"campaign,omitzero,required"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BrandCampaignNewParams) MarshalJSON added in v0.7.0

func (r BrandCampaignNewParams) MarshalJSON() (data []byte, err error)

func (*BrandCampaignNewParams) UnmarshalJSON added in v0.7.0

func (r *BrandCampaignNewParams) UnmarshalJSON(data []byte) error

type BrandCampaignService added in v0.7.0

type BrandCampaignService struct {
	Options []option.RequestOption
}

BrandCampaignService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrandCampaignService method instead.

func NewBrandCampaignService added in v0.7.0

func NewBrandCampaignService(opts ...option.RequestOption) (r BrandCampaignService)

NewBrandCampaignService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrandCampaignService) Delete added in v0.7.0

func (r *BrandCampaignService) Delete(ctx context.Context, campaignID string, params BrandCampaignDeleteParams, opts ...option.RequestOption) (err error)

Deletes a campaign by ID within a specific brand. The brand must belong to the authenticated customer.

func (*BrandCampaignService) List added in v0.7.0

Retrieves all campaigns linked to a specific brand, including their use cases and sample messages.

func (*BrandCampaignService) New added in v0.7.0

Creates a new campaign scoped under a specific brand. The campaign is linked to the specified brand. Each campaign must include at least one use case with sample messages.

func (*BrandCampaignService) Update added in v0.7.0

Updates an existing campaign scoped under a specific brand. Cannot update campaigns that have already been submitted to TCR.

type BrandCampaignUpdateParams added in v0.7.0

type BrandCampaignUpdateParams struct {
	BrandID string `path:"brandId,required" format:"uuid" json:"-"`
	// Campaign data
	Campaign CampaignDataParam `json:"campaign,omitzero,required"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BrandCampaignUpdateParams) MarshalJSON added in v0.7.0

func (r BrandCampaignUpdateParams) MarshalJSON() (data []byte, err error)

func (*BrandCampaignUpdateParams) UnmarshalJSON added in v0.7.0

func (r *BrandCampaignUpdateParams) UnmarshalJSON(data []byte) error

type BrandDataEntityType added in v0.7.0

type BrandDataEntityType string

Business entity type

const (
	BrandDataEntityTypePrivateProfit  BrandDataEntityType = "PRIVATE_PROFIT"
	BrandDataEntityTypePublicProfit   BrandDataEntityType = "PUBLIC_PROFIT"
	BrandDataEntityTypeNonProfit      BrandDataEntityType = "NON_PROFIT"
	BrandDataEntityTypeSoleProprietor BrandDataEntityType = "SOLE_PROPRIETOR"
	BrandDataEntityTypeGovernment     BrandDataEntityType = "GOVERNMENT"
)

type BrandDataParam added in v0.7.0

type BrandDataParam struct {
	// Brand relationship level with TCR (required for TCR)
	//
	// Any of "BASIC_ACCOUNT", "MEDIUM_ACCOUNT", "LARGE_ACCOUNT", "SMALL_ACCOUNT",
	// "KEY_ACCOUNT".
	BrandRelationship TcrBrandRelationship `json:"brandRelationship,omitzero,required"`
	// Primary contact name (required)
	ContactName string `json:"contactName,required"`
	// Business vertical/industry category (required for TCR)
	//
	// Any of "PROFESSIONAL", "REAL_ESTATE", "HEALTHCARE", "HUMAN_RESOURCES", "ENERGY",
	// "ENTERTAINMENT", "RETAIL", "TRANSPORTATION", "AGRICULTURE", "INSURANCE",
	// "POSTAL", "EDUCATION", "HOSPITALITY", "FINANCIAL", "POLITICAL", "GAMBLING",
	// "LEGAL", "CONSTRUCTION", "NGO", "MANUFACTURING", "GOVERNMENT", "TECHNOLOGY",
	// "COMMUNICATION".
	Vertical TcrVertical `json:"vertical,omitzero,required"`
	// Brand name for KYC submission
	BrandName param.Opt[string] `json:"brandName,omitzero"`
	// Legal business name
	BusinessLegalName param.Opt[string] `json:"businessLegalName,omitzero"`
	// Business/brand name
	BusinessName param.Opt[string] `json:"businessName,omitzero"`
	// Contact's role in the business
	BusinessRole param.Opt[string] `json:"businessRole,omitzero"`
	// Business website URL
	BusinessURL param.Opt[string] `json:"businessUrl,omitzero" format:"uri"`
	// City
	City param.Opt[string] `json:"city,omitzero"`
	// Contact email address
	ContactEmail param.Opt[string] `json:"contactEmail,omitzero" format:"email"`
	// Contact phone number in E.164 format
	ContactPhone param.Opt[string] `json:"contactPhone,omitzero"`
	// Contact phone country code (e.g., "1" for US)
	ContactPhoneCountryCode param.Opt[string] `json:"contactPhoneCountryCode,omitzero"`
	// Country code (e.g., US, CA)
	Country param.Opt[string] `json:"country,omitzero"`
	// Country where the business is registered
	CountryOfRegistration param.Opt[string] `json:"countryOfRegistration,omitzero"`
	// Expected daily messaging volume
	ExpectedMessagingVolume param.Opt[string] `json:"expectedMessagingVolume,omitzero"`
	// Whether this is a TCR (Campaign Registry) application
	IsTcrApplication param.Opt[bool] `json:"isTcrApplication,omitzero"`
	// Additional notes about the business or use case
	Notes param.Opt[string] `json:"notes,omitzero"`
	// Phone number prefix for messaging (e.g., "+1")
	PhoneNumberPrefix param.Opt[string] `json:"phoneNumberPrefix,omitzero"`
	// Postal/ZIP code
	PostalCode param.Opt[string] `json:"postalCode,omitzero"`
	// Primary messaging use case description
	PrimaryUseCase param.Opt[string] `json:"primaryUseCase,omitzero"`
	// State/province code
	State param.Opt[string] `json:"state,omitzero"`
	// Street address
	Street param.Opt[string] `json:"street,omitzero"`
	// Tax ID/EIN number
	TaxID param.Opt[string] `json:"taxId,omitzero"`
	// Type of tax ID (e.g., us_ein, ca_bn)
	TaxIDType param.Opt[string] `json:"taxIdType,omitzero"`
	// List of destination countries for messaging
	DestinationCountries []DestinationCountryParam `json:"destinationCountries,omitzero"`
	// Business entity type
	//
	// Any of "PRIVATE_PROFIT", "PUBLIC_PROFIT", "NON_PROFIT", "SOLE_PROPRIETOR",
	// "GOVERNMENT".
	EntityType BrandDataEntityType `json:"entityType,omitzero"`
	// contains filtered or unexported fields
}

Brand and KYC data

The properties BrandRelationship, ContactName, Vertical are required.

func (BrandDataParam) MarshalJSON added in v0.7.0

func (r BrandDataParam) MarshalJSON() (data []byte, err error)

func (*BrandDataParam) UnmarshalJSON added in v0.7.0

func (r *BrandDataParam) UnmarshalJSON(data []byte) error

type BrandDeleteParams added in v0.7.0

type BrandDeleteParams struct {
	// Request to delete a brand
	Body BrandDeleteParamsBody
	// contains filtered or unexported fields
}

func (BrandDeleteParams) MarshalJSON added in v0.7.0

func (r BrandDeleteParams) MarshalJSON() (data []byte, err error)

func (*BrandDeleteParams) UnmarshalJSON added in v0.7.0

func (r *BrandDeleteParams) UnmarshalJSON(data []byte) error

type BrandDeleteParamsBody added in v0.7.0

type BrandDeleteParamsBody struct {
	MutationRequestParam
}

Request to delete a brand

func (BrandDeleteParamsBody) MarshalJSON added in v0.7.0

func (r BrandDeleteParamsBody) MarshalJSON() (data []byte, err error)

type BrandListResponse added in v0.7.0

type BrandListResponse struct {
	// The response data (null if error)
	Data []BrandWithKYC `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (BrandListResponse) RawJSON added in v0.7.0

func (r BrandListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrandListResponse) UnmarshalJSON added in v0.7.0

func (r *BrandListResponse) UnmarshalJSON(data []byte) error

type BrandNewParams added in v0.7.0

type BrandNewParams struct {
	// Brand and KYC information
	Brand BrandDataParam `json:"brand,omitzero,required"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BrandNewParams) MarshalJSON added in v0.7.0

func (r BrandNewParams) MarshalJSON() (data []byte, err error)

func (*BrandNewParams) UnmarshalJSON added in v0.7.0

func (r *BrandNewParams) UnmarshalJSON(data []byte) error

type BrandService added in v0.7.0

type BrandService struct {
	Options   []option.RequestOption
	Campaigns BrandCampaignService
}

BrandService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBrandService method instead.

func NewBrandService added in v0.7.0

func NewBrandService(opts ...option.RequestOption) (r BrandService)

NewBrandService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BrandService) Delete added in v0.7.0

func (r *BrandService) Delete(ctx context.Context, brandID string, body BrandDeleteParams, opts ...option.RequestOption) (err error)

Delete a brand by ID. The brand must belong to the authenticated customer.

func (*BrandService) List added in v0.7.0

func (r *BrandService) List(ctx context.Context, opts ...option.RequestOption) (res *BrandListResponse, err error)

Retrieves all brands for the authenticated customer with information in a flattened structure. Includes inherited brands if inheritTcrBrand=true.

func (*BrandService) New added in v0.7.0

Creates a new brand and associated information. This endpoint automatically sets inheritTcrBrand=false when a brand is created.

func (*BrandService) Update added in v0.7.0

func (r *BrandService) Update(ctx context.Context, brandID string, params BrandUpdateParams, opts ...option.RequestOption) (res *APIResponseBrandWithKYC, err error)

Updates an existing brand and its associated information. Cannot update brands that have already been submitted to TCR or inherited brands.

type BrandUpdateParams added in v0.7.0

type BrandUpdateParams struct {
	// Brand and KYC information
	Brand BrandDataParam `json:"brand,omitzero,required"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BrandUpdateParams) MarshalJSON added in v0.7.0

func (r BrandUpdateParams) MarshalJSON() (data []byte, err error)

func (*BrandUpdateParams) UnmarshalJSON added in v0.7.0

func (r *BrandUpdateParams) UnmarshalJSON(data []byte) error

type BrandWithKYC added in v0.7.0

type BrandWithKYC struct {
	// Unique identifier for the brand
	ID string `json:"id" format:"uuid"`
	// Brand relationship level with TCR
	//
	// Any of "BASIC_ACCOUNT", "MEDIUM_ACCOUNT", "LARGE_ACCOUNT", "SMALL_ACCOUNT",
	// "KEY_ACCOUNT".
	BrandRelationship TcrBrandRelationship `json:"brandRelationship,nullable"`
	// Legal business name
	BusinessLegalName string `json:"businessLegalName,nullable"`
	// Business/brand name
	BusinessName string `json:"businessName,nullable"`
	// Contact's role in the business
	BusinessRole string `json:"businessRole,nullable"`
	// Business website URL
	BusinessURL string `json:"businessUrl,nullable"`
	// City
	City string `json:"city,nullable"`
	// Contact email address
	ContactEmail string `json:"contactEmail,nullable"`
	// Primary contact name
	ContactName string `json:"contactName"`
	// Contact phone number
	ContactPhone string `json:"contactPhone,nullable"`
	// Contact phone country code
	ContactPhoneCountryCode string `json:"contactPhoneCountryCode,nullable"`
	// Country code
	Country string `json:"country,nullable"`
	// Country where the business is registered
	CountryOfRegistration string `json:"countryOfRegistration,nullable"`
	// When the brand was created
	CreatedAt time.Time `json:"createdAt" format:"date-time"`
	// CSP (Campaign Service Provider) ID
	CspID string `json:"cspId,nullable"`
	// List of destination countries for messaging
	DestinationCountries []DestinationCountry `json:"destinationCountries"`
	// Business entity type
	EntityType string `json:"entityType,nullable"`
	// Expected daily messaging volume
	ExpectedMessagingVolume string `json:"expectedMessagingVolume,nullable"`
	// TCR brand identity verification status
	//
	// Any of "SELF_DECLARED", "UNVERIFIED", "VERIFIED", "VETTED_VERIFIED".
	IdentityStatus BrandWithKYCIdentityStatus `json:"identityStatus,nullable"`
	// Whether this brand is inherited from parent organization
	IsInherited bool `json:"isInherited"`
	// Whether this is a TCR application
	IsTcrApplication bool `json:"isTcrApplication"`
	// Additional notes
	Notes string `json:"notes,nullable"`
	// Phone number prefix for messaging
	PhoneNumberPrefix string `json:"phoneNumberPrefix,nullable"`
	// Postal/ZIP code
	PostalCode string `json:"postalCode,nullable"`
	// Primary messaging use case description
	PrimaryUseCase string `json:"primaryUseCase,nullable"`
	// State/province code
	State string `json:"state,nullable"`
	// TCR brand status
	//
	// Any of "ACTIVE", "INACTIVE", "SUSPENDED".
	Status BrandWithKYCStatus `json:"status,nullable"`
	// Street address
	Street string `json:"street,nullable"`
	// When the brand was submitted to TCR
	SubmittedAt time.Time `json:"submittedAt,nullable" format:"date-time"`
	// Whether this brand was submitted to TCR
	SubmittedToTcr bool `json:"submittedToTCR"`
	// Tax ID/EIN number
	TaxID string `json:"taxId,nullable"`
	// Type of tax ID
	TaxIDType string `json:"taxIdType,nullable"`
	// TCR brand ID (populated after TCR submission)
	TcrBrandID string `json:"tcrBrandId,nullable"`
	// Universal EIN from TCR
	UniversalEin string `json:"universalEin,nullable"`
	// When the brand was last updated
	UpdatedAt time.Time `json:"updatedAt,nullable" format:"date-time"`
	// Business vertical/industry category
	//
	// Any of "PROFESSIONAL", "REAL_ESTATE", "HEALTHCARE", "HUMAN_RESOURCES", "ENERGY",
	// "ENTERTAINMENT", "RETAIL", "TRANSPORTATION", "AGRICULTURE", "INSURANCE",
	// "POSTAL", "EDUCATION", "HOSPITALITY", "FINANCIAL", "POLITICAL", "GAMBLING",
	// "LEGAL", "CONSTRUCTION", "NGO", "MANUFACTURING", "GOVERNMENT", "TECHNOLOGY",
	// "COMMUNICATION".
	Vertical TcrVertical `json:"vertical,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                      respjson.Field
		BrandRelationship       respjson.Field
		BusinessLegalName       respjson.Field
		BusinessName            respjson.Field
		BusinessRole            respjson.Field
		BusinessURL             respjson.Field
		City                    respjson.Field
		ContactEmail            respjson.Field
		ContactName             respjson.Field
		ContactPhone            respjson.Field
		ContactPhoneCountryCode respjson.Field
		Country                 respjson.Field
		CountryOfRegistration   respjson.Field
		CreatedAt               respjson.Field
		CspID                   respjson.Field
		DestinationCountries    respjson.Field
		EntityType              respjson.Field
		ExpectedMessagingVolume respjson.Field
		IdentityStatus          respjson.Field
		IsInherited             respjson.Field
		IsTcrApplication        respjson.Field
		Notes                   respjson.Field
		PhoneNumberPrefix       respjson.Field
		PostalCode              respjson.Field
		PrimaryUseCase          respjson.Field
		State                   respjson.Field
		Status                  respjson.Field
		Street                  respjson.Field
		SubmittedAt             respjson.Field
		SubmittedToTcr          respjson.Field
		TaxID                   respjson.Field
		TaxIDType               respjson.Field
		TcrBrandID              respjson.Field
		UniversalEin            respjson.Field
		UpdatedAt               respjson.Field
		Vertical                respjson.Field
		ExtraFields             map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Flattened brand response with embedded KYC information

func (BrandWithKYC) RawJSON added in v0.7.0

func (r BrandWithKYC) RawJSON() string

Returns the unmodified JSON received from the API

func (*BrandWithKYC) UnmarshalJSON added in v0.7.0

func (r *BrandWithKYC) UnmarshalJSON(data []byte) error

type BrandWithKYCIdentityStatus added in v0.7.0

type BrandWithKYCIdentityStatus string

TCR brand identity verification status

const (
	BrandWithKYCIdentityStatusSelfDeclared   BrandWithKYCIdentityStatus = "SELF_DECLARED"
	BrandWithKYCIdentityStatusUnverified     BrandWithKYCIdentityStatus = "UNVERIFIED"
	BrandWithKYCIdentityStatusVerified       BrandWithKYCIdentityStatus = "VERIFIED"
	BrandWithKYCIdentityStatusVettedVerified BrandWithKYCIdentityStatus = "VETTED_VERIFIED"
)

type BrandWithKYCStatus added in v0.7.0

type BrandWithKYCStatus string

TCR brand status

const (
	BrandWithKYCStatusActive    BrandWithKYCStatus = "ACTIVE"
	BrandWithKYCStatusInactive  BrandWithKYCStatus = "INACTIVE"
	BrandWithKYCStatusSuspended BrandWithKYCStatus = "SUSPENDED"
)

type CampaignDataParam added in v0.7.0

type CampaignDataParam struct {
	// Campaign description
	Description string `json:"description,required"`
	// Campaign name
	Name string `json:"name,required"`
	// Campaign type (e.g., "KYC", "App")
	Type string `json:"type,required"`
	// List of use cases with sample messages
	UseCases []SentDmServicesEndpointsCustomerApIv3ContractsRequestsCampaignsCampaignUseCaseDataParam `json:"useCases,omitzero,required"`
	// Comma-separated keywords that trigger help message (e.g., "HELP, INFO, SUPPORT")
	HelpKeywords param.Opt[string] `json:"helpKeywords,omitzero"`
	// Message sent when user requests help
	HelpMessage param.Opt[string] `json:"helpMessage,omitzero"`
	// Description of how messages flow in the campaign
	MessageFlow param.Opt[string] `json:"messageFlow,omitzero"`
	// Comma-separated keywords that trigger opt-in (e.g., "YES, START, SUBSCRIBE")
	OptinKeywords param.Opt[string] `json:"optinKeywords,omitzero"`
	// Message sent when user opts in
	OptinMessage param.Opt[string] `json:"optinMessage,omitzero"`
	// Comma-separated keywords that trigger opt-out (e.g., "STOP, UNSUBSCRIBE, END")
	OptoutKeywords param.Opt[string] `json:"optoutKeywords,omitzero"`
	// Message sent when user opts out
	OptoutMessage param.Opt[string] `json:"optoutMessage,omitzero"`
	// URL to privacy policy
	PrivacyPolicyLink param.Opt[string] `json:"privacyPolicyLink,omitzero" format:"uri"`
	// URL to terms and conditions
	TermsAndConditionsLink param.Opt[string] `json:"termsAndConditionsLink,omitzero" format:"uri"`
	// contains filtered or unexported fields
}

Campaign data for create or update operation

The properties Description, Name, Type, UseCases are required.

func (CampaignDataParam) MarshalJSON added in v0.7.0

func (r CampaignDataParam) MarshalJSON() (data []byte, err error)

func (*CampaignDataParam) UnmarshalJSON added in v0.7.0

func (r *CampaignDataParam) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	Options   []option.RequestOption
	Webhooks  WebhookService
	Users     UserService
	Templates TemplateService
	Profiles  ProfileService
	Messages  MessageService
	Lookup    LookupService
	Contacts  ContactService
	Brands    BrandService
	Me        MeService
}

Client creates a struct with services and top level methods that help with interacting with the sent-dm API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (SENT_DM_API_KEY, SENT_DM_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Contact added in v0.7.0

type Contact struct {
	// Unique identifier for the contact
	ID string `json:"id" format:"uuid"`
	// Comma-separated list of available messaging channels (e.g., "sms,whatsapp")
	AvailableChannels string `json:"available_channels"`
	// Country calling code (e.g., 1 for US/Canada)
	CountryCode string `json:"country_code"`
	// When the contact was created
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// Default messaging channel to use (e.g., "sms" or "whatsapp")
	DefaultChannel string `json:"default_channel"`
	// Phone number in E.164 format (e.g., +1234567890)
	FormatE164 string `json:"format_e164"`
	// Phone number in international format (e.g., +1 234-567-890)
	FormatInternational string `json:"format_international"`
	// Phone number in national format (e.g., (234) 567-890)
	FormatNational string `json:"format_national"`
	// Phone number in RFC 3966 format (e.g., tel:+1-234-567-890)
	FormatRfc string `json:"format_rfc"`
	// Whether this is an inherited contact (read-only)
	IsInherited bool `json:"is_inherited"`
	// Whether the contact has opted out of messaging
	OptOut bool `json:"opt_out"`
	// Phone number in original format
	PhoneNumber string `json:"phone_number"`
	// ISO 3166-1 alpha-2 country code (e.g., US, CA, GB)
	RegionCode string `json:"region_code"`
	// When the contact was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                  respjson.Field
		AvailableChannels   respjson.Field
		CountryCode         respjson.Field
		CreatedAt           respjson.Field
		DefaultChannel      respjson.Field
		FormatE164          respjson.Field
		FormatInternational respjson.Field
		FormatNational      respjson.Field
		FormatRfc           respjson.Field
		IsInherited         respjson.Field
		OptOut              respjson.Field
		PhoneNumber         respjson.Field
		RegionCode          respjson.Field
		UpdatedAt           respjson.Field
		ExtraFields         map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Contact response for v3 API Uses snake_case for JSON property names

func (Contact) RawJSON added in v0.7.0

func (r Contact) RawJSON() string

Returns the unmodified JSON received from the API

func (*Contact) UnmarshalJSON added in v0.7.0

func (r *Contact) UnmarshalJSON(data []byte) error

type ContactDeleteParams added in v0.7.0

type ContactDeleteParams struct {
	// Request to delete/dissociate a contact
	Body ContactDeleteParamsBody
	// contains filtered or unexported fields
}

func (ContactDeleteParams) MarshalJSON added in v0.7.0

func (r ContactDeleteParams) MarshalJSON() (data []byte, err error)

func (*ContactDeleteParams) UnmarshalJSON added in v0.7.0

func (r *ContactDeleteParams) UnmarshalJSON(data []byte) error

type ContactDeleteParamsBody added in v0.7.0

type ContactDeleteParamsBody struct {
	MutationRequestParam
}

Request to delete/dissociate a contact

func (ContactDeleteParamsBody) MarshalJSON added in v0.7.0

func (r ContactDeleteParamsBody) MarshalJSON() (data []byte, err error)

type ContactListParams

type ContactListParams struct {
	// Page number (1-indexed)
	Page     int64 `query:"page,required" json:"-"`
	PageSize int64 `query:"pageSize,required" json:"-"`
	// Optional channel filter (sms, whatsapp)
	Channel param.Opt[string] `query:"channel,omitzero" json:"-"`
	// Optional phone number filter (alternative to list view)
	Phone param.Opt[string] `query:"phone,omitzero" json:"-"`
	// Optional search term for filtering contacts
	Search param.Opt[string] `query:"search,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ContactListParams) URLQuery

func (r ContactListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ContactListParams's query parameters as `url.Values`.

type ContactListResponse

type ContactListResponse struct {
	// The response data (null if error)
	Data ContactListResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (ContactListResponse) RawJSON

func (r ContactListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContactListResponse) UnmarshalJSON

func (r *ContactListResponse) UnmarshalJSON(data []byte) error

type ContactListResponseData added in v0.7.0

type ContactListResponseData struct {
	// List of contacts
	Contacts []Contact `json:"contacts"`
	// Pagination metadata
	Pagination PaginationMeta `json:"pagination"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Contacts    respjson.Field
		Pagination  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (ContactListResponseData) RawJSON added in v0.7.0

func (r ContactListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContactListResponseData) UnmarshalJSON added in v0.7.0

func (r *ContactListResponseData) UnmarshalJSON(data []byte) error

type ContactNewParams added in v0.7.0

type ContactNewParams struct {
	// Phone number of the contact to create
	PhoneNumber param.Opt[string] `json:"phone_number,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ContactNewParams) MarshalJSON added in v0.7.0

func (r ContactNewParams) MarshalJSON() (data []byte, err error)

func (*ContactNewParams) UnmarshalJSON added in v0.7.0

func (r *ContactNewParams) UnmarshalJSON(data []byte) error

type ContactService

type ContactService struct {
	Options []option.RequestOption
}

ContactService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewContactService method instead.

func NewContactService

func NewContactService(opts ...option.RequestOption) (r ContactService)

NewContactService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ContactService) Delete added in v0.7.0

func (r *ContactService) Delete(ctx context.Context, id string, body ContactDeleteParams, opts ...option.RequestOption) (err error)

Dissociates a contact from the authenticated customer. Inherited contacts cannot be deleted.

func (*ContactService) Get added in v0.7.0

func (r *ContactService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *APIResponseContact, err error)

Retrieves a specific contact by their unique identifier. Returns detailed contact information including phone formats, available channels, and opt-out status.

func (*ContactService) List

Retrieves a paginated list of contacts for the authenticated customer. Supports filtering by search term, channel, or phone number.

func (*ContactService) New added in v0.7.0

Creates a new contact by phone number and associates it with the authenticated customer.

func (*ContactService) Update added in v0.7.0

func (r *ContactService) Update(ctx context.Context, id string, params ContactUpdateParams, opts ...option.RequestOption) (res *APIResponseContact, err error)

Updates a contact's default channel and/or opt-out status. Inherited contacts cannot be updated.

type ContactUpdateParams added in v0.7.0

type ContactUpdateParams struct {
	// Default messaging channel: "sms" or "whatsapp"
	DefaultChannel param.Opt[string] `json:"default_channel,omitzero"`
	// Whether the contact has opted out of messaging
	OptOut param.Opt[bool] `json:"opt_out,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ContactUpdateParams) MarshalJSON added in v0.7.0

func (r ContactUpdateParams) MarshalJSON() (data []byte, err error)

func (*ContactUpdateParams) UnmarshalJSON added in v0.7.0

func (r *ContactUpdateParams) UnmarshalJSON(data []byte) error

type DestinationCountry added in v0.7.0

type DestinationCountry struct {
	ID     string `json:"id"`
	IsMain bool   `json:"isMain"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		IsMain      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DestinationCountry) RawJSON added in v0.7.0

func (r DestinationCountry) RawJSON() string

Returns the unmodified JSON received from the API

func (DestinationCountry) ToParam added in v0.7.0

ToParam converts this DestinationCountry to a DestinationCountryParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with DestinationCountryParam.Overrides()

func (*DestinationCountry) UnmarshalJSON added in v0.7.0

func (r *DestinationCountry) UnmarshalJSON(data []byte) error

type DestinationCountryParam added in v0.7.0

type DestinationCountryParam struct {
	ID     param.Opt[string] `json:"id,omitzero"`
	IsMain param.Opt[bool]   `json:"isMain,omitzero"`
	// contains filtered or unexported fields
}

func (DestinationCountryParam) MarshalJSON added in v0.7.0

func (r DestinationCountryParam) MarshalJSON() (data []byte, err error)

func (*DestinationCountryParam) UnmarshalJSON added in v0.7.0

func (r *DestinationCountryParam) UnmarshalJSON(data []byte) error

type Error

type Error = apierror.Error

type LookupGetPhoneInfoResponse added in v0.7.0

type LookupGetPhoneInfoResponse struct {
	// The response data (null if error)
	Data LookupGetPhoneInfoResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (LookupGetPhoneInfoResponse) RawJSON added in v0.7.0

func (r LookupGetPhoneInfoResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*LookupGetPhoneInfoResponse) UnmarshalJSON added in v0.7.0

func (r *LookupGetPhoneInfoResponse) UnmarshalJSON(data []byte) error

type LookupGetPhoneInfoResponseData added in v0.7.0

type LookupGetPhoneInfoResponseData struct {
	CarrierName       string `json:"carrierName,nullable"`
	IsPorted          bool   `json:"isPorted,nullable"`
	IsValid           bool   `json:"isValid"`
	IsVoip            bool   `json:"isVoip,nullable"`
	LineType          string `json:"lineType,nullable"`
	MobileCountryCode string `json:"mobileCountryCode,nullable"`
	MobileNetworkCode string `json:"mobileNetworkCode,nullable"`
	PhoneNumber       string `json:"phoneNumber"`
	Provider          string `json:"provider"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CarrierName       respjson.Field
		IsPorted          respjson.Field
		IsValid           respjson.Field
		IsVoip            respjson.Field
		LineType          respjson.Field
		MobileCountryCode respjson.Field
		MobileNetworkCode respjson.Field
		PhoneNumber       respjson.Field
		Provider          respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (LookupGetPhoneInfoResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*LookupGetPhoneInfoResponseData) UnmarshalJSON added in v0.7.0

func (r *LookupGetPhoneInfoResponseData) UnmarshalJSON(data []byte) error

type LookupService added in v0.7.0

type LookupService struct {
	Options []option.RequestOption
}

LookupService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewLookupService method instead.

func NewLookupService added in v0.7.0

func NewLookupService(opts ...option.RequestOption) (r LookupService)

NewLookupService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*LookupService) GetPhoneInfo added in v0.7.0

func (r *LookupService) GetPhoneInfo(ctx context.Context, phoneNumber string, opts ...option.RequestOption) (res *LookupGetPhoneInfoResponse, err error)

Validates a phone number and retrieves formatting, country, and timezone information from the internal index. Provider-agnostic and works for all customers.

type MeGetResponse added in v0.7.0

type MeGetResponse struct {
	// The response data (null if error)
	Data MeGetResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (MeGetResponse) RawJSON added in v0.7.0

func (r MeGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MeGetResponse) UnmarshalJSON added in v0.7.0

func (r *MeGetResponse) UnmarshalJSON(data []byte) error

type MeGetResponseData added in v0.7.0

type MeGetResponseData struct {
	// Customer ID (organization or profile)
	ID string `json:"id" format:"uuid"`
	// When the account was created
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// Account description
	Description string `json:"description,nullable"`
	// Account icon URL
	Icon string `json:"icon,nullable"`
	// Account name
	Name string `json:"name"`
	// List of profiles (only for organization type)
	Profiles []MeGetResponseDataProfile `json:"profiles,nullable"`
	// Profile settings (only for profile type)
	Settings ProfileSettings `json:"settings,nullable"`
	// Profile status (only for profile type): incomplete, pending_review, approved,
	// etc.
	Status string `json:"status,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Description respjson.Field
		Icon        respjson.Field
		Name        respjson.Field
		Profiles    respjson.Field
		Settings    respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (MeGetResponseData) RawJSON added in v0.7.0

func (r MeGetResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*MeGetResponseData) UnmarshalJSON added in v0.7.0

func (r *MeGetResponseData) UnmarshalJSON(data []byte) error

type MeGetResponseDataProfile added in v0.7.0

type MeGetResponseDataProfile struct {
	// Profile unique identifier
	ID string `json:"id" format:"uuid"`
	// When the profile was created
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// Profile description
	Description string `json:"description,nullable"`
	// Profile icon URL
	Icon string `json:"icon,nullable"`
	// Profile name
	Name string `json:"name"`
	// User's role in this profile: admin, billing, developer (inherited from
	// organization if not explicitly set)
	Role string `json:"role,nullable"`
	// Profile configuration settings
	Settings ProfileSettings `json:"settings"`
	// Profile short name (abbreviation)
	ShortName string `json:"short_name,nullable"`
	// Profile setup status: incomplete, pending_review, approved, rejected
	Status string `json:"status,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Description respjson.Field
		Icon        respjson.Field
		Name        respjson.Field
		Role        respjson.Field
		Settings    respjson.Field
		ShortName   respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Profile (sender profile) response for v3 API

func (MeGetResponseDataProfile) RawJSON added in v0.7.0

func (r MeGetResponseDataProfile) RawJSON() string

Returns the unmodified JSON received from the API

func (*MeGetResponseDataProfile) UnmarshalJSON added in v0.7.0

func (r *MeGetResponseDataProfile) UnmarshalJSON(data []byte) error

type MeService added in v0.7.0

type MeService struct {
	Options []option.RequestOption
}

MeService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMeService method instead.

func NewMeService added in v0.7.0

func NewMeService(opts ...option.RequestOption) (r MeService)

NewMeService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MeService) Get added in v0.7.0

func (r *MeService) Get(ctx context.Context, opts ...option.RequestOption) (res *MeGetResponse, err error)

Returns the account associated with the API key. For organization API keys, returns the organization with its profiles. For profile API keys, returns the profile with its settings.

type MessageGetActivitiesResponse added in v0.7.0

type MessageGetActivitiesResponse struct {
	// The response data (null if error)
	Data MessageGetActivitiesResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (MessageGetActivitiesResponse) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetActivitiesResponse) UnmarshalJSON added in v0.7.0

func (r *MessageGetActivitiesResponse) UnmarshalJSON(data []byte) error

type MessageGetActivitiesResponseData added in v0.7.0

type MessageGetActivitiesResponseData struct {
	// List of activity events ordered by most recent first
	Activities []MessageGetActivitiesResponseDataActivity `json:"activities"`
	// The message ID these activities belong to
	MessageID string `json:"message_id" format:"uuid"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Activities  respjson.Field
		MessageID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (MessageGetActivitiesResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetActivitiesResponseData) UnmarshalJSON added in v0.7.0

func (r *MessageGetActivitiesResponseData) UnmarshalJSON(data []byte) error

type MessageGetActivitiesResponseDataActivity added in v0.7.0

type MessageGetActivitiesResponseDataActivity struct {
	// Additional content or payload for the activity (e.g., channel response)
	Content string `json:"content,nullable"`
	// Human-readable description of the activity
	Description string `json:"description"`
	// Activity status (e.g., ACCEPTED, PROCESSED, SENT, DELIVERED, FAILED)
	Status string `json:"status"`
	// When this activity occurred
	Timestamp time.Time `json:"timestamp" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Description respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A single message activity event for v3 API

func (MessageGetActivitiesResponseDataActivity) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetActivitiesResponseDataActivity) UnmarshalJSON added in v0.7.0

func (r *MessageGetActivitiesResponseDataActivity) UnmarshalJSON(data []byte) error

type MessageGetStatusResponse added in v0.7.0

type MessageGetStatusResponse struct {
	// The response data (null if error)
	Data MessageGetStatusResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (MessageGetStatusResponse) RawJSON added in v0.7.0

func (r MessageGetStatusResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageGetStatusResponse) UnmarshalJSON added in v0.7.0

func (r *MessageGetStatusResponse) UnmarshalJSON(data []byte) error

type MessageGetStatusResponseData added in v0.7.0

type MessageGetStatusResponseData struct {
	ID         string                              `json:"id" format:"uuid"`
	Channel    string                              `json:"channel"`
	ContactID  string                              `json:"contact_id" format:"uuid"`
	CreatedAt  time.Time                           `json:"created_at" format:"date-time"`
	CustomerID string                              `json:"customer_id" format:"uuid"`
	Events     []MessageGetStatusResponseDataEvent `json:"events,nullable"`
	// Structured message body format for database storage. Preserves channel-specific
	// components (header, body, footer, buttons).
	MessageBody        MessageGetStatusResponseDataMessageBody `json:"message_body,nullable"`
	Phone              string                                  `json:"phone"`
	PhoneInternational string                                  `json:"phone_international"`
	Price              float64                                 `json:"price,nullable"`
	RegionCode         string                                  `json:"region_code"`
	Status             string                                  `json:"status"`
	TemplateCategory   string                                  `json:"template_category"`
	TemplateID         string                                  `json:"template_id,nullable" format:"uuid"`
	TemplateName       string                                  `json:"template_name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                 respjson.Field
		Channel            respjson.Field
		ContactID          respjson.Field
		CreatedAt          respjson.Field
		CustomerID         respjson.Field
		Events             respjson.Field
		MessageBody        respjson.Field
		Phone              respjson.Field
		PhoneInternational respjson.Field
		Price              respjson.Field
		RegionCode         respjson.Field
		Status             respjson.Field
		TemplateCategory   respjson.Field
		TemplateID         respjson.Field
		TemplateName       respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (MessageGetStatusResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetStatusResponseData) UnmarshalJSON added in v0.7.0

func (r *MessageGetStatusResponseData) UnmarshalJSON(data []byte) error

type MessageGetStatusResponseDataEvent added in v0.7.0

type MessageGetStatusResponseDataEvent struct {
	Description string    `json:"description,nullable"`
	Status      string    `json:"status"`
	Timestamp   time.Time `json:"timestamp" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		Status      respjson.Field
		Timestamp   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a status change event in a message's lifecycle (v3)

func (MessageGetStatusResponseDataEvent) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetStatusResponseDataEvent) UnmarshalJSON added in v0.7.0

func (r *MessageGetStatusResponseDataEvent) UnmarshalJSON(data []byte) error

type MessageGetStatusResponseDataMessageBody added in v0.7.0

type MessageGetStatusResponseDataMessageBody struct {
	Buttons []MessageGetStatusResponseDataMessageBodyButton `json:"buttons,nullable"`
	Content string                                          `json:"content"`
	Footer  string                                          `json:"footer,nullable"`
	Header  string                                          `json:"header,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Buttons     respjson.Field
		Content     respjson.Field
		Footer      respjson.Field
		Header      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Structured message body format for database storage. Preserves channel-specific components (header, body, footer, buttons).

func (MessageGetStatusResponseDataMessageBody) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetStatusResponseDataMessageBody) UnmarshalJSON added in v0.7.0

func (r *MessageGetStatusResponseDataMessageBody) UnmarshalJSON(data []byte) error

type MessageGetStatusResponseDataMessageBodyButton added in v0.7.0

type MessageGetStatusResponseDataMessageBodyButton struct {
	Type  string `json:"type"`
	Value string `json:"value"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageGetStatusResponseDataMessageBodyButton) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageGetStatusResponseDataMessageBodyButton) UnmarshalJSON added in v0.7.0

func (r *MessageGetStatusResponseDataMessageBodyButton) UnmarshalJSON(data []byte) error

type MessageSendParams added in v0.7.0

type MessageSendParams struct {
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// Channels to broadcast on, e.g. ["whatsapp", "sms"]. Each channel produces a
	// separate message per recipient. "sent" = auto-detect, "rcs" = reserved
	// (skipped). Defaults to ["sent"] (auto-detect) if omitted.
	Channel []string `json:"channel,omitzero"`
	// Template reference (by id or name, with optional parameters)
	Template MessageSendParamsTemplate `json:"template,omitzero"`
	// List of recipient phone numbers in E.164 format (multi-recipient fan-out)
	To []string `json:"to,omitzero"`
	// contains filtered or unexported fields
}

func (MessageSendParams) MarshalJSON added in v0.7.0

func (r MessageSendParams) MarshalJSON() (data []byte, err error)

func (*MessageSendParams) UnmarshalJSON added in v0.7.0

func (r *MessageSendParams) UnmarshalJSON(data []byte) error

type MessageSendParamsTemplate added in v0.7.0

type MessageSendParamsTemplate struct {
	// Template ID (mutually exclusive with name)
	ID param.Opt[string] `json:"id,omitzero" format:"uuid"`
	// Template name (mutually exclusive with id)
	Name param.Opt[string] `json:"name,omitzero"`
	// Template variable parameters for personalization
	Parameters map[string]string `json:"parameters,omitzero"`
	// contains filtered or unexported fields
}

Template reference (by id or name, with optional parameters)

func (MessageSendParamsTemplate) MarshalJSON added in v0.7.0

func (r MessageSendParamsTemplate) MarshalJSON() (data []byte, err error)

func (*MessageSendParamsTemplate) UnmarshalJSON added in v0.7.0

func (r *MessageSendParamsTemplate) UnmarshalJSON(data []byte) error

type MessageSendResponse added in v0.7.0

type MessageSendResponse struct {
	// The response data (null if error)
	Data MessageSendResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (MessageSendResponse) RawJSON added in v0.7.0

func (r MessageSendResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageSendResponse) UnmarshalJSON added in v0.7.0

func (r *MessageSendResponse) UnmarshalJSON(data []byte) error

type MessageSendResponseData added in v0.7.0

type MessageSendResponseData struct {
	// Resolved template body text
	Body string `json:"body,nullable"`
	// Per-recipient message results
	Recipients []MessageSendResponseDataRecipient `json:"recipients"`
	// Overall request status (e.g. "accepted")
	Status string `json:"status"`
	// Template ID that was used
	TemplateID string `json:"template_id" format:"uuid"`
	// Template display name
	TemplateName string `json:"template_name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Body         respjson.Field
		Recipients   respjson.Field
		Status       respjson.Field
		TemplateID   respjson.Field
		TemplateName respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (MessageSendResponseData) RawJSON added in v0.7.0

func (r MessageSendResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageSendResponseData) UnmarshalJSON added in v0.7.0

func (r *MessageSendResponseData) UnmarshalJSON(data []byte) error

type MessageSendResponseDataRecipient added in v0.7.0

type MessageSendResponseDataRecipient struct {
	// Channel this message will be sent on (e.g. "sms", "whatsapp"), or null for
	// auto-detect
	Channel string `json:"channel,nullable"`
	// Unique message identifier for tracking this recipient's message
	MessageID string `json:"message_id" format:"uuid"`
	// Phone number in E.164 format
	To string `json:"to"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Channel     respjson.Field
		MessageID   respjson.Field
		To          respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Per-recipient result in the send message response

func (MessageSendResponseDataRecipient) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*MessageSendResponseDataRecipient) UnmarshalJSON added in v0.7.0

func (r *MessageSendResponseDataRecipient) UnmarshalJSON(data []byte) error

type MessageService

type MessageService struct {
	Options []option.RequestOption
}

MessageService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMessageService method instead.

func NewMessageService

func NewMessageService(opts ...option.RequestOption) (r MessageService)

NewMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MessageService) GetActivities added in v0.7.0

func (r *MessageService) GetActivities(ctx context.Context, id string, opts ...option.RequestOption) (res *MessageGetActivitiesResponse, err error)

Retrieves the activity log for a specific message. Activities track the message lifecycle including acceptance, processing, sending, delivery, and any errors.

func (*MessageService) GetStatus added in v0.7.0

func (r *MessageService) GetStatus(ctx context.Context, id string, opts ...option.RequestOption) (res *MessageGetStatusResponse, err error)

Retrieves the current status and details of a message by ID. Includes delivery status, timestamps, and error information if applicable.

func (*MessageService) Send added in v0.7.0

Sends a message to one or more recipients using a template. Supports multi-channel broadcast — when multiple channels are specified (e.g. ["sms", "whatsapp"]), a separate message is created for each (recipient, channel) pair. Returns immediately with per-recipient message IDs for async tracking via webhooks or the GET /messages/{id} endpoint.

type MessagingUseCaseUs added in v0.7.0

type MessagingUseCaseUs string
const (
	MessagingUseCaseUsMarketing                 MessagingUseCaseUs = "MARKETING"
	MessagingUseCaseUsAccountNotification       MessagingUseCaseUs = "ACCOUNT_NOTIFICATION"
	MessagingUseCaseUsCustomerCare              MessagingUseCaseUs = "CUSTOMER_CARE"
	MessagingUseCaseUsFraudAlert                MessagingUseCaseUs = "FRAUD_ALERT"
	MessagingUseCaseUsTwoFa                     MessagingUseCaseUs = "TWO_FA"
	MessagingUseCaseUsDeliveryNotification      MessagingUseCaseUs = "DELIVERY_NOTIFICATION"
	MessagingUseCaseUsSecurityAlert             MessagingUseCaseUs = "SECURITY_ALERT"
	MessagingUseCaseUsM2M                       MessagingUseCaseUs = "M2M"
	MessagingUseCaseUsMixed                     MessagingUseCaseUs = "MIXED"
	MessagingUseCaseUsHigherEducation           MessagingUseCaseUs = "HIGHER_EDUCATION"
	MessagingUseCaseUsPollingVoting             MessagingUseCaseUs = "POLLING_VOTING"
	MessagingUseCaseUsPublicServiceAnnouncement MessagingUseCaseUs = "PUBLIC_SERVICE_ANNOUNCEMENT"
	MessagingUseCaseUsLowVolume                 MessagingUseCaseUs = "LOW_VOLUME"
)

type MutationRequestParam added in v0.7.0

type MutationRequestParam struct {
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode param.Opt[bool] `json:"test_mode,omitzero"`
	// contains filtered or unexported fields
}

func (MutationRequestParam) MarshalJSON added in v0.7.0

func (r MutationRequestParam) MarshalJSON() (data []byte, err error)

func (*MutationRequestParam) UnmarshalJSON added in v0.7.0

func (r *MutationRequestParam) UnmarshalJSON(data []byte) error

type PaginationMeta added in v0.7.0

type PaginationMeta struct {
	// Cursor-based pagination (optional)
	Cursors PaginationMetaCursors `json:"cursors,nullable"`
	// Whether there are more pages after this one
	HasMore bool `json:"has_more"`
	// Current page number (1-indexed)
	Page int64 `json:"page"`
	// Number of items per page
	PageSize int64 `json:"page_size"`
	// Total number of items across all pages
	TotalCount int64 `json:"total_count"`
	// Total number of pages
	TotalPages int64 `json:"total_pages"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Cursors     respjson.Field
		HasMore     respjson.Field
		Page        respjson.Field
		PageSize    respjson.Field
		TotalCount  respjson.Field
		TotalPages  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Pagination metadata for list responses

func (PaginationMeta) RawJSON added in v0.7.0

func (r PaginationMeta) RawJSON() string

Returns the unmodified JSON received from the API

func (*PaginationMeta) UnmarshalJSON added in v0.7.0

func (r *PaginationMeta) UnmarshalJSON(data []byte) error

type PaginationMetaCursors added in v0.7.0

type PaginationMetaCursors struct {
	// Cursor to fetch the next page
	After string `json:"after,nullable"`
	// Cursor to fetch the previous page
	Before string `json:"before,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		After       respjson.Field
		Before      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Cursor-based pagination (optional)

func (PaginationMetaCursors) RawJSON added in v0.7.0

func (r PaginationMetaCursors) RawJSON() string

Returns the unmodified JSON received from the API

func (*PaginationMetaCursors) UnmarshalJSON added in v0.7.0

func (r *PaginationMetaCursors) UnmarshalJSON(data []byte) error

type ProfileCompleteParams added in v0.7.0

type ProfileCompleteParams struct {
	// Webhook URL to call when profile completion finishes (success or failure)
	WebHookURL string `json:"webHookUrl,required" format:"uri"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ProfileCompleteParams) MarshalJSON added in v0.7.0

func (r ProfileCompleteParams) MarshalJSON() (data []byte, err error)

func (*ProfileCompleteParams) UnmarshalJSON added in v0.7.0

func (r *ProfileCompleteParams) UnmarshalJSON(data []byte) error

type ProfileCompleteResponse added in v0.7.0

type ProfileCompleteResponse = any

type ProfileDeleteParams added in v0.7.0

type ProfileDeleteParams struct {
	// Profile ID from route parameter
	ProfileID param.Opt[string] `json:"profile_id,omitzero" format:"uuid"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode param.Opt[bool] `json:"test_mode,omitzero"`
	// contains filtered or unexported fields
}

func (ProfileDeleteParams) MarshalJSON added in v0.7.0

func (r ProfileDeleteParams) MarshalJSON() (data []byte, err error)

func (*ProfileDeleteParams) UnmarshalJSON added in v0.7.0

func (r *ProfileDeleteParams) UnmarshalJSON(data []byte) error

type ProfileDetail added in v0.7.0

type ProfileDetail struct {
	// Profile unique identifier
	ID string `json:"id" format:"uuid"`
	// When the profile was created
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// Profile description
	Description string `json:"description,nullable"`
	// Profile email (inherited from organization)
	Email string `json:"email,nullable"`
	// Profile icon URL
	Icon string `json:"icon,nullable"`
	// Profile name
	Name string `json:"name"`
	// Parent organization ID
	OrganizationID string `json:"organization_id,nullable" format:"uuid"`
	// Profile configuration settings
	Settings ProfileDetailSettings `json:"settings"`
	// Profile short name (abbreviation)
	ShortName string `json:"short_name,nullable"`
	// Profile setup status: incomplete, pending_review, approved, rejected
	Status string `json:"status"`
	// When the profile was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID             respjson.Field
		CreatedAt      respjson.Field
		Description    respjson.Field
		Email          respjson.Field
		Icon           respjson.Field
		Name           respjson.Field
		OrganizationID respjson.Field
		Settings       respjson.Field
		ShortName      respjson.Field
		Status         respjson.Field
		UpdatedAt      respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Detailed profile response for v3 API

func (ProfileDetail) RawJSON added in v0.7.0

func (r ProfileDetail) RawJSON() string

Returns the unmodified JSON received from the API

func (*ProfileDetail) UnmarshalJSON added in v0.7.0

func (r *ProfileDetail) UnmarshalJSON(data []byte) error

type ProfileDetailSettings added in v0.7.0

type ProfileDetailSettings struct {
	// Whether contacts are shared across profiles in the organization
	AllowContactSharing bool `json:"allow_contact_sharing"`
	// Whether number changes are allowed during onboarding
	AllowNumberChangeDuringOnboarding bool `json:"allow_number_change_during_onboarding,nullable"`
	// Whether templates are shared across profiles in the organization
	AllowTemplateSharing bool `json:"allow_template_sharing"`
	// Billing model: profile, organization, or profile_and_organization
	BillingModel string `json:"billing_model"`
	// Whether this profile inherits contacts from the organization
	InheritContacts bool `json:"inherit_contacts"`
	// Whether this profile inherits TCR brand from the organization
	InheritTcrBrand bool `json:"inherit_tcr_brand"`
	// Whether this profile inherits TCR campaign from the organization
	InheritTcrCampaign bool `json:"inherit_tcr_campaign"`
	// Whether this profile inherits templates from the organization
	InheritTemplates bool `json:"inherit_templates"`
	// Direct SMS phone number
	SendingPhoneNumber string `json:"sending_phone_number,nullable"`
	// Reference to another profile for SMS/Telnyx configuration
	SendingPhoneNumberProfileID string `json:"sending_phone_number_profile_id,nullable" format:"uuid"`
	// Reference to another profile for WhatsApp configuration
	SendingWhatsappNumberProfileID string `json:"sending_whatsapp_number_profile_id,nullable" format:"uuid"`
	// Direct WhatsApp phone number
	WhatsappPhoneNumber string `json:"whatsapp_phone_number,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AllowContactSharing               respjson.Field
		AllowNumberChangeDuringOnboarding respjson.Field
		AllowTemplateSharing              respjson.Field
		BillingModel                      respjson.Field
		InheritContacts                   respjson.Field
		InheritTcrBrand                   respjson.Field
		InheritTcrCampaign                respjson.Field
		InheritTemplates                  respjson.Field
		SendingPhoneNumber                respjson.Field
		SendingPhoneNumberProfileID       respjson.Field
		SendingWhatsappNumberProfileID    respjson.Field
		WhatsappPhoneNumber               respjson.Field
		ExtraFields                       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Profile configuration settings

func (ProfileDetailSettings) RawJSON added in v0.7.0

func (r ProfileDetailSettings) RawJSON() string

Returns the unmodified JSON received from the API

func (*ProfileDetailSettings) UnmarshalJSON added in v0.7.0

func (r *ProfileDetailSettings) UnmarshalJSON(data []byte) error

type ProfileListResponse added in v0.7.0

type ProfileListResponse struct {
	// The response data (null if error)
	Data ProfileListResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (ProfileListResponse) RawJSON added in v0.7.0

func (r ProfileListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ProfileListResponse) UnmarshalJSON added in v0.7.0

func (r *ProfileListResponse) UnmarshalJSON(data []byte) error

type ProfileListResponseData added in v0.7.0

type ProfileListResponseData struct {
	// List of profiles in the organization
	Profiles []ProfileDetail `json:"profiles"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Profiles    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (ProfileListResponseData) RawJSON added in v0.7.0

func (r ProfileListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*ProfileListResponseData) UnmarshalJSON added in v0.7.0

func (r *ProfileListResponseData) UnmarshalJSON(data []byte) error

type ProfileNewParams added in v0.7.0

type ProfileNewParams struct {
	// Billing model: profile, organization, or profile_and_organization (default:
	// profile)
	BillingModel param.Opt[string] `json:"billing_model,omitzero"`
	// Profile description (optional)
	Description param.Opt[string] `json:"description,omitzero"`
	// Profile icon URL (optional)
	Icon param.Opt[string] `json:"icon,omitzero"`
	// Whether this profile inherits contacts from organization (default: true)
	InheritContacts param.Opt[bool] `json:"inherit_contacts,omitzero"`
	// Whether this profile inherits TCR brand from organization (default: true)
	InheritTcrBrand param.Opt[bool] `json:"inherit_tcr_brand,omitzero"`
	// Whether this profile inherits TCR campaign from organization (default: true)
	InheritTcrCampaign param.Opt[bool] `json:"inherit_tcr_campaign,omitzero"`
	// Whether this profile inherits templates from organization (default: true)
	InheritTemplates param.Opt[bool] `json:"inherit_templates,omitzero"`
	// Profile short name/abbreviation (optional)
	ShortName param.Opt[string] `json:"short_name,omitzero"`
	// Whether contacts are shared across profiles (default: false)
	AllowContactSharing param.Opt[bool] `json:"allow_contact_sharing,omitzero"`
	// Whether templates are shared across profiles (default: false)
	AllowTemplateSharing param.Opt[bool] `json:"allow_template_sharing,omitzero"`
	// Profile name (required)
	Name param.Opt[string] `json:"name,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ProfileNewParams) MarshalJSON added in v0.7.0

func (r ProfileNewParams) MarshalJSON() (data []byte, err error)

func (*ProfileNewParams) UnmarshalJSON added in v0.7.0

func (r *ProfileNewParams) UnmarshalJSON(data []byte) error

type ProfileService added in v0.7.0

type ProfileService struct {
	Options []option.RequestOption
}

ProfileService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewProfileService method instead.

func NewProfileService added in v0.7.0

func NewProfileService(opts ...option.RequestOption) (r ProfileService)

NewProfileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ProfileService) Complete added in v0.7.0

func (r *ProfileService) Complete(ctx context.Context, profileID string, params ProfileCompleteParams, opts ...option.RequestOption) (res *ProfileCompleteResponse, err error)

Final step in profile compliance workflow. Validates all prerequisites (general data, brand, campaigns), connects profile to Telnyx/WhatsApp, and sets status based on configuration. The process runs in the background and calls the provided webhook URL when finished.

Prerequisites:
- Profile must be completed
- If inheritTcrBrand=false: Profile must have existing brand
- If inheritTcrBrand=true: Parent must have existing brand
- If TCR application: Must have at least one campaign (own or inherited)
- If inheritTcrCampaign=false: Profile should have campaigns
- If inheritTcrCampaign=true: Parent must have campaigns

Status Logic:
- If both SMS and WhatsApp channels are missing → SUBMITTED
- If TCR application and not inheriting brand/campaigns → SUBMITTED
- If non-TCR with destination country (IsMain=true) → SUBMITTED
- Otherwise → COMPLETED

func (*ProfileService) Delete added in v0.7.0

func (r *ProfileService) Delete(ctx context.Context, profileID string, body ProfileDeleteParams, opts ...option.RequestOption) (err error)

Soft deletes a sender profile. The profile will be marked as deleted but data is retained. Requires admin role in the organization.

func (*ProfileService) Get added in v0.7.0

func (r *ProfileService) Get(ctx context.Context, profileID string, opts ...option.RequestOption) (res *APIResponseOfProfileDetail, err error)

Retrieves detailed information about a specific sender profile within an organization.

func (*ProfileService) List added in v0.7.0

func (r *ProfileService) List(ctx context.Context, opts ...option.RequestOption) (res *ProfileListResponse, err error)

Retrieves all sender profiles within an organization. Profiles represent different brands, departments, or use cases within an organization, each with their own messaging configuration.

func (*ProfileService) New added in v0.7.0

Creates a new sender profile within an organization. Profiles represent different brands, departments, or use cases, each with their own messaging configuration and settings. Requires admin role in the organization.

func (*ProfileService) Update added in v0.7.0

func (r *ProfileService) Update(ctx context.Context, profileID string, params ProfileUpdateParams, opts ...option.RequestOption) (res *APIResponseOfProfileDetail, err error)

Updates a profile's configuration and settings. Requires admin role in the organization. Only provided fields will be updated (partial update).

type ProfileSettings added in v0.7.0

type ProfileSettings struct {
	// Whether contacts are shared across profiles in the organization
	AllowContactSharing bool `json:"allow_contact_sharing,nullable"`
	// Whether templates are shared across profiles in the organization
	AllowTemplateSharing bool `json:"allow_template_sharing,nullable"`
	// Billing model: profile, organization, or profile_and_organization
	BillingModel string `json:"billing_model,nullable"`
	// Whether this profile inherits contacts from the organization
	InheritContacts bool `json:"inherit_contacts,nullable"`
	// Whether this profile inherits TCR brand from the organization
	InheritTcrBrand bool `json:"inherit_tcr_brand,nullable"`
	// Whether this profile inherits TCR campaign from the organization
	InheritTcrCampaign bool `json:"inherit_tcr_campaign,nullable"`
	// Whether this profile inherits templates from the organization
	InheritTemplates bool `json:"inherit_templates,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AllowContactSharing  respjson.Field
		AllowTemplateSharing respjson.Field
		BillingModel         respjson.Field
		InheritContacts      respjson.Field
		InheritTcrBrand      respjson.Field
		InheritTcrCampaign   respjson.Field
		InheritTemplates     respjson.Field
		ExtraFields          map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Profile configuration settings

func (ProfileSettings) RawJSON added in v0.7.0

func (r ProfileSettings) RawJSON() string

Returns the unmodified JSON received from the API

func (*ProfileSettings) UnmarshalJSON added in v0.7.0

func (r *ProfileSettings) UnmarshalJSON(data []byte) error

type ProfileUpdateParams added in v0.7.0

type ProfileUpdateParams struct {
	// Whether contacts are shared across profiles (optional)
	AllowContactSharing param.Opt[bool] `json:"allow_contact_sharing,omitzero"`
	// Whether number changes are allowed during onboarding (optional)
	AllowNumberChangeDuringOnboarding param.Opt[bool] `json:"allow_number_change_during_onboarding,omitzero"`
	// Whether templates are shared across profiles (optional)
	AllowTemplateSharing param.Opt[bool] `json:"allow_template_sharing,omitzero"`
	// Billing model: profile, organization, or profile_and_organization (optional)
	BillingModel param.Opt[string] `json:"billing_model,omitzero"`
	// Profile description (optional)
	Description param.Opt[string] `json:"description,omitzero"`
	// Profile icon URL (optional)
	Icon param.Opt[string] `json:"icon,omitzero"`
	// Whether this profile inherits contacts from organization (optional)
	InheritContacts param.Opt[bool] `json:"inherit_contacts,omitzero"`
	// Whether this profile inherits TCR brand from organization (optional)
	InheritTcrBrand param.Opt[bool] `json:"inherit_tcr_brand,omitzero"`
	// Whether this profile inherits TCR campaign from organization (optional)
	InheritTcrCampaign param.Opt[bool] `json:"inherit_tcr_campaign,omitzero"`
	// Whether this profile inherits templates from organization (optional)
	InheritTemplates param.Opt[bool] `json:"inherit_templates,omitzero"`
	// Profile name (optional)
	Name param.Opt[string] `json:"name,omitzero"`
	// Direct phone number for SMS sending (optional)
	SendingPhoneNumber param.Opt[string] `json:"sending_phone_number,omitzero"`
	// Reference to another profile to use for SMS/Telnyx configuration (optional)
	SendingPhoneNumberProfileID param.Opt[string] `json:"sending_phone_number_profile_id,omitzero" format:"uuid"`
	// Reference to another profile to use for WhatsApp configuration (optional)
	SendingWhatsappNumberProfileID param.Opt[string] `json:"sending_whatsapp_number_profile_id,omitzero" format:"uuid"`
	// Profile short name/abbreviation (optional)
	ShortName param.Opt[string] `json:"short_name,omitzero"`
	// Direct phone number for WhatsApp sending (optional)
	WhatsappPhoneNumber param.Opt[string] `json:"whatsapp_phone_number,omitzero"`
	// Profile ID from route parameter
	ProfileID param.Opt[string] `json:"profile_id,omitzero" format:"uuid"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ProfileUpdateParams) MarshalJSON added in v0.7.0

func (r ProfileUpdateParams) MarshalJSON() (data []byte, err error)

func (*ProfileUpdateParams) UnmarshalJSON added in v0.7.0

func (r *ProfileUpdateParams) UnmarshalJSON(data []byte) error

type SentDmServicesCommonContractsPocOsAuthenticationConfigParam added in v0.7.0

type SentDmServicesCommonContractsPocOsAuthenticationConfigParam struct {
	// Code expiration time in minutes (1-90). If set, adds footer: "This code expires
	// in X minutes."
	CodeExpirationMinutes param.Opt[int64] `json:"codeExpirationMinutes,omitzero"`
	// Whether to add the security recommendation text: "For your security, do not
	// share this code."
	AddSecurityRecommendation param.Opt[bool] `json:"addSecurityRecommendation,omitzero"`
	// contains filtered or unexported fields
}

Configuration for AUTHENTICATION category templates

func (SentDmServicesCommonContractsPocOsAuthenticationConfigParam) MarshalJSON added in v0.7.0

func (*SentDmServicesCommonContractsPocOsAuthenticationConfigParam) UnmarshalJSON added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateBodyParam added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateBodyParam struct {
	// Content that will be used for all channels (SMS and WhatsApp) unless
	// channel-specific content is provided
	MultiChannel TemplateBodyContentParam `json:"multiChannel,omitzero"`
	// SMS-specific content that overrides multi-channel content for SMS messages
	SMS TemplateBodyContentParam `json:"sms,omitzero"`
	// WhatsApp-specific content that overrides multi-channel content for WhatsApp
	// messages
	Whatsapp TemplateBodyContentParam `json:"whatsapp,omitzero"`
	// contains filtered or unexported fields
}

Body section of a message template with channel-specific content

func (SentDmServicesCommonContractsPocOsTemplateBodyParam) MarshalJSON added in v0.7.0

func (r SentDmServicesCommonContractsPocOsTemplateBodyParam) MarshalJSON() (data []byte, err error)

func (*SentDmServicesCommonContractsPocOsTemplateBodyParam) UnmarshalJSON added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateButtonParam added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateButtonParam struct {
	// The unique identifier of the button (1-based index)
	ID param.Opt[int64] `json:"id,omitzero"`
	// The type of button (e.g., QUICK_REPLY, URL, PHONE_NUMBER, VOICE_CALL, COPY_CODE)
	Type param.Opt[string] `json:"type,omitzero"`
	// Properties specific to the button type
	Props SentDmServicesCommonContractsPocOsTemplateButtonPropsParam `json:"props,omitzero"`
	// contains filtered or unexported fields
}

Interactive button in a message template

func (SentDmServicesCommonContractsPocOsTemplateButtonParam) MarshalJSON added in v0.7.0

func (*SentDmServicesCommonContractsPocOsTemplateButtonParam) UnmarshalJSON added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateButtonPropsParam added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateButtonPropsParam struct {
	ActiveFor      param.Opt[int64]  `json:"activeFor,omitzero"`
	AutofillText   param.Opt[string] `json:"autofillText,omitzero"`
	CountryCode    param.Opt[string] `json:"countryCode,omitzero"`
	OfferCode      param.Opt[string] `json:"offerCode,omitzero"`
	OtpType        param.Opt[string] `json:"otpType,omitzero"`
	PackageName    param.Opt[string] `json:"packageName,omitzero"`
	PhoneNumber    param.Opt[string] `json:"phoneNumber,omitzero"`
	QuickReplyType param.Opt[string] `json:"quickReplyType,omitzero"`
	SignatureHash  param.Opt[string] `json:"signatureHash,omitzero"`
	Text           param.Opt[string] `json:"text,omitzero"`
	URL            param.Opt[string] `json:"url,omitzero"`
	URLType        param.Opt[string] `json:"urlType,omitzero"`
	// contains filtered or unexported fields
}

func (SentDmServicesCommonContractsPocOsTemplateButtonPropsParam) MarshalJSON added in v0.7.0

func (*SentDmServicesCommonContractsPocOsTemplateButtonPropsParam) UnmarshalJSON added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateFooterParam added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateFooterParam struct {
	// The type of footer (typically "text")
	Type param.Opt[string] `json:"type,omitzero"`
	// The footer template text with optional variable placeholders
	Template param.Opt[string] `json:"template,omitzero"`
	// List of variables used in the footer template
	Variables []TemplateVariableParam `json:"variables,omitzero"`
	// contains filtered or unexported fields
}

Footer section of a message template

func (SentDmServicesCommonContractsPocOsTemplateFooterParam) MarshalJSON added in v0.7.0

func (*SentDmServicesCommonContractsPocOsTemplateFooterParam) UnmarshalJSON added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateHeaderParam added in v0.7.0

type SentDmServicesCommonContractsPocOsTemplateHeaderParam struct {
	// The type of header (e.g., "text", "image", "video", "document")
	Type param.Opt[string] `json:"type,omitzero"`
	// The header template text with optional variable placeholders (e.g., "Welcome to
	// {{0:variable}}")
	Template param.Opt[string] `json:"template,omitzero"`
	// List of variables used in the header template
	Variables []TemplateVariableParam `json:"variables,omitzero"`
	// contains filtered or unexported fields
}

Header section of a message template

func (SentDmServicesCommonContractsPocOsTemplateHeaderParam) MarshalJSON added in v0.7.0

func (*SentDmServicesCommonContractsPocOsTemplateHeaderParam) UnmarshalJSON added in v0.7.0

type SentDmServicesEndpointsCustomerApIv3ContractsRequestsCampaignsCampaignUseCaseDataParam added in v0.7.0

type SentDmServicesEndpointsCustomerApIv3ContractsRequestsCampaignsCampaignUseCaseDataParam struct {
	// US messaging use case category
	//
	// Any of "MARKETING", "ACCOUNT_NOTIFICATION", "CUSTOMER_CARE", "FRAUD_ALERT",
	// "TWO_FA", "DELIVERY_NOTIFICATION", "SECURITY_ALERT", "M2M", "MIXED",
	// "HIGHER_EDUCATION", "POLLING_VOTING", "PUBLIC_SERVICE_ANNOUNCEMENT",
	// "LOW_VOLUME".
	MessagingUseCaseUs MessagingUseCaseUs `json:"messagingUseCaseUs,omitzero,required"`
	// Sample messages for this use case (1-5 messages, max 1024 characters each)
	SampleMessages []string `json:"sampleMessages,omitzero,required"`
	// contains filtered or unexported fields
}

Campaign use case with sample messages

The properties MessagingUseCaseUs, SampleMessages are required.

func (SentDmServicesEndpointsCustomerApIv3ContractsRequestsCampaignsCampaignUseCaseDataParam) MarshalJSON added in v0.7.0

func (*SentDmServicesEndpointsCustomerApIv3ContractsRequestsCampaignsCampaignUseCaseDataParam) UnmarshalJSON added in v0.7.0

type TcrBrandRelationship added in v0.7.0

type TcrBrandRelationship string
const (
	TcrBrandRelationshipBasicAccount  TcrBrandRelationship = "BASIC_ACCOUNT"
	TcrBrandRelationshipMediumAccount TcrBrandRelationship = "MEDIUM_ACCOUNT"
	TcrBrandRelationshipLargeAccount  TcrBrandRelationship = "LARGE_ACCOUNT"
	TcrBrandRelationshipSmallAccount  TcrBrandRelationship = "SMALL_ACCOUNT"
	TcrBrandRelationshipKeyAccount    TcrBrandRelationship = "KEY_ACCOUNT"
)

type TcrCampaignWithUseCases added in v0.7.0

type TcrCampaignWithUseCases struct {
	BilledDate          time.Time `json:"billedDate,nullable" format:"date-time"`
	BrandID             string    `json:"brandId,nullable" format:"uuid"`
	Cost                float64   `json:"cost,nullable"`
	CspID               string    `json:"cspId,nullable"`
	CustomerID          string    `json:"customerId" format:"uuid"`
	Description         string    `json:"description"`
	HelpKeywords        string    `json:"helpKeywords,nullable"`
	HelpMessage         string    `json:"helpMessage,nullable"`
	KYCSubmissionFormID string    `json:"kycSubmissionFormId,nullable" format:"uuid"`
	MessageFlow         string    `json:"messageFlow,nullable"`
	Name                string    `json:"name"`
	OptinKeywords       string    `json:"optinKeywords,nullable"`
	OptinMessage        string    `json:"optinMessage,nullable"`
	OptoutKeywords      string    `json:"optoutKeywords,nullable"`
	OptoutMessage       string    `json:"optoutMessage,nullable"`
	PrivacyPolicyLink   string    `json:"privacyPolicyLink,nullable"`
	ResellerID          string    `json:"resellerId,nullable"`
	// Any of "PENDING", "ACCEPTED", "DECLINED".
	SharingStatus string `json:"sharingStatus,nullable"`
	// Any of "SENT_CREATED", "ACTIVE", "EXPIRED".
	Status                 string                           `json:"status,nullable"`
	SubmittedAt            time.Time                        `json:"submittedAt,nullable" format:"date-time"`
	SubmittedToTcr         bool                             `json:"submittedToTCR"`
	TcrCampaignID          string                           `json:"tcrCampaignId,nullable"`
	TcrSyncError           string                           `json:"tcrSyncError,nullable"`
	TelnyxCampaignID       string                           `json:"telnyxCampaignId,nullable"`
	TermsAndConditionsLink string                           `json:"termsAndConditionsLink,nullable"`
	Type                   string                           `json:"type"`
	UpstreamCnpID          string                           `json:"upstreamCnpId,nullable"`
	UseCases               []TcrCampaignWithUseCasesUseCase `json:"useCases"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BilledDate             respjson.Field
		BrandID                respjson.Field
		Cost                   respjson.Field
		CspID                  respjson.Field
		CustomerID             respjson.Field
		Description            respjson.Field
		HelpKeywords           respjson.Field
		HelpMessage            respjson.Field
		KYCSubmissionFormID    respjson.Field
		MessageFlow            respjson.Field
		Name                   respjson.Field
		OptinKeywords          respjson.Field
		OptinMessage           respjson.Field
		OptoutKeywords         respjson.Field
		OptoutMessage          respjson.Field
		PrivacyPolicyLink      respjson.Field
		ResellerID             respjson.Field
		SharingStatus          respjson.Field
		Status                 respjson.Field
		SubmittedAt            respjson.Field
		SubmittedToTcr         respjson.Field
		TcrCampaignID          respjson.Field
		TcrSyncError           respjson.Field
		TelnyxCampaignID       respjson.Field
		TermsAndConditionsLink respjson.Field
		Type                   respjson.Field
		UpstreamCnpID          respjson.Field
		UseCases               respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
	BaseDto
}

func (TcrCampaignWithUseCases) RawJSON added in v0.7.0

func (r TcrCampaignWithUseCases) RawJSON() string

Returns the unmodified JSON received from the API

func (*TcrCampaignWithUseCases) UnmarshalJSON added in v0.7.0

func (r *TcrCampaignWithUseCases) UnmarshalJSON(data []byte) error

type TcrCampaignWithUseCasesUseCase added in v0.7.0

type TcrCampaignWithUseCasesUseCase struct {
	CampaignID string `json:"campaignId" format:"uuid"`
	CustomerID string `json:"customerId" format:"uuid"`
	// Any of "MARKETING", "ACCOUNT_NOTIFICATION", "CUSTOMER_CARE", "FRAUD_ALERT",
	// "TWO_FA", "DELIVERY_NOTIFICATION", "SECURITY_ALERT", "M2M", "MIXED",
	// "HIGHER_EDUCATION", "POLLING_VOTING", "PUBLIC_SERVICE_ANNOUNCEMENT",
	// "LOW_VOLUME".
	MessagingUseCaseUs MessagingUseCaseUs `json:"messagingUseCaseUs"`
	SampleMessages     []string           `json:"sampleMessages"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CampaignID         respjson.Field
		CustomerID         respjson.Field
		MessagingUseCaseUs respjson.Field
		SampleMessages     respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
	BaseDto
}

func (TcrCampaignWithUseCasesUseCase) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*TcrCampaignWithUseCasesUseCase) UnmarshalJSON added in v0.7.0

func (r *TcrCampaignWithUseCasesUseCase) UnmarshalJSON(data []byte) error

type TcrVertical added in v0.7.0

type TcrVertical string
const (
	TcrVerticalProfessional   TcrVertical = "PROFESSIONAL"
	TcrVerticalRealEstate     TcrVertical = "REAL_ESTATE"
	TcrVerticalHealthcare     TcrVertical = "HEALTHCARE"
	TcrVerticalHumanResources TcrVertical = "HUMAN_RESOURCES"
	TcrVerticalEnergy         TcrVertical = "ENERGY"
	TcrVerticalEntertainment  TcrVertical = "ENTERTAINMENT"
	TcrVerticalRetail         TcrVertical = "RETAIL"
	TcrVerticalTransportation TcrVertical = "TRANSPORTATION"
	TcrVerticalAgriculture    TcrVertical = "AGRICULTURE"
	TcrVerticalInsurance      TcrVertical = "INSURANCE"
	TcrVerticalPostal         TcrVertical = "POSTAL"
	TcrVerticalEducation      TcrVertical = "EDUCATION"
	TcrVerticalHospitality    TcrVertical = "HOSPITALITY"
	TcrVerticalFinancial      TcrVertical = "FINANCIAL"
	TcrVerticalPolitical      TcrVertical = "POLITICAL"
	TcrVerticalGambling       TcrVertical = "GAMBLING"
	TcrVerticalLegal          TcrVertical = "LEGAL"
	TcrVerticalConstruction   TcrVertical = "CONSTRUCTION"
	TcrVerticalNgo            TcrVertical = "NGO"
	TcrVerticalManufacturing  TcrVertical = "MANUFACTURING"
	TcrVerticalGovernment     TcrVertical = "GOVERNMENT"
	TcrVerticalTechnology     TcrVertical = "TECHNOLOGY"
	TcrVerticalCommunication  TcrVertical = "COMMUNICATION"
)

type Template added in v0.7.0

type Template struct {
	// Unique template identifier
	ID string `json:"id" format:"uuid"`
	// Template category: MARKETING, UTILITY, AUTHENTICATION
	Category string `json:"category"`
	// Supported channels: sms, whatsapp
	Channels []string `json:"channels,nullable"`
	// When the template was created
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// Whether the template is published and active
	IsPublished bool `json:"is_published"`
	// Template language code (e.g., en_US)
	Language string `json:"language"`
	// Template display name
	Name string `json:"name"`
	// Template status: APPROVED, PENDING, REJECTED
	Status string `json:"status"`
	// When the template was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// Template variables for personalization
	Variables []string `json:"variables,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Category    respjson.Field
		Channels    respjson.Field
		CreatedAt   respjson.Field
		IsPublished respjson.Field
		Language    respjson.Field
		Name        respjson.Field
		Status      respjson.Field
		UpdatedAt   respjson.Field
		Variables   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Template response for v3 API

func (Template) RawJSON added in v0.7.0

func (r Template) RawJSON() string

Returns the unmodified JSON received from the API

func (*Template) UnmarshalJSON added in v0.7.0

func (r *Template) UnmarshalJSON(data []byte) error

type TemplateBodyContentParam

type TemplateBodyContentParam struct {
	Type      param.Opt[string]       `json:"type,omitzero"`
	Template  param.Opt[string]       `json:"template,omitzero"`
	Variables []TemplateVariableParam `json:"variables,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateBodyContentParam) MarshalJSON

func (r TemplateBodyContentParam) MarshalJSON() (data []byte, err error)

func (*TemplateBodyContentParam) UnmarshalJSON

func (r *TemplateBodyContentParam) UnmarshalJSON(data []byte) error

type TemplateDefinitionParam

type TemplateDefinitionParam struct {
	// Required template body with content for different channels (multi-channel,
	// SMS-specific, or WhatsApp-specific)
	Body SentDmServicesCommonContractsPocOsTemplateBodyParam `json:"body,omitzero,required"`
	// The version of the template definition format
	DefinitionVersion param.Opt[string] `json:"definitionVersion,omitzero"`
	// Optional list of interactive buttons (e.g., quick replies, URLs, phone numbers)
	Buttons []SentDmServicesCommonContractsPocOsTemplateButtonParam `json:"buttons,omitzero"`
	// Configuration specific to AUTHENTICATION category templates (optional)
	AuthenticationConfig SentDmServicesCommonContractsPocOsAuthenticationConfigParam `json:"authenticationConfig,omitzero"`
	// Optional template footer with optional variables
	Footer SentDmServicesCommonContractsPocOsTemplateFooterParam `json:"footer,omitzero"`
	// Optional template header with optional variables
	Header SentDmServicesCommonContractsPocOsTemplateHeaderParam `json:"header,omitzero"`
	// contains filtered or unexported fields
}

Complete definition of a message template including header, body, footer, and buttons

The property Body is required.

func (TemplateDefinitionParam) MarshalJSON

func (r TemplateDefinitionParam) MarshalJSON() (data []byte, err error)

func (*TemplateDefinitionParam) UnmarshalJSON

func (r *TemplateDefinitionParam) UnmarshalJSON(data []byte) error

type TemplateDeleteParams added in v0.7.0

type TemplateDeleteParams struct {
	// Whether to also delete the template from WhatsApp/Meta (optional, defaults to
	// false)
	DeleteFromMeta param.Opt[bool] `json:"delete_from_meta,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode param.Opt[bool] `json:"test_mode,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateDeleteParams) MarshalJSON added in v0.7.0

func (r TemplateDeleteParams) MarshalJSON() (data []byte, err error)

func (*TemplateDeleteParams) UnmarshalJSON added in v0.7.0

func (r *TemplateDeleteParams) UnmarshalJSON(data []byte) error

type TemplateListParams

type TemplateListParams struct {
	// Page number (1-indexed)
	Page     int64 `query:"page,required" json:"-"`
	PageSize int64 `query:"pageSize,required" json:"-"`
	// Optional category filter: MARKETING, UTILITY, AUTHENTICATION
	Category param.Opt[string] `query:"category,omitzero" json:"-"`
	// Optional search term for filtering templates
	Search param.Opt[string] `query:"search,omitzero" json:"-"`
	// Optional status filter: APPROVED, PENDING, REJECTED
	Status param.Opt[string] `query:"status,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (TemplateListParams) URLQuery

func (r TemplateListParams) URLQuery() (v url.Values, err error)

URLQuery serializes TemplateListParams's query parameters as `url.Values`.

type TemplateListResponse

type TemplateListResponse struct {
	// The response data (null if error)
	Data TemplateListResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (TemplateListResponse) RawJSON

func (r TemplateListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TemplateListResponse) UnmarshalJSON

func (r *TemplateListResponse) UnmarshalJSON(data []byte) error

type TemplateListResponseData added in v0.7.0

type TemplateListResponseData struct {
	// Pagination metadata
	Pagination PaginationMeta `json:"pagination"`
	// List of templates
	Templates []Template `json:"templates"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Pagination  respjson.Field
		Templates   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (TemplateListResponseData) RawJSON added in v0.7.0

func (r TemplateListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TemplateListResponseData) UnmarshalJSON added in v0.7.0

func (r *TemplateListResponseData) UnmarshalJSON(data []byte) error

type TemplateNewParams

type TemplateNewParams struct {
	// Template category: MARKETING, UTILITY, AUTHENTICATION (optional, auto-detected
	// if not provided)
	Category param.Opt[string] `json:"category,omitzero"`
	// Source of template creation (default: from-api)
	CreationSource param.Opt[string] `json:"creation_source,omitzero"`
	// Template language code (e.g., en_US) (optional, auto-detected if not provided)
	Language param.Opt[string] `json:"language,omitzero"`
	// Whether to submit the template for review after creation (default: false)
	SubmitForReview param.Opt[bool] `json:"submit_for_review,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// Template definition including header, body, footer, and buttons
	Definition TemplateDefinitionParam `json:"definition,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateNewParams) MarshalJSON

func (r TemplateNewParams) MarshalJSON() (data []byte, err error)

func (*TemplateNewParams) UnmarshalJSON

func (r *TemplateNewParams) UnmarshalJSON(data []byte) error

type TemplateService

type TemplateService struct {
	Options []option.RequestOption
}

TemplateService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTemplateService method instead.

func NewTemplateService

func NewTemplateService(opts ...option.RequestOption) (r TemplateService)

NewTemplateService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TemplateService) Delete

func (r *TemplateService) Delete(ctx context.Context, id string, body TemplateDeleteParams, opts ...option.RequestOption) (err error)

Deletes a template by ID. Optionally, you can also delete the template from WhatsApp/Meta by setting delete_from_meta=true.

func (*TemplateService) Get

func (r *TemplateService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *APIResponseTemplate, err error)

Retrieves a specific template by its ID. Returns template details including name, category, language, status, and definition.

func (*TemplateService) List

Retrieves a paginated list of message templates for the authenticated customer. Supports filtering by status, category, and search term.

func (*TemplateService) New

Creates a new message template with header, body, footer, and buttons. The template can be submitted for review immediately or saved as draft for later submission.

func (*TemplateService) Update added in v0.7.0

Updates an existing template's name, category, language, definition, or submits it for review.

type TemplateUpdateParams added in v0.7.0

type TemplateUpdateParams struct {
	// Template category: MARKETING, UTILITY, AUTHENTICATION
	Category param.Opt[string] `json:"category,omitzero"`
	// Template language code (e.g., en_US)
	Language param.Opt[string] `json:"language,omitzero"`
	// Template display name
	Name param.Opt[string] `json:"name,omitzero"`
	// Whether to submit the template for review after updating (default: false)
	SubmitForReview param.Opt[bool] `json:"submit_for_review,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// Template definition including header, body, footer, and buttons
	Definition TemplateDefinitionParam `json:"definition,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateUpdateParams) MarshalJSON added in v0.7.0

func (r TemplateUpdateParams) MarshalJSON() (data []byte, err error)

func (*TemplateUpdateParams) UnmarshalJSON added in v0.7.0

func (r *TemplateUpdateParams) UnmarshalJSON(data []byte) error

type TemplateVariableParam

type TemplateVariableParam struct {
	ID    param.Opt[int64]           `json:"id,omitzero"`
	Name  param.Opt[string]          `json:"name,omitzero"`
	Type  param.Opt[string]          `json:"type,omitzero"`
	Props TemplateVariablePropsParam `json:"props,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateVariableParam) MarshalJSON

func (r TemplateVariableParam) MarshalJSON() (data []byte, err error)

func (*TemplateVariableParam) UnmarshalJSON

func (r *TemplateVariableParam) UnmarshalJSON(data []byte) error

type TemplateVariablePropsParam

type TemplateVariablePropsParam struct {
	Alt          param.Opt[string] `json:"alt,omitzero"`
	MediaType    param.Opt[string] `json:"mediaType,omitzero"`
	Sample       param.Opt[string] `json:"sample,omitzero"`
	ShortURL     param.Opt[string] `json:"shortUrl,omitzero"`
	URL          param.Opt[string] `json:"url,omitzero"`
	VariableType param.Opt[string] `json:"variableType,omitzero"`
	// contains filtered or unexported fields
}

func (TemplateVariablePropsParam) MarshalJSON

func (r TemplateVariablePropsParam) MarshalJSON() (data []byte, err error)

func (*TemplateVariablePropsParam) UnmarshalJSON

func (r *TemplateVariablePropsParam) UnmarshalJSON(data []byte) error

type UserInviteParams added in v0.7.0

type UserInviteParams struct {
	// User email address (required)
	Email param.Opt[string] `json:"email,omitzero" format:"email"`
	// User full name (required)
	Name param.Opt[string] `json:"name,omitzero"`
	// User role: admin, billing, or developer (required)
	Role param.Opt[string] `json:"role,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (UserInviteParams) MarshalJSON added in v0.7.0

func (r UserInviteParams) MarshalJSON() (data []byte, err error)

func (*UserInviteParams) UnmarshalJSON added in v0.7.0

func (r *UserInviteParams) UnmarshalJSON(data []byte) error

type UserListResponse added in v0.7.0

type UserListResponse struct {
	// The response data (null if error)
	Data UserListResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (UserListResponse) RawJSON added in v0.7.0

func (r UserListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*UserListResponse) UnmarshalJSON added in v0.7.0

func (r *UserListResponse) UnmarshalJSON(data []byte) error

type UserListResponseData added in v0.7.0

type UserListResponseData struct {
	// List of users in the organization
	Users []UserResponse `json:"users"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Users       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (UserListResponseData) RawJSON added in v0.7.0

func (r UserListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*UserListResponseData) UnmarshalJSON added in v0.7.0

func (r *UserListResponseData) UnmarshalJSON(data []byte) error

type UserRemoveParams added in v0.7.0

type UserRemoveParams struct {
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode param.Opt[bool] `json:"test_mode,omitzero"`
	// User ID from route parameter
	UserID param.Opt[string] `json:"user_id,omitzero" format:"uuid"`
	// contains filtered or unexported fields
}

func (UserRemoveParams) MarshalJSON added in v0.7.0

func (r UserRemoveParams) MarshalJSON() (data []byte, err error)

func (*UserRemoveParams) UnmarshalJSON added in v0.7.0

func (r *UserRemoveParams) UnmarshalJSON(data []byte) error

type UserResponse added in v0.7.0

type UserResponse struct {
	// User unique identifier
	ID string `json:"id" format:"uuid"`
	// When the user was added to the organization
	CreatedAt time.Time `json:"created_at" format:"date-time"`
	// User email address
	Email string `json:"email"`
	// When the user was invited
	InvitedAt time.Time `json:"invited_at,nullable" format:"date-time"`
	// When the user last logged in
	LastLoginAt time.Time `json:"last_login_at,nullable" format:"date-time"`
	// User full name
	Name string `json:"name"`
	// User role in the organization: admin, billing, developer
	Role string `json:"role"`
	// User status: active, invited, suspended, rejected
	Status string `json:"status"`
	// When the user record was last updated
	UpdatedAt time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Email       respjson.Field
		InvitedAt   respjson.Field
		LastLoginAt respjson.Field
		Name        respjson.Field
		Role        respjson.Field
		Status      respjson.Field
		UpdatedAt   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

User response for v3 API

func (UserResponse) RawJSON added in v0.7.0

func (r UserResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*UserResponse) UnmarshalJSON added in v0.7.0

func (r *UserResponse) UnmarshalJSON(data []byte) error

type UserService added in v0.7.0

type UserService struct {
	Options []option.RequestOption
}

UserService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUserService method instead.

func NewUserService added in v0.7.0

func NewUserService(opts ...option.RequestOption) (r UserService)

NewUserService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*UserService) Get added in v0.7.0

func (r *UserService) Get(ctx context.Context, userID string, opts ...option.RequestOption) (res *APIResponseOfUser, err error)

Retrieves detailed information about a specific user in an organization or profile. Requires developer role or higher.

func (*UserService) Invite added in v0.7.0

func (r *UserService) Invite(ctx context.Context, params UserInviteParams, opts ...option.RequestOption) (res *APIResponseOfUser, err error)

Sends an invitation to a user to join the organization or profile with a specific role. Requires admin role. The user will receive an invitation email with a token to accept. Invitation tokens expire after 7 days.

func (*UserService) List added in v0.7.0

func (r *UserService) List(ctx context.Context, opts ...option.RequestOption) (res *UserListResponse, err error)

Retrieves all users who have access to the organization or profile identified by the API key, including their roles and status. Shows invited users (pending acceptance) and active users. Requires developer role or higher.

func (*UserService) Remove added in v0.7.0

func (r *UserService) Remove(ctx context.Context, userID string, body UserRemoveParams, opts ...option.RequestOption) (err error)

Removes a user's access to an organization or profile. Requires admin role. You cannot remove yourself or remove the last admin.

func (*UserService) UpdateRole added in v0.7.0

func (r *UserService) UpdateRole(ctx context.Context, userID string, params UserUpdateRoleParams, opts ...option.RequestOption) (res *APIResponseOfUser, err error)

Updates a user's role in the organization or profile. Requires admin role. You cannot change your own role or demote the last admin.

type UserUpdateRoleParams added in v0.7.0

type UserUpdateRoleParams struct {
	// User role: admin, billing, or developer (required)
	Role param.Opt[string] `json:"role,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode param.Opt[bool] `json:"test_mode,omitzero"`
	// User ID from route parameter
	UserID         param.Opt[string] `json:"user_id,omitzero" format:"uuid"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (UserUpdateRoleParams) MarshalJSON added in v0.7.0

func (r UserUpdateRoleParams) MarshalJSON() (data []byte, err error)

func (*UserUpdateRoleParams) UnmarshalJSON added in v0.7.0

func (r *UserUpdateRoleParams) UnmarshalJSON(data []byte) error

type WebhookListEventTypesResponse added in v0.7.0

type WebhookListEventTypesResponse struct {
	// The response data (null if error)
	Data WebhookListEventTypesResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (WebhookListEventTypesResponse) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookListEventTypesResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventTypesResponse) UnmarshalJSON(data []byte) error

type WebhookListEventTypesResponseData added in v0.7.0

type WebhookListEventTypesResponseData struct {
	EventTypes []WebhookListEventTypesResponseDataEventType `json:"event_types"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EventTypes  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (WebhookListEventTypesResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookListEventTypesResponseData) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventTypesResponseData) UnmarshalJSON(data []byte) error

type WebhookListEventTypesResponseDataEventType added in v0.7.0

type WebhookListEventTypesResponseDataEventType struct {
	Description string `json:"description,nullable"`
	DisplayName string `json:"display_name"`
	IsActive    bool   `json:"is_active"`
	Name        string `json:"name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		DisplayName respjson.Field
		IsActive    respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListEventTypesResponseDataEventType) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookListEventTypesResponseDataEventType) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventTypesResponseDataEventType) UnmarshalJSON(data []byte) error

type WebhookListEventsParams added in v0.7.0

type WebhookListEventsParams struct {
	Page     int64             `query:"page,required" json:"-"`
	PageSize int64             `query:"pageSize,required" json:"-"`
	Search   param.Opt[string] `query:"search,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookListEventsParams) URLQuery added in v0.7.0

func (r WebhookListEventsParams) URLQuery() (v url.Values, err error)

URLQuery serializes WebhookListEventsParams's query parameters as `url.Values`.

type WebhookListEventsResponse added in v0.7.0

type WebhookListEventsResponse struct {
	// The response data (null if error)
	Data WebhookListEventsResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (WebhookListEventsResponse) RawJSON added in v0.7.0

func (r WebhookListEventsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListEventsResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventsResponse) UnmarshalJSON(data []byte) error

type WebhookListEventsResponseData added in v0.7.0

type WebhookListEventsResponseData struct {
	Events []WebhookListEventsResponseDataEvent `json:"events"`
	// Pagination metadata for list responses
	Pagination PaginationMeta `json:"pagination"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Events      respjson.Field
		Pagination  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (WebhookListEventsResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookListEventsResponseData) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventsResponseData) UnmarshalJSON(data []byte) error

type WebhookListEventsResponseDataEvent added in v0.7.0

type WebhookListEventsResponseDataEvent struct {
	ID                    string    `json:"id" format:"uuid"`
	CreatedAt             time.Time `json:"created_at" format:"date-time"`
	DeliveryAttempts      int64     `json:"delivery_attempts"`
	DeliveryStatus        string    `json:"delivery_status"`
	ErrorMessage          string    `json:"error_message,nullable"`
	EventData             any       `json:"event_data"`
	EventType             string    `json:"event_type"`
	HTTPStatusCode        int64     `json:"http_status_code,nullable"`
	ProcessingCompletedAt time.Time `json:"processing_completed_at,nullable" format:"date-time"`
	ProcessingStartedAt   time.Time `json:"processing_started_at,nullable" format:"date-time"`
	ResponseBody          string    `json:"response_body,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                    respjson.Field
		CreatedAt             respjson.Field
		DeliveryAttempts      respjson.Field
		DeliveryStatus        respjson.Field
		ErrorMessage          respjson.Field
		EventData             respjson.Field
		EventType             respjson.Field
		HTTPStatusCode        respjson.Field
		ProcessingCompletedAt respjson.Field
		ProcessingStartedAt   respjson.Field
		ResponseBody          respjson.Field
		ExtraFields           map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListEventsResponseDataEvent) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookListEventsResponseDataEvent) UnmarshalJSON added in v0.7.0

func (r *WebhookListEventsResponseDataEvent) UnmarshalJSON(data []byte) error

type WebhookListParams added in v0.7.0

type WebhookListParams struct {
	Page     int64             `query:"page,required" json:"-"`
	PageSize int64             `query:"pageSize,required" json:"-"`
	IsActive param.Opt[bool]   `query:"isActive,omitzero" json:"-"`
	Search   param.Opt[string] `query:"search,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookListParams) URLQuery added in v0.7.0

func (r WebhookListParams) URLQuery() (v url.Values, err error)

URLQuery serializes WebhookListParams's query parameters as `url.Values`.

type WebhookListResponse added in v0.7.0

type WebhookListResponse struct {
	// The response data (null if error)
	Data WebhookListResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (WebhookListResponse) RawJSON added in v0.7.0

func (r WebhookListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookListResponse) UnmarshalJSON(data []byte) error

type WebhookListResponseData added in v0.7.0

type WebhookListResponseData struct {
	// Pagination metadata for list responses
	Pagination PaginationMeta    `json:"pagination"`
	Webhooks   []WebhookResponse `json:"webhooks"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Pagination  respjson.Field
		Webhooks    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (WebhookListResponseData) RawJSON added in v0.7.0

func (r WebhookListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListResponseData) UnmarshalJSON added in v0.7.0

func (r *WebhookListResponseData) UnmarshalJSON(data []byte) error

type WebhookNewParams added in v0.7.0

type WebhookNewParams struct {
	DisplayName param.Opt[string] `json:"display_name,omitzero"`
	EndpointURL param.Opt[string] `json:"endpoint_url,omitzero"`
	RetryCount  param.Opt[int64]  `json:"retry_count,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	TimeoutSeconds param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	EventTypes     []string          `json:"event_types,omitzero"`
	// contains filtered or unexported fields
}

func (WebhookNewParams) MarshalJSON added in v0.7.0

func (r WebhookNewParams) MarshalJSON() (data []byte, err error)

func (*WebhookNewParams) UnmarshalJSON added in v0.7.0

func (r *WebhookNewParams) UnmarshalJSON(data []byte) error

type WebhookResponse added in v0.7.0

type WebhookResponse struct {
	ID                       string    `json:"id" format:"uuid"`
	ConsecutiveFailures      int64     `json:"consecutive_failures"`
	CreatedAt                time.Time `json:"created_at" format:"date-time"`
	DisplayName              string    `json:"display_name"`
	EndpointURL              string    `json:"endpoint_url"`
	EventTypes               []string  `json:"event_types"`
	IsActive                 bool      `json:"is_active"`
	LastDeliveryAttemptAt    time.Time `json:"last_delivery_attempt_at,nullable" format:"date-time"`
	LastSuccessfulDeliveryAt time.Time `json:"last_successful_delivery_at,nullable" format:"date-time"`
	RetryCount               int64     `json:"retry_count"`
	SigningSecret            string    `json:"signing_secret,nullable"`
	TimeoutSeconds           int64     `json:"timeout_seconds"`
	UpdatedAt                time.Time `json:"updated_at,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                       respjson.Field
		ConsecutiveFailures      respjson.Field
		CreatedAt                respjson.Field
		DisplayName              respjson.Field
		EndpointURL              respjson.Field
		EventTypes               respjson.Field
		IsActive                 respjson.Field
		LastDeliveryAttemptAt    respjson.Field
		LastSuccessfulDeliveryAt respjson.Field
		RetryCount               respjson.Field
		SigningSecret            respjson.Field
		TimeoutSeconds           respjson.Field
		UpdatedAt                respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookResponse) RawJSON added in v0.7.0

func (r WebhookResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookResponse) UnmarshalJSON(data []byte) error

type WebhookRotateSecretParams added in v0.7.0

type WebhookRotateSecretParams struct {
	Body           WebhookRotateSecretParamsBody
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookRotateSecretParams) MarshalJSON added in v0.7.0

func (r WebhookRotateSecretParams) MarshalJSON() (data []byte, err error)

func (*WebhookRotateSecretParams) UnmarshalJSON added in v0.7.0

func (r *WebhookRotateSecretParams) UnmarshalJSON(data []byte) error

type WebhookRotateSecretParamsBody added in v0.7.0

type WebhookRotateSecretParamsBody struct {
	MutationRequestParam
}

func (WebhookRotateSecretParamsBody) MarshalJSON added in v0.7.0

func (r WebhookRotateSecretParamsBody) MarshalJSON() (data []byte, err error)

type WebhookRotateSecretResponse added in v0.7.0

type WebhookRotateSecretResponse struct {
	// The response data (null if error)
	Data WebhookRotateSecretResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (WebhookRotateSecretResponse) RawJSON added in v0.7.0

func (r WebhookRotateSecretResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookRotateSecretResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookRotateSecretResponse) UnmarshalJSON(data []byte) error

type WebhookRotateSecretResponseData added in v0.7.0

type WebhookRotateSecretResponseData struct {
	SigningSecret string `json:"signing_secret"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SigningSecret respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (WebhookRotateSecretResponseData) RawJSON added in v0.7.0

Returns the unmodified JSON received from the API

func (*WebhookRotateSecretResponseData) UnmarshalJSON added in v0.7.0

func (r *WebhookRotateSecretResponseData) UnmarshalJSON(data []byte) error

type WebhookService added in v0.7.0

type WebhookService struct {
	Options []option.RequestOption
}

WebhookService contains methods and other services that help with interacting with the sent-dm API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWebhookService method instead.

func NewWebhookService added in v0.7.0

func NewWebhookService(opts ...option.RequestOption) (r WebhookService)

NewWebhookService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*WebhookService) Delete added in v0.7.0

func (r *WebhookService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Deletes a webhook for the authenticated customer.

func (*WebhookService) Get added in v0.7.0

func (r *WebhookService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *APIResponseWebhook, err error)

Retrieves a single webhook by ID for the authenticated customer.

func (*WebhookService) List added in v0.7.0

Retrieves a paginated list of webhooks for the authenticated customer.

func (*WebhookService) ListEventTypes added in v0.7.0

func (r *WebhookService) ListEventTypes(ctx context.Context, opts ...option.RequestOption) (res *WebhookListEventTypesResponse, err error)

Retrieves all available webhook event types that can be subscribed to.

func (*WebhookService) ListEvents added in v0.7.0

Retrieves a paginated list of delivery events for the specified webhook.

func (*WebhookService) New added in v0.7.0

Creates a new webhook endpoint for the authenticated customer.

func (*WebhookService) RotateSecret added in v0.7.0

Generates a new signing secret for the specified webhook. The old secret is immediately invalidated.

func (*WebhookService) Test added in v0.7.0

func (r *WebhookService) Test(ctx context.Context, id string, params WebhookTestParams, opts ...option.RequestOption) (res *WebhookTestResponse, err error)

Sends a test event to the specified webhook endpoint to verify connectivity.

func (*WebhookService) ToggleStatus added in v0.7.0

func (r *WebhookService) ToggleStatus(ctx context.Context, id string, params WebhookToggleStatusParams, opts ...option.RequestOption) (res *APIResponseWebhook, err error)

Activates or deactivates a webhook for the authenticated customer.

func (*WebhookService) Update added in v0.7.0

func (r *WebhookService) Update(ctx context.Context, id string, params WebhookUpdateParams, opts ...option.RequestOption) (res *APIResponseWebhook, err error)

Updates an existing webhook for the authenticated customer.

type WebhookTestParams added in v0.7.0

type WebhookTestParams struct {
	EventType param.Opt[string] `json:"event_type,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookTestParams) MarshalJSON added in v0.7.0

func (r WebhookTestParams) MarshalJSON() (data []byte, err error)

func (*WebhookTestParams) UnmarshalJSON added in v0.7.0

func (r *WebhookTestParams) UnmarshalJSON(data []byte) error

type WebhookTestResponse added in v0.7.0

type WebhookTestResponse struct {
	// The response data (null if error)
	Data WebhookTestResponseData `json:"data,nullable"`
	// Error details (null if successful)
	Error APIError `json:"error,nullable"`
	// Metadata about the request and response
	Meta APIMeta `json:"meta"`
	// Indicates whether the request was successful
	Success bool `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Error       respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Standard API response envelope for all v3 endpoints

func (WebhookTestResponse) RawJSON added in v0.7.0

func (r WebhookTestResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookTestResponse) UnmarshalJSON added in v0.7.0

func (r *WebhookTestResponse) UnmarshalJSON(data []byte) error

type WebhookTestResponseData added in v0.7.0

type WebhookTestResponseData struct {
	Message string `json:"message"`
	Success bool   `json:"success"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response data (null if error)

func (WebhookTestResponseData) RawJSON added in v0.7.0

func (r WebhookTestResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookTestResponseData) UnmarshalJSON added in v0.7.0

func (r *WebhookTestResponseData) UnmarshalJSON(data []byte) error

type WebhookToggleStatusParams added in v0.7.0

type WebhookToggleStatusParams struct {
	IsActive param.Opt[bool] `json:"is_active,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookToggleStatusParams) MarshalJSON added in v0.7.0

func (r WebhookToggleStatusParams) MarshalJSON() (data []byte, err error)

func (*WebhookToggleStatusParams) UnmarshalJSON added in v0.7.0

func (r *WebhookToggleStatusParams) UnmarshalJSON(data []byte) error

type WebhookUpdateParams added in v0.7.0

type WebhookUpdateParams struct {
	DisplayName param.Opt[string] `json:"display_name,omitzero"`
	EndpointURL param.Opt[string] `json:"endpoint_url,omitzero"`
	RetryCount  param.Opt[int64]  `json:"retry_count,omitzero"`
	// Test mode flag - when true, the operation is simulated without side effects
	// Useful for testing integrations without actual execution
	TestMode       param.Opt[bool]   `json:"test_mode,omitzero"`
	TimeoutSeconds param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	EventTypes     []string          `json:"event_types,omitzero"`
	// contains filtered or unexported fields
}

func (WebhookUpdateParams) MarshalJSON added in v0.7.0

func (r WebhookUpdateParams) MarshalJSON() (data []byte, err error)

func (*WebhookUpdateParams) UnmarshalJSON added in v0.7.0

func (r *WebhookUpdateParams) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages
shared

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL