ark

package module
v0.6.0 Latest Latest
Warning

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

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

README

Ark Go API Library

Go Reference

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

It is generated with Stainless.

MCP Server

Use the Ark MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

Add to Cursor Install in VS Code

Note: You may need to set environment variables in your MCP client.

Installation

import (
	"github.com/ArkHQ-io/ark-go" // imported as ark
)

Or to pin the version:

go get -u 'github.com/ArkHQ-io/[email protected]'

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/ArkHQ-io/ark-go"
	"github.com/ArkHQ-io/ark-go/option"
)

func main() {
	client := ark.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("ARK_API_KEY")
	)
	response, err := client.Emails.Send(context.TODO(), ark.EmailSendParams{
		From:    "[email protected]",
		Subject: "Hello World",
		To:      []string{"[email protected]"},
		HTML:    ark.String("<h1>Welcome!</h1>"),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
}

Request fields

The ark 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, ark.String(string), ark.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 := ark.ExampleParams{
	ID:   "id_xxx",          // required property
	Name: ark.String("..."), // optional property

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

	Origin: ark.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[ark.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 := ark.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Emails.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:

iter := client.Emails.ListAutoPaging(context.TODO(), ark.EmailListParams{
	Page:    ark.Int(1),
	PerPage: ark.Int(10),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	emailListResponse := iter.Current()
	fmt.Printf("%+v\n", emailListResponse)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

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.:

page, err := client.Emails.List(context.TODO(), ark.EmailListParams{
	Page:    ark.Int(1),
	PerPage: ark.Int(10),
})
for page != nil {
	for _, email := range page.Data {
		fmt.Printf("%+v\n", email)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *ark.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.Emails.Send(context.TODO(), ark.EmailSendParams{
	From:    "[email protected]",
	Subject: "Hello World",
	To:      []string{"[email protected]"},
	HTML:    ark.String("<h1>Welcome!</h1>"),
})
if err != nil {
	var apierr *ark.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 "/emails": 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.Emails.Send(
	ctx,
	ark.EmailSendParams{
		From:    "[email protected]",
		Subject: "Hello World",
		To:      []string{"[email protected]"},
		HTML:    ark.String("<h1>Welcome!</h1>"),
	},
	// 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 ark.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 := ark.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Emails.Send(
	context.TODO(),
	ark.EmailSendParams{
		From:    "[email protected]",
		Subject: "Hello World",
		To:      []string{"[email protected]"},
		HTML:    ark.String("<h1>Welcome!</h1>"),
	},
	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.Emails.Send(
	context.TODO(),
	ark.EmailSendParams{
		From:    "[email protected]",
		Subject: "Hello World",
		To:      []string{"[email protected]"},
		HTML:    ark.String("<h1>Welcome!</h1>"),
	},
	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: ark.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 := ark.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 (ARK_API_KEY, ARK_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 APIMeta

type APIMeta = shared.APIMeta

This is an alias to an internal type.

type Client

type Client struct {
	Options      []option.RequestOption
	Emails       EmailService
	Domains      DomainService
	Suppressions SuppressionService
	Webhooks     WebhookService
	Tracking     TrackingService
}

Client creates a struct with services and top level methods that help with interacting with the ark 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 (ARK_API_KEY, ARK_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 DNSRecord

type DNSRecord struct {
	// DNS record name (hostname)
	Name string `json:"name,required"`
	// DNS record type
	//
	// Any of "TXT", "CNAME", "MX".
	Type DNSRecordType `json:"type,required"`
	// DNS record value
	Value string `json:"value,required"`
	// DNS verification status:
	//
	// - `OK` - Record is correctly configured
	// - `Missing` - Record not found in DNS
	// - `Invalid` - Record exists but has wrong value
	// - `null` - Not yet checked
	//
	// Any of "OK", "Missing", "Invalid".
	Status DNSRecordStatus `json:"status,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DNSRecord) RawJSON

func (r DNSRecord) RawJSON() string

Returns the unmodified JSON received from the API

func (*DNSRecord) UnmarshalJSON

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

type DNSRecordStatus

type DNSRecordStatus string

DNS verification status:

- `OK` - Record is correctly configured - `Missing` - Record not found in DNS - `Invalid` - Record exists but has wrong value - `null` - Not yet checked

const (
	DNSRecordStatusOk      DNSRecordStatus = "OK"
	DNSRecordStatusMissing DNSRecordStatus = "Missing"
	DNSRecordStatusInvalid DNSRecordStatus = "Invalid"
)

type DNSRecordType

type DNSRecordType string

DNS record type

const (
	DNSRecordTypeTxt   DNSRecordType = "TXT"
	DNSRecordTypeCname DNSRecordType = "CNAME"
	DNSRecordTypeMx    DNSRecordType = "MX"
)

type DomainDeleteResponse added in v0.3.0

type DomainDeleteResponse struct {
	Data    DomainDeleteResponseData `json:"data,required"`
	Meta    shared.APIMeta           `json:"meta,required"`
	Success bool                     `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainDeleteResponse) RawJSON added in v0.3.0

func (r DomainDeleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainDeleteResponse) UnmarshalJSON added in v0.3.0

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

type DomainDeleteResponseData added in v0.3.0

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

func (DomainDeleteResponseData) RawJSON added in v0.3.0

func (r DomainDeleteResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainDeleteResponseData) UnmarshalJSON added in v0.3.0

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

type DomainGetResponse added in v0.3.0

type DomainGetResponse struct {
	Data    DomainGetResponseData `json:"data,required"`
	Meta    shared.APIMeta        `json:"meta,required"`
	Success bool                  `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainGetResponse) RawJSON added in v0.3.0

func (r DomainGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainGetResponse) UnmarshalJSON added in v0.3.0

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

type DomainGetResponseData added in v0.3.0

type DomainGetResponseData struct {
	// Domain ID
	ID         string                          `json:"id,required"`
	CreatedAt  time.Time                       `json:"createdAt,required" format:"date-time"`
	DNSRecords DomainGetResponseDataDNSRecords `json:"dnsRecords,required"`
	// Domain name
	Name string `json:"name,required"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// Whether DNS is verified
	Verified bool `json:"verified,required"`
	// When the domain was verified (null if not verified)
	VerifiedAt time.Time `json:"verifiedAt,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		DNSRecords  respjson.Field
		Name        respjson.Field
		Uuid        respjson.Field
		Verified    respjson.Field
		VerifiedAt  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainGetResponseData) RawJSON added in v0.3.0

func (r DomainGetResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainGetResponseData) UnmarshalJSON added in v0.3.0

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

type DomainGetResponseDataDNSRecords added in v0.3.0

type DomainGetResponseDataDNSRecords struct {
	Dkim       DNSRecord `json:"dkim,required"`
	ReturnPath DNSRecord `json:"returnPath,required"`
	Spf        DNSRecord `json:"spf,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Dkim        respjson.Field
		ReturnPath  respjson.Field
		Spf         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainGetResponseDataDNSRecords) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*DomainGetResponseDataDNSRecords) UnmarshalJSON added in v0.3.0

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

type DomainListResponse

type DomainListResponse struct {
	Data    DomainListResponseData `json:"data,required"`
	Meta    shared.APIMeta         `json:"meta,required"`
	Success bool                   `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainListResponse) RawJSON

func (r DomainListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainListResponse) UnmarshalJSON

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

type DomainListResponseData

type DomainListResponseData struct {
	Domains []DomainListResponseDataDomain `json:"domains,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Domains     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainListResponseData) RawJSON

func (r DomainListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainListResponseData) UnmarshalJSON

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

type DomainListResponseDataDomain

type DomainListResponseDataDomain struct {
	// Domain ID
	ID       string `json:"id,required"`
	DNSOk    bool   `json:"dnsOk,required"`
	Name     string `json:"name,required"`
	Verified bool   `json:"verified,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		DNSOk       respjson.Field
		Name        respjson.Field
		Verified    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainListResponseDataDomain) RawJSON

Returns the unmodified JSON received from the API

func (*DomainListResponseDataDomain) UnmarshalJSON

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

type DomainNewParams

type DomainNewParams struct {
	// Domain name (e.g., "mail.example.com")
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

func (DomainNewParams) MarshalJSON

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

func (*DomainNewParams) UnmarshalJSON

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

type DomainNewResponse added in v0.3.0

type DomainNewResponse struct {
	Data    DomainNewResponseData `json:"data,required"`
	Meta    shared.APIMeta        `json:"meta,required"`
	Success bool                  `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainNewResponse) RawJSON added in v0.3.0

func (r DomainNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainNewResponse) UnmarshalJSON added in v0.3.0

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

type DomainNewResponseData added in v0.3.0

type DomainNewResponseData struct {
	// Domain ID
	ID         string                          `json:"id,required"`
	CreatedAt  time.Time                       `json:"createdAt,required" format:"date-time"`
	DNSRecords DomainNewResponseDataDNSRecords `json:"dnsRecords,required"`
	// Domain name
	Name string `json:"name,required"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// Whether DNS is verified
	Verified bool `json:"verified,required"`
	// When the domain was verified (null if not verified)
	VerifiedAt time.Time `json:"verifiedAt,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		DNSRecords  respjson.Field
		Name        respjson.Field
		Uuid        respjson.Field
		Verified    respjson.Field
		VerifiedAt  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainNewResponseData) RawJSON added in v0.3.0

func (r DomainNewResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainNewResponseData) UnmarshalJSON added in v0.3.0

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

type DomainNewResponseDataDNSRecords added in v0.3.0

type DomainNewResponseDataDNSRecords struct {
	Dkim       DNSRecord `json:"dkim,required"`
	ReturnPath DNSRecord `json:"returnPath,required"`
	Spf        DNSRecord `json:"spf,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Dkim        respjson.Field
		ReturnPath  respjson.Field
		Spf         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainNewResponseDataDNSRecords) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*DomainNewResponseDataDNSRecords) UnmarshalJSON added in v0.3.0

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

type DomainService

type DomainService struct {
	Options []option.RequestOption
}

DomainService contains methods and other services that help with interacting with the ark 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 NewDomainService method instead.

func NewDomainService

func NewDomainService(opts ...option.RequestOption) (r DomainService)

NewDomainService 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 (*DomainService) Delete

func (r *DomainService) Delete(ctx context.Context, domainID string, opts ...option.RequestOption) (res *DomainDeleteResponse, err error)

Remove a sending domain. You will no longer be able to send emails from this domain.

**Warning:** This action cannot be undone.

func (*DomainService) Get

func (r *DomainService) Get(ctx context.Context, domainID string, opts ...option.RequestOption) (res *DomainGetResponse, err error)

Get detailed information about a domain including DNS record status

func (*DomainService) List

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

Get all sending domains with their verification status

func (*DomainService) New

Add a new domain for sending emails. Returns DNS records that must be configured before the domain can be verified.

**Required DNS records:**

- **SPF** - TXT record for sender authentication - **DKIM** - TXT record for email signing - **Return Path** - CNAME for bounce handling

After adding DNS records, call `POST /domains/{id}/verify` to verify.

func (*DomainService) Verify

func (r *DomainService) Verify(ctx context.Context, domainID string, opts ...option.RequestOption) (res *DomainVerifyResponse, err error)

Check if DNS records are correctly configured and verify the domain. Returns the current status of each required DNS record.

Call this after you've added the DNS records shown when creating the domain.

type DomainVerifyResponse added in v0.3.0

type DomainVerifyResponse struct {
	Data    DomainVerifyResponseData `json:"data,required"`
	Meta    shared.APIMeta           `json:"meta,required"`
	Success bool                     `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainVerifyResponse) RawJSON added in v0.3.0

func (r DomainVerifyResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainVerifyResponse) UnmarshalJSON added in v0.3.0

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

type DomainVerifyResponseData added in v0.3.0

type DomainVerifyResponseData struct {
	// Domain ID
	ID         string                             `json:"id,required"`
	CreatedAt  time.Time                          `json:"createdAt,required" format:"date-time"`
	DNSRecords DomainVerifyResponseDataDNSRecords `json:"dnsRecords,required"`
	// Domain name
	Name string `json:"name,required"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// Whether DNS is verified
	Verified bool `json:"verified,required"`
	// When the domain was verified (null if not verified)
	VerifiedAt time.Time `json:"verifiedAt,nullable" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		DNSRecords  respjson.Field
		Name        respjson.Field
		Uuid        respjson.Field
		Verified    respjson.Field
		VerifiedAt  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainVerifyResponseData) RawJSON added in v0.3.0

func (r DomainVerifyResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*DomainVerifyResponseData) UnmarshalJSON added in v0.3.0

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

type DomainVerifyResponseDataDNSRecords added in v0.3.0

type DomainVerifyResponseDataDNSRecords struct {
	Dkim       DNSRecord `json:"dkim,required"`
	ReturnPath DNSRecord `json:"returnPath,required"`
	Spf        DNSRecord `json:"spf,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Dkim        respjson.Field
		ReturnPath  respjson.Field
		Spf         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DomainVerifyResponseDataDNSRecords) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*DomainVerifyResponseDataDNSRecords) UnmarshalJSON added in v0.3.0

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

type EmailGetDeliveriesResponse

type EmailGetDeliveriesResponse struct {
	Data    EmailGetDeliveriesResponseData `json:"data,required"`
	Meta    shared.APIMeta                 `json:"meta,required"`
	Success bool                           `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetDeliveriesResponse) RawJSON

func (r EmailGetDeliveriesResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailGetDeliveriesResponse) UnmarshalJSON

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

type EmailGetDeliveriesResponseData

type EmailGetDeliveriesResponseData struct {
	Deliveries []EmailGetDeliveriesResponseDataDelivery `json:"deliveries,required"`
	// Internal message ID
	MessageID string `json:"messageId,required"`
	// Message token
	MessageToken string `json:"messageToken,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Deliveries   respjson.Field
		MessageID    respjson.Field
		MessageToken respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetDeliveriesResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*EmailGetDeliveriesResponseData) UnmarshalJSON

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

type EmailGetDeliveriesResponseDataDelivery added in v0.3.0

type EmailGetDeliveriesResponseDataDelivery struct {
	// Delivery attempt ID
	ID string `json:"id,required"`
	// Delivery status (lowercase)
	Status string `json:"status,required"`
	// Unix timestamp
	Timestamp float64 `json:"timestamp,required"`
	// ISO 8601 timestamp
	TimestampISO time.Time `json:"timestampIso,required" format:"date-time"`
	// SMTP response code
	Code int64 `json:"code"`
	// Status details
	Details string `json:"details"`
	// SMTP server response from the receiving mail server
	Output string `json:"output"`
	// Whether TLS was used
	SentWithSsl bool `json:"sentWithSsl"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		Status       respjson.Field
		Timestamp    respjson.Field
		TimestampISO respjson.Field
		Code         respjson.Field
		Details      respjson.Field
		Output       respjson.Field
		SentWithSsl  respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetDeliveriesResponseDataDelivery) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*EmailGetDeliveriesResponseDataDelivery) UnmarshalJSON added in v0.3.0

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

type EmailGetParams

type EmailGetParams struct {
	// Comma-separated list of fields to include:
	//
	// - `content` - HTML and plain text body
	// - `headers` - Email headers
	// - `deliveries` - Delivery attempt history
	// - `activity` - Opens and clicks
	Expand param.Opt[string] `query:"expand,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (EmailGetParams) URLQuery

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

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

type EmailGetResponse

type EmailGetResponse struct {
	Data    EmailGetResponseData `json:"data,required"`
	Meta    shared.APIMeta       `json:"meta,required"`
	Success bool                 `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetResponse) RawJSON

func (r EmailGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailGetResponse) UnmarshalJSON

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

type EmailGetResponseData

type EmailGetResponseData struct {
	// Internal message ID
	ID string `json:"id,required"`
	// Unique message token used to retrieve this email via API. Combined with id to
	// form the full message identifier: msg*{id}*{token} Use this token with GET
	// /emails/{emailId} where emailId = "msg*{id}*{token}"
	Token string `json:"token,required"`
	// Sender address
	From string `json:"from,required"`
	// Message direction
	//
	// Any of "outgoing", "incoming".
	Scope string `json:"scope,required"`
	// Current delivery status:
	//
	// - `pending` - Email accepted, waiting to be processed
	// - `sent` - Email transmitted to recipient's mail server
	// - `softfail` - Temporary delivery failure, will retry
	// - `hardfail` - Permanent delivery failure
	// - `bounced` - Email bounced back
	// - `held` - Held for manual review
	//
	// Any of "pending", "sent", "softfail", "hardfail", "bounced", "held".
	Status string `json:"status,required"`
	// Email subject line
	Subject string `json:"subject,required"`
	// Unix timestamp when the email was sent
	Timestamp float64 `json:"timestamp,required"`
	// ISO 8601 formatted timestamp
	TimestampISO time.Time `json:"timestampIso,required" format:"date-time"`
	// Recipient address
	To string `json:"to,required" format:"email"`
	// Delivery attempt history (included if expand=deliveries)
	Deliveries []EmailGetResponseDataDelivery `json:"deliveries"`
	// Email headers (included if expand=headers)
	Headers map[string]string `json:"headers"`
	// HTML body content (included if expand=content)
	HTMLBody string `json:"htmlBody"`
	// SMTP Message-ID header
	MessageID string `json:"messageId"`
	// Plain text body (included if expand=content)
	PlainBody string `json:"plainBody"`
	// Whether the message was flagged as spam
	Spam bool `json:"spam"`
	// Spam score (if applicable)
	SpamScore float64 `json:"spamScore"`
	// Optional categorization tag
	Tag string `json:"tag"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		Token        respjson.Field
		From         respjson.Field
		Scope        respjson.Field
		Status       respjson.Field
		Subject      respjson.Field
		Timestamp    respjson.Field
		TimestampISO respjson.Field
		To           respjson.Field
		Deliveries   respjson.Field
		Headers      respjson.Field
		HTMLBody     respjson.Field
		MessageID    respjson.Field
		PlainBody    respjson.Field
		Spam         respjson.Field
		SpamScore    respjson.Field
		Tag          respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetResponseData) RawJSON

func (r EmailGetResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailGetResponseData) UnmarshalJSON

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

type EmailGetResponseDataDelivery added in v0.3.0

type EmailGetResponseDataDelivery struct {
	// Delivery attempt ID
	ID string `json:"id,required"`
	// Delivery status (lowercase)
	Status string `json:"status,required"`
	// Unix timestamp
	Timestamp float64 `json:"timestamp,required"`
	// ISO 8601 timestamp
	TimestampISO time.Time `json:"timestampIso,required" format:"date-time"`
	// SMTP response code
	Code int64 `json:"code"`
	// Status details
	Details string `json:"details"`
	// SMTP server response from the receiving mail server
	Output string `json:"output"`
	// Whether TLS was used
	SentWithSsl bool `json:"sentWithSsl"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		Status       respjson.Field
		Timestamp    respjson.Field
		TimestampISO respjson.Field
		Code         respjson.Field
		Details      respjson.Field
		Output       respjson.Field
		SentWithSsl  respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailGetResponseDataDelivery) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*EmailGetResponseDataDelivery) UnmarshalJSON added in v0.3.0

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

type EmailListParams

type EmailListParams struct {
	// Return emails sent after this timestamp (Unix seconds or ISO 8601)
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Return emails sent before this timestamp
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// Filter by sender email address
	From param.Opt[string] `query:"from,omitzero" format:"email" json:"-"`
	// Page number (starts at 1)
	Page param.Opt[int64] `query:"page,omitzero" json:"-"`
	// Results per page (max 100)
	PerPage param.Opt[int64] `query:"perPage,omitzero" json:"-"`
	// Filter by tag
	Tag param.Opt[string] `query:"tag,omitzero" json:"-"`
	// Filter by recipient email address
	To param.Opt[string] `query:"to,omitzero" format:"email" json:"-"`
	// Filter by delivery status:
	//
	// - `pending` - Email accepted, waiting to be processed
	// - `sent` - Email transmitted to recipient's mail server
	// - `softfail` - Temporary delivery failure, will retry
	// - `hardfail` - Permanent delivery failure
	// - `bounced` - Email bounced back
	// - `held` - Held for manual review
	//
	// Any of "pending", "sent", "softfail", "hardfail", "bounced", "held".
	Status EmailListParamsStatus `query:"status,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (EmailListParams) URLQuery

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

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

type EmailListParamsStatus

type EmailListParamsStatus string

Filter by delivery status:

- `pending` - Email accepted, waiting to be processed - `sent` - Email transmitted to recipient's mail server - `softfail` - Temporary delivery failure, will retry - `hardfail` - Permanent delivery failure - `bounced` - Email bounced back - `held` - Held for manual review

const (
	EmailListParamsStatusPending  EmailListParamsStatus = "pending"
	EmailListParamsStatusSent     EmailListParamsStatus = "sent"
	EmailListParamsStatusSoftfail EmailListParamsStatus = "softfail"
	EmailListParamsStatusHardfail EmailListParamsStatus = "hardfail"
	EmailListParamsStatusBounced  EmailListParamsStatus = "bounced"
	EmailListParamsStatusHeld     EmailListParamsStatus = "held"
)

type EmailListResponse

type EmailListResponse struct {
	// Internal message ID
	ID    string `json:"id,required"`
	Token string `json:"token,required"`
	From  string `json:"from,required"`
	// Current delivery status:
	//
	// - `pending` - Email accepted, waiting to be processed
	// - `sent` - Email transmitted to recipient's mail server
	// - `softfail` - Temporary delivery failure, will retry
	// - `hardfail` - Permanent delivery failure
	// - `bounced` - Email bounced back
	// - `held` - Held for manual review
	//
	// Any of "pending", "sent", "softfail", "hardfail", "bounced", "held".
	Status       EmailListResponseStatus `json:"status,required"`
	Subject      string                  `json:"subject,required"`
	Timestamp    float64                 `json:"timestamp,required"`
	TimestampISO time.Time               `json:"timestampIso,required" format:"date-time"`
	To           string                  `json:"to,required" format:"email"`
	Tag          string                  `json:"tag"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		Token        respjson.Field
		From         respjson.Field
		Status       respjson.Field
		Subject      respjson.Field
		Timestamp    respjson.Field
		TimestampISO respjson.Field
		To           respjson.Field
		Tag          respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailListResponse) RawJSON

func (r EmailListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailListResponse) UnmarshalJSON

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

type EmailListResponseStatus added in v0.4.0

type EmailListResponseStatus string

Current delivery status:

- `pending` - Email accepted, waiting to be processed - `sent` - Email transmitted to recipient's mail server - `softfail` - Temporary delivery failure, will retry - `hardfail` - Permanent delivery failure - `bounced` - Email bounced back - `held` - Held for manual review

const (
	EmailListResponseStatusPending  EmailListResponseStatus = "pending"
	EmailListResponseStatusSent     EmailListResponseStatus = "sent"
	EmailListResponseStatusSoftfail EmailListResponseStatus = "softfail"
	EmailListResponseStatusHardfail EmailListResponseStatus = "hardfail"
	EmailListResponseStatusBounced  EmailListResponseStatus = "bounced"
	EmailListResponseStatusHeld     EmailListResponseStatus = "held"
)

type EmailRetryResponse

type EmailRetryResponse struct {
	Data    EmailRetryResponseData `json:"data,required"`
	Meta    shared.APIMeta         `json:"meta,required"`
	Success bool                   `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailRetryResponse) RawJSON

func (r EmailRetryResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailRetryResponse) UnmarshalJSON

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

type EmailRetryResponseData

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

func (EmailRetryResponseData) RawJSON

func (r EmailRetryResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailRetryResponseData) UnmarshalJSON

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

type EmailSendBatchParams

type EmailSendBatchParams struct {
	Emails []EmailSendBatchParamsEmail `json:"emails,omitzero,required"`
	// Sender email for all messages
	From           string            `json:"from,required"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (EmailSendBatchParams) MarshalJSON

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

func (*EmailSendBatchParams) UnmarshalJSON

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

type EmailSendBatchParamsEmail

type EmailSendBatchParamsEmail struct {
	Subject string            `json:"subject,required"`
	To      []string          `json:"to,omitzero,required" format:"email"`
	HTML    param.Opt[string] `json:"html,omitzero"`
	Tag     param.Opt[string] `json:"tag,omitzero"`
	Text    param.Opt[string] `json:"text,omitzero"`
	// Custom key-value pairs attached to an email for webhook correlation.
	//
	// When you send an email with metadata, these key-value pairs are:
	//
	// - **Stored** with the message
	// - **Returned** in all webhook event payloads (MessageSent, MessageBounced, etc.)
	// - **Never visible** to email recipients
	//
	// This is useful for correlating webhook events with your internal systems (e.g.,
	// user IDs, order IDs, campaign identifiers).
	Metadata map[string]string `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

The properties Subject, To are required.

func (EmailSendBatchParamsEmail) MarshalJSON

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

func (*EmailSendBatchParamsEmail) UnmarshalJSON

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

type EmailSendBatchResponse

type EmailSendBatchResponse struct {
	Data    EmailSendBatchResponseData `json:"data,required"`
	Meta    shared.APIMeta             `json:"meta,required"`
	Success bool                       `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendBatchResponse) RawJSON

func (r EmailSendBatchResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendBatchResponse) UnmarshalJSON

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

type EmailSendBatchResponseData

type EmailSendBatchResponseData struct {
	// Successfully accepted emails
	Accepted int64 `json:"accepted,required"`
	// Failed emails
	Failed int64 `json:"failed,required"`
	// Map of recipient email to message info
	Messages map[string]EmailSendBatchResponseDataMessage `json:"messages,required"`
	// Total emails in the batch
	Total int64 `json:"total,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Accepted    respjson.Field
		Failed      respjson.Field
		Messages    respjson.Field
		Total       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendBatchResponseData) RawJSON

func (r EmailSendBatchResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendBatchResponseData) UnmarshalJSON

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

type EmailSendBatchResponseDataMessage

type EmailSendBatchResponseDataMessage struct {
	// Message ID
	ID    string `json:"id,required"`
	Token string `json:"token,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Token       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendBatchResponseDataMessage) RawJSON

Returns the unmodified JSON received from the API

func (*EmailSendBatchResponseDataMessage) UnmarshalJSON

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

type EmailSendParams

type EmailSendParams struct {
	// Sender email address. Must be from a verified domain.
	//
	// **Supported formats:**
	//
	// - Email only: `[email protected]`
	// - With display name: `Acme <[email protected]>`
	// - With quoted name: `"Acme Support" <[email protected]>`
	//
	// The domain portion must match a verified sending domain in your account.
	From string `json:"from,required"`
	// Email subject line
	Subject string `json:"subject,required"`
	// Recipient email addresses (max 50)
	To []string `json:"to,omitzero,required" format:"email"`
	// HTML body content (accepts null). Maximum 5MB (5,242,880 characters). Combined
	// with attachments, the total message must not exceed 14MB.
	HTML param.Opt[string] `json:"html,omitzero"`
	// Reply-to address (accepts null)
	ReplyTo param.Opt[string] `json:"replyTo,omitzero" format:"email"`
	// Tag for categorization and filtering (accepts null)
	Tag param.Opt[string] `json:"tag,omitzero"`
	// Plain text body (accepts null, auto-generated from HTML if not provided).
	// Maximum 5MB (5,242,880 characters).
	Text           param.Opt[string] `json:"text,omitzero"`
	IdempotencyKey param.Opt[string] `header:"Idempotency-Key,omitzero" json:"-"`
	// File attachments (accepts null)
	Attachments []EmailSendParamsAttachment `json:"attachments,omitzero"`
	// BCC recipients (accepts null)
	Bcc []string `json:"bcc,omitzero" format:"email"`
	// CC recipients (accepts null)
	Cc []string `json:"cc,omitzero" format:"email"`
	// Custom email headers (accepts null)
	Headers map[string]string `json:"headers,omitzero"`
	// Custom key-value pairs attached to an email for webhook correlation.
	//
	// When you send an email with metadata, these key-value pairs are:
	//
	// - **Stored** with the message
	// - **Returned** in all webhook event payloads (MessageSent, MessageBounced, etc.)
	// - **Never visible** to email recipients
	//
	// This is useful for correlating webhook events with your internal systems (e.g.,
	// user IDs, order IDs, campaign identifiers).
	Metadata map[string]string `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (EmailSendParams) MarshalJSON

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

func (*EmailSendParams) UnmarshalJSON

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

type EmailSendParamsAttachment

type EmailSendParamsAttachment struct {
	// Base64-encoded file content
	Content string `json:"content,required"`
	// MIME type
	ContentType string `json:"contentType,required"`
	// Attachment filename
	Filename string `json:"filename,required"`
	// contains filtered or unexported fields
}

The properties Content, ContentType, Filename are required.

func (EmailSendParamsAttachment) MarshalJSON

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

func (*EmailSendParamsAttachment) UnmarshalJSON

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

type EmailSendRawParams

type EmailSendRawParams struct {
	// Base64-encoded RFC 2822 message
	Data string `json:"data,required"`
	// Envelope sender address
	MailFrom string `json:"mailFrom,required" format:"email"`
	// Envelope recipient addresses
	RcptTo []string `json:"rcptTo,omitzero,required" format:"email"`
	// Whether this is a bounce message (accepts null)
	Bounce param.Opt[bool] `json:"bounce,omitzero"`
	// contains filtered or unexported fields
}

func (EmailSendRawParams) MarshalJSON

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

func (*EmailSendRawParams) UnmarshalJSON

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

type EmailSendRawResponse added in v0.3.0

type EmailSendRawResponse struct {
	Data    EmailSendRawResponseData `json:"data,required"`
	Meta    shared.APIMeta           `json:"meta,required"`
	Success bool                     `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendRawResponse) RawJSON added in v0.3.0

func (r EmailSendRawResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendRawResponse) UnmarshalJSON added in v0.3.0

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

type EmailSendRawResponseData added in v0.3.0

type EmailSendRawResponseData struct {
	// Unique message ID (format: msg*{id}*{token})
	ID string `json:"id,required"`
	// Current delivery status
	//
	// Any of "pending", "sent".
	Status string `json:"status,required"`
	// List of recipient addresses
	To []string `json:"to,required" format:"email"`
	// SMTP Message-ID header value
	MessageID string `json:"messageId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Status      respjson.Field
		To          respjson.Field
		MessageID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendRawResponseData) RawJSON added in v0.3.0

func (r EmailSendRawResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendRawResponseData) UnmarshalJSON added in v0.3.0

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

type EmailSendResponse added in v0.3.0

type EmailSendResponse struct {
	Data    EmailSendResponseData `json:"data,required"`
	Meta    shared.APIMeta        `json:"meta,required"`
	Success bool                  `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendResponse) RawJSON added in v0.3.0

func (r EmailSendResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendResponse) UnmarshalJSON added in v0.3.0

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

type EmailSendResponseData added in v0.3.0

type EmailSendResponseData struct {
	// Unique message ID (format: msg*{id}*{token})
	ID string `json:"id,required"`
	// Current delivery status
	//
	// Any of "pending", "sent".
	Status string `json:"status,required"`
	// List of recipient addresses
	To []string `json:"to,required" format:"email"`
	// SMTP Message-ID header value
	MessageID string `json:"messageId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Status      respjson.Field
		To          respjson.Field
		MessageID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (EmailSendResponseData) RawJSON added in v0.3.0

func (r EmailSendResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*EmailSendResponseData) UnmarshalJSON added in v0.3.0

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

type EmailService

type EmailService struct {
	Options []option.RequestOption
}

EmailService contains methods and other services that help with interacting with the ark 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 NewEmailService method instead.

func NewEmailService

func NewEmailService(opts ...option.RequestOption) (r EmailService)

NewEmailService 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 (*EmailService) Get

func (r *EmailService) Get(ctx context.Context, emailID string, query EmailGetParams, opts ...option.RequestOption) (res *EmailGetResponse, err error)

Retrieve detailed information about a specific email including delivery status, timestamps, and optionally the email content.

Use the `expand` parameter to include additional data like the HTML/text body, headers, or delivery attempts.

func (*EmailService) GetDeliveries

func (r *EmailService) GetDeliveries(ctx context.Context, emailID string, opts ...option.RequestOption) (res *EmailGetDeliveriesResponse, err error)

Get the history of delivery attempts for an email, including SMTP response codes and timestamps.

func (*EmailService) List

Retrieve a paginated list of sent emails. Results are ordered by send time, newest first.

Use filters to narrow down results by status, recipient, sender, or tag.

**Related endpoints:**

- `GET /emails/{id}` - Get full details of a specific email - `POST /emails` - Send a new email

func (*EmailService) ListAutoPaging added in v0.4.0

Retrieve a paginated list of sent emails. Results are ordered by send time, newest first.

Use filters to narrow down results by status, recipient, sender, or tag.

**Related endpoints:**

- `GET /emails/{id}` - Get full details of a specific email - `POST /emails` - Send a new email

func (*EmailService) Retry

func (r *EmailService) Retry(ctx context.Context, emailID string, opts ...option.RequestOption) (res *EmailRetryResponse, err error)

Retry delivery of a failed or soft-bounced email. Creates a new delivery attempt.

Only works for emails that have failed or are in a retryable state.

func (*EmailService) Send

func (r *EmailService) Send(ctx context.Context, params EmailSendParams, opts ...option.RequestOption) (res *EmailSendResponse, err error)

Send a single email message. The email is accepted for immediate delivery and typically delivered within seconds.

**Example use case:** Send a password reset email to a user.

**Required fields:** `from`, `to`, `subject`, and either `html` or `text`

**Idempotency:** Supports `Idempotency-Key` header for safe retries.

**Related endpoints:**

- `GET /emails/{id}` - Track delivery status - `GET /emails/{id}/deliveries` - View delivery attempts - `POST /emails/{id}/retry` - Retry failed delivery

func (*EmailService) SendBatch

func (r *EmailService) SendBatch(ctx context.Context, params EmailSendBatchParams, opts ...option.RequestOption) (res *EmailSendBatchResponse, err error)

Send up to 100 emails in a single request. Useful for sending personalized emails to multiple recipients efficiently.

Each email in the batch can have different content and recipients. Failed emails don't affect other emails in the batch.

**Idempotency:** Supports `Idempotency-Key` header for safe retries.

func (*EmailService) SendRaw

func (r *EmailService) SendRaw(ctx context.Context, body EmailSendRawParams, opts ...option.RequestOption) (res *EmailSendRawResponse, err error)

Send a pre-formatted RFC 2822 MIME message. Use this for advanced use cases or when migrating from systems that generate raw email content.

The `data` field should contain the base64-encoded raw email.

type Error

type Error = apierror.Error

type SuppressionBulkNewParams

type SuppressionBulkNewParams struct {
	Suppressions []SuppressionBulkNewParamsSuppression `json:"suppressions,omitzero,required"`
	// contains filtered or unexported fields
}

func (SuppressionBulkNewParams) MarshalJSON

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

func (*SuppressionBulkNewParams) UnmarshalJSON

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

type SuppressionBulkNewParamsSuppression

type SuppressionBulkNewParamsSuppression struct {
	Address string `json:"address,required" format:"email"`
	// Reason for suppression (accepts null)
	Reason param.Opt[string] `json:"reason,omitzero"`
	// contains filtered or unexported fields
}

The property Address is required.

func (SuppressionBulkNewParamsSuppression) MarshalJSON

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

func (*SuppressionBulkNewParamsSuppression) UnmarshalJSON

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

type SuppressionBulkNewResponse

type SuppressionBulkNewResponse struct {
	Data    SuppressionBulkNewResponseData `json:"data,required"`
	Meta    shared.APIMeta                 `json:"meta,required"`
	Success bool                           `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionBulkNewResponse) RawJSON

func (r SuppressionBulkNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionBulkNewResponse) UnmarshalJSON

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

type SuppressionBulkNewResponseData

type SuppressionBulkNewResponseData struct {
	// Newly suppressed addresses
	Added int64 `json:"added,required"`
	// Invalid addresses skipped
	Failed int64 `json:"failed,required"`
	// Total addresses in request
	TotalRequested int64 `json:"totalRequested,required"`
	// Already suppressed addresses (updated reason)
	Updated int64 `json:"updated,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Added          respjson.Field
		Failed         respjson.Field
		TotalRequested respjson.Field
		Updated        respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionBulkNewResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*SuppressionBulkNewResponseData) UnmarshalJSON

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

type SuppressionDeleteResponse added in v0.3.0

type SuppressionDeleteResponse struct {
	Data    SuppressionDeleteResponseData `json:"data,required"`
	Meta    shared.APIMeta                `json:"meta,required"`
	Success bool                          `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionDeleteResponse) RawJSON added in v0.3.0

func (r SuppressionDeleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionDeleteResponse) UnmarshalJSON added in v0.3.0

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

type SuppressionDeleteResponseData added in v0.3.0

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

func (SuppressionDeleteResponseData) RawJSON added in v0.3.0

Returns the unmodified JSON received from the API

func (*SuppressionDeleteResponseData) UnmarshalJSON added in v0.3.0

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

type SuppressionGetResponse

type SuppressionGetResponse struct {
	Data    SuppressionGetResponseData `json:"data,required"`
	Meta    shared.APIMeta             `json:"meta,required"`
	Success bool                       `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionGetResponse) RawJSON

func (r SuppressionGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionGetResponse) UnmarshalJSON

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

type SuppressionGetResponseData

type SuppressionGetResponseData struct {
	// The email address that was checked
	Address string `json:"address,required" format:"email"`
	// Whether the address is currently suppressed
	Suppressed bool `json:"suppressed,required"`
	// When the suppression was created (if suppressed)
	CreatedAt time.Time `json:"createdAt,nullable" format:"date-time"`
	// Reason for suppression (if suppressed)
	Reason string `json:"reason,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Address     respjson.Field
		Suppressed  respjson.Field
		CreatedAt   respjson.Field
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionGetResponseData) RawJSON

func (r SuppressionGetResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionGetResponseData) UnmarshalJSON

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

type SuppressionListParams

type SuppressionListParams struct {
	Page    param.Opt[int64] `query:"page,omitzero" json:"-"`
	PerPage param.Opt[int64] `query:"perPage,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SuppressionListParams) URLQuery

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

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

type SuppressionListResponse

type SuppressionListResponse struct {
	// Suppression ID
	ID        string    `json:"id,required"`
	Address   string    `json:"address,required" format:"email"`
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	Reason    string    `json:"reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Address     respjson.Field
		CreatedAt   respjson.Field
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionListResponse) RawJSON

func (r SuppressionListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionListResponse) UnmarshalJSON

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

type SuppressionNewParams

type SuppressionNewParams struct {
	// Email address to suppress
	Address string `json:"address,required" format:"email"`
	// Reason for suppression (accepts null)
	Reason param.Opt[string] `json:"reason,omitzero"`
	// contains filtered or unexported fields
}

func (SuppressionNewParams) MarshalJSON

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

func (*SuppressionNewParams) UnmarshalJSON

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

type SuppressionNewResponse

type SuppressionNewResponse struct {
	Data    SuppressionNewResponseData `json:"data,required"`
	Meta    shared.APIMeta             `json:"meta,required"`
	Success bool                       `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionNewResponse) RawJSON

func (r SuppressionNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionNewResponse) UnmarshalJSON

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

type SuppressionNewResponseData

type SuppressionNewResponseData struct {
	// Suppression ID
	ID        string    `json:"id,required"`
	Address   string    `json:"address,required" format:"email"`
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	// Reason for suppression
	Reason string `json:"reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Address     respjson.Field
		CreatedAt   respjson.Field
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SuppressionNewResponseData) RawJSON

func (r SuppressionNewResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SuppressionNewResponseData) UnmarshalJSON

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

type SuppressionService

type SuppressionService struct {
	Options []option.RequestOption
}

SuppressionService contains methods and other services that help with interacting with the ark 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 NewSuppressionService method instead.

func NewSuppressionService

func NewSuppressionService(opts ...option.RequestOption) (r SuppressionService)

NewSuppressionService 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 (*SuppressionService) BulkNew

Add up to 1000 email addresses to the suppression list at once

func (*SuppressionService) Delete

func (r *SuppressionService) Delete(ctx context.Context, email string, opts ...option.RequestOption) (res *SuppressionDeleteResponse, err error)

Remove an email address from the suppression list. The address will be able to receive emails again.

func (*SuppressionService) Get

func (r *SuppressionService) Get(ctx context.Context, email string, opts ...option.RequestOption) (res *SuppressionGetResponse, err error)

Check if a specific email address is on the suppression list

func (*SuppressionService) List

Get all email addresses on the suppression list. These addresses will not receive any emails.

func (*SuppressionService) ListAutoPaging added in v0.4.0

Get all email addresses on the suppression list. These addresses will not receive any emails.

func (*SuppressionService) New

Add an email address to the suppression list. The address will not receive any emails until removed.

type TrackDomain

type TrackDomain struct {
	// Track domain ID
	ID string `json:"id,required"`
	// When the track domain was created
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	// Whether DNS is correctly configured
	DNSOk bool `json:"dnsOk,required"`
	// ID of the parent sending domain
	DomainID string `json:"domainId,required"`
	// Full domain name
	FullName string `json:"fullName,required"`
	// Subdomain name
	Name string `json:"name,required"`
	// Whether SSL is enabled for tracking URLs
	SslEnabled bool `json:"sslEnabled,required"`
	// Whether click tracking is enabled
	TrackClicks bool `json:"trackClicks,required"`
	// Whether open tracking is enabled
	TrackOpens bool `json:"trackOpens,required"`
	// When DNS was last checked
	DNSCheckedAt time.Time `json:"dnsCheckedAt,nullable" format:"date-time"`
	// DNS error message if verification failed
	DNSError string `json:"dnsError,nullable"`
	// Required DNS record configuration
	DNSRecord TrackDomainDNSRecord `json:"dnsRecord,nullable"`
	// Current DNS verification status
	//
	// Any of "ok", "missing", "invalid".
	DNSStatus TrackDomainDNSStatus `json:"dnsStatus,nullable"`
	// Domains excluded from click tracking
	ExcludedClickDomains string `json:"excludedClickDomains,nullable"`
	// When the track domain was last updated
	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
		DNSOk                respjson.Field
		DomainID             respjson.Field
		FullName             respjson.Field
		Name                 respjson.Field
		SslEnabled           respjson.Field
		TrackClicks          respjson.Field
		TrackOpens           respjson.Field
		DNSCheckedAt         respjson.Field
		DNSError             respjson.Field
		DNSRecord            respjson.Field
		DNSStatus            respjson.Field
		ExcludedClickDomains respjson.Field
		UpdatedAt            respjson.Field
		ExtraFields          map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackDomain) RawJSON

func (r TrackDomain) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackDomain) UnmarshalJSON

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

type TrackDomainDNSRecord

type TrackDomainDNSRecord struct {
	// DNS record name
	Name string `json:"name"`
	// DNS record type
	Type string `json:"type"`
	// DNS record value (target)
	Value string `json:"value"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Type        respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Required DNS record configuration

func (TrackDomainDNSRecord) RawJSON

func (r TrackDomainDNSRecord) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackDomainDNSRecord) UnmarshalJSON

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

type TrackDomainDNSStatus

type TrackDomainDNSStatus string

Current DNS verification status

const (
	TrackDomainDNSStatusOk      TrackDomainDNSStatus = "ok"
	TrackDomainDNSStatusMissing TrackDomainDNSStatus = "missing"
	TrackDomainDNSStatusInvalid TrackDomainDNSStatus = "invalid"
)

type TrackingDeleteResponse added in v0.3.0

type TrackingDeleteResponse struct {
	Data    TrackingDeleteResponseData `json:"data,required"`
	Meta    shared.APIMeta             `json:"meta,required"`
	Success bool                       `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingDeleteResponse) RawJSON added in v0.3.0

func (r TrackingDeleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingDeleteResponse) UnmarshalJSON added in v0.3.0

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

type TrackingDeleteResponseData added in v0.3.0

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

func (TrackingDeleteResponseData) RawJSON added in v0.3.0

func (r TrackingDeleteResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingDeleteResponseData) UnmarshalJSON added in v0.3.0

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

type TrackingGetResponse added in v0.3.0

type TrackingGetResponse struct {
	Data    TrackDomain    `json:"data,required"`
	Meta    shared.APIMeta `json:"meta,required"`
	Success bool           `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingGetResponse) RawJSON added in v0.3.0

func (r TrackingGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingGetResponse) UnmarshalJSON added in v0.3.0

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

type TrackingListResponse

type TrackingListResponse struct {
	Data    TrackingListResponseData `json:"data,required"`
	Meta    shared.APIMeta           `json:"meta,required"`
	Success bool                     `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingListResponse) RawJSON

func (r TrackingListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingListResponse) UnmarshalJSON

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

type TrackingListResponseData

type TrackingListResponseData struct {
	TrackDomains []TrackDomain `json:"trackDomains,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		TrackDomains respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingListResponseData) RawJSON

func (r TrackingListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingListResponseData) UnmarshalJSON

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

type TrackingNewParams

type TrackingNewParams struct {
	// ID of the sending domain to attach this track domain to
	DomainID int64 `json:"domainId,required"`
	// Subdomain name (e.g., 'track' for track.yourdomain.com)
	Name string `json:"name,required"`
	// Enable SSL for tracking URLs (accepts null, defaults to true)
	SslEnabled param.Opt[bool] `json:"sslEnabled,omitzero"`
	// Enable click tracking (accepts null, defaults to true)
	TrackClicks param.Opt[bool] `json:"trackClicks,omitzero"`
	// Enable open tracking (tracking pixel, accepts null, defaults to true)
	TrackOpens param.Opt[bool] `json:"trackOpens,omitzero"`
	// contains filtered or unexported fields
}

func (TrackingNewParams) MarshalJSON

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

func (*TrackingNewParams) UnmarshalJSON

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

type TrackingNewResponse added in v0.3.0

type TrackingNewResponse struct {
	Data    TrackDomain    `json:"data,required"`
	Meta    shared.APIMeta `json:"meta,required"`
	Success bool           `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingNewResponse) RawJSON added in v0.3.0

func (r TrackingNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingNewResponse) UnmarshalJSON added in v0.3.0

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

type TrackingService

type TrackingService struct {
	Options []option.RequestOption
}

TrackingService contains methods and other services that help with interacting with the ark 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 NewTrackingService method instead.

func NewTrackingService

func NewTrackingService(opts ...option.RequestOption) (r TrackingService)

NewTrackingService 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 (*TrackingService) Delete

func (r *TrackingService) Delete(ctx context.Context, trackingID string, opts ...option.RequestOption) (res *TrackingDeleteResponse, err error)

Delete a track domain. This will disable tracking for any emails using this domain.

func (*TrackingService) Get

func (r *TrackingService) Get(ctx context.Context, trackingID string, opts ...option.RequestOption) (res *TrackingGetResponse, err error)

Get details of a specific track domain including DNS configuration

func (*TrackingService) List

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

List all track domains configured for your server. Track domains enable open and click tracking for your emails.

func (*TrackingService) New

Create a new track domain for open/click tracking.

After creation, you must configure a CNAME record pointing to the provided DNS value before tracking will work.

func (*TrackingService) Update

func (r *TrackingService) Update(ctx context.Context, trackingID string, body TrackingUpdateParams, opts ...option.RequestOption) (res *TrackingUpdateResponse, err error)

Update track domain settings.

Use this to:

- Enable/disable click tracking - Enable/disable open tracking - Enable/disable SSL - Set excluded click domains

func (*TrackingService) Verify

func (r *TrackingService) Verify(ctx context.Context, trackingID string, opts ...option.RequestOption) (res *TrackingVerifyResponse, err error)

Check DNS configuration for the track domain.

The track domain requires a CNAME record to be configured before open and click tracking will work. Use this endpoint to verify the DNS is correctly set up.

type TrackingUpdateParams

type TrackingUpdateParams struct {
	// Comma-separated list of domains to exclude from click tracking (accepts null)
	ExcludedClickDomains param.Opt[string] `json:"excludedClickDomains,omitzero"`
	// Enable or disable SSL for tracking URLs (accepts null)
	SslEnabled param.Opt[bool] `json:"sslEnabled,omitzero"`
	// Enable or disable click tracking (accepts null)
	TrackClicks param.Opt[bool] `json:"trackClicks,omitzero"`
	// Enable or disable open tracking (accepts null)
	TrackOpens param.Opt[bool] `json:"trackOpens,omitzero"`
	// contains filtered or unexported fields
}

func (TrackingUpdateParams) MarshalJSON

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

func (*TrackingUpdateParams) UnmarshalJSON

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

type TrackingUpdateResponse added in v0.3.0

type TrackingUpdateResponse struct {
	Data    TrackDomain    `json:"data,required"`
	Meta    shared.APIMeta `json:"meta,required"`
	Success bool           `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingUpdateResponse) RawJSON added in v0.3.0

func (r TrackingUpdateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingUpdateResponse) UnmarshalJSON added in v0.3.0

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

type TrackingVerifyResponse

type TrackingVerifyResponse struct {
	Data    TrackingVerifyResponseData `json:"data,required"`
	Meta    shared.APIMeta             `json:"meta,required"`
	Success bool                       `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingVerifyResponse) RawJSON

func (r TrackingVerifyResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingVerifyResponse) UnmarshalJSON

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

type TrackingVerifyResponseData

type TrackingVerifyResponseData struct {
	// Track domain ID
	ID string `json:"id,required"`
	// Whether DNS is correctly configured
	DNSOk bool `json:"dnsOk,required"`
	// Current DNS verification status
	//
	// Any of "ok", "missing", "invalid".
	DNSStatus string `json:"dnsStatus,required"`
	// Full domain name
	FullName string `json:"fullName,required"`
	// When DNS was last checked
	DNSCheckedAt time.Time `json:"dnsCheckedAt,nullable" format:"date-time"`
	// DNS error message if verification failed
	DNSError string `json:"dnsError,nullable"`
	// Required DNS record configuration
	DNSRecord TrackingVerifyResponseDataDNSRecord `json:"dnsRecord,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		DNSOk        respjson.Field
		DNSStatus    respjson.Field
		FullName     respjson.Field
		DNSCheckedAt respjson.Field
		DNSError     respjson.Field
		DNSRecord    respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TrackingVerifyResponseData) RawJSON

func (r TrackingVerifyResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TrackingVerifyResponseData) UnmarshalJSON

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

type TrackingVerifyResponseDataDNSRecord

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

Required DNS record configuration

func (TrackingVerifyResponseDataDNSRecord) RawJSON

Returns the unmodified JSON received from the API

func (*TrackingVerifyResponseDataDNSRecord) UnmarshalJSON

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

type WebhookDeleteResponse added in v0.3.0

type WebhookDeleteResponse struct {
	Data    WebhookDeleteResponseData `json:"data,required"`
	Meta    shared.APIMeta            `json:"meta,required"`
	Success bool                      `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookDeleteResponse) RawJSON added in v0.3.0

func (r WebhookDeleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookDeleteResponse) UnmarshalJSON added in v0.3.0

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

type WebhookDeleteResponseData added in v0.3.0

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

func (WebhookDeleteResponseData) RawJSON added in v0.3.0

func (r WebhookDeleteResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookDeleteResponseData) UnmarshalJSON added in v0.3.0

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

type WebhookGetResponse added in v0.3.0

type WebhookGetResponse struct {
	Data    WebhookGetResponseData `json:"data,required"`
	Meta    shared.APIMeta         `json:"meta,required"`
	Success bool                   `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookGetResponse) RawJSON added in v0.3.0

func (r WebhookGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookGetResponse) UnmarshalJSON added in v0.3.0

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

type WebhookGetResponseData added in v0.3.0

type WebhookGetResponseData struct {
	// Webhook ID
	ID string `json:"id,required"`
	// Whether subscribed to all events
	AllEvents bool      `json:"allEvents,required"`
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	// Whether the webhook is active
	Enabled bool `json:"enabled,required"`
	// Subscribed events
	//
	// Any of "MessageSent", "MessageDelayed", "MessageDeliveryFailed", "MessageHeld",
	// "MessageBounced", "MessageLinkClicked", "MessageLoaded", "DomainDNSError".
	Events []string `json:"events,required"`
	// Webhook name for identification
	Name string `json:"name,required"`
	// Webhook endpoint URL
	URL  string `json:"url,required" format:"uri"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		AllEvents   respjson.Field
		CreatedAt   respjson.Field
		Enabled     respjson.Field
		Events      respjson.Field
		Name        respjson.Field
		URL         respjson.Field
		Uuid        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookGetResponseData) RawJSON added in v0.3.0

func (r WebhookGetResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookGetResponseData) UnmarshalJSON added in v0.3.0

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

type WebhookListResponse

type WebhookListResponse struct {
	Data    WebhookListResponseData `json:"data,required"`
	Meta    shared.APIMeta          `json:"meta,required"`
	Success bool                    `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListResponse) RawJSON

func (r WebhookListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListResponse) UnmarshalJSON

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

type WebhookListResponseData

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

func (WebhookListResponseData) RawJSON

func (r WebhookListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListResponseData) UnmarshalJSON

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

type WebhookListResponseDataWebhook

type WebhookListResponseDataWebhook struct {
	// Webhook ID
	ID      string   `json:"id,required"`
	Enabled bool     `json:"enabled,required"`
	Events  []string `json:"events,required"`
	Name    string   `json:"name,required"`
	URL     string   `json:"url,required" format:"uri"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Enabled     respjson.Field
		Events      respjson.Field
		Name        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListResponseDataWebhook) RawJSON

Returns the unmodified JSON received from the API

func (*WebhookListResponseDataWebhook) UnmarshalJSON

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

type WebhookNewParams

type WebhookNewParams struct {
	// Webhook name for identification
	Name string `json:"name,required"`
	// HTTPS endpoint URL
	URL string `json:"url,required" format:"uri"`
	// Subscribe to all events (ignores events array, accepts null)
	AllEvents param.Opt[bool] `json:"allEvents,omitzero"`
	// Whether the webhook is enabled (accepts null)
	Enabled param.Opt[bool] `json:"enabled,omitzero"`
	// Events to subscribe to (accepts null):
	//
	// - `MessageSent` - Email successfully delivered to recipient's server
	// - `MessageDelayed` - Temporary delivery failure, will retry
	// - `MessageDeliveryFailed` - Permanent delivery failure
	// - `MessageHeld` - Email held for manual review
	// - `MessageBounced` - Email bounced back
	// - `MessageLinkClicked` - Recipient clicked a tracked link
	// - `MessageLoaded` - Recipient opened the email (tracking pixel loaded)
	// - `DomainDNSError` - DNS configuration issue detected
	//
	// Any of "MessageSent", "MessageDelayed", "MessageDeliveryFailed", "MessageHeld",
	// "MessageBounced", "MessageLinkClicked", "MessageLoaded", "DomainDNSError".
	Events []string `json:"events,omitzero"`
	// contains filtered or unexported fields
}

func (WebhookNewParams) MarshalJSON

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

func (*WebhookNewParams) UnmarshalJSON

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

type WebhookNewResponse added in v0.3.0

type WebhookNewResponse struct {
	Data    WebhookNewResponseData `json:"data,required"`
	Meta    shared.APIMeta         `json:"meta,required"`
	Success bool                   `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookNewResponse) RawJSON added in v0.3.0

func (r WebhookNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookNewResponse) UnmarshalJSON added in v0.3.0

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

type WebhookNewResponseData added in v0.3.0

type WebhookNewResponseData struct {
	// Webhook ID
	ID string `json:"id,required"`
	// Whether subscribed to all events
	AllEvents bool      `json:"allEvents,required"`
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	// Whether the webhook is active
	Enabled bool `json:"enabled,required"`
	// Subscribed events
	//
	// Any of "MessageSent", "MessageDelayed", "MessageDeliveryFailed", "MessageHeld",
	// "MessageBounced", "MessageLinkClicked", "MessageLoaded", "DomainDNSError".
	Events []string `json:"events,required"`
	// Webhook name for identification
	Name string `json:"name,required"`
	// Webhook endpoint URL
	URL  string `json:"url,required" format:"uri"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		AllEvents   respjson.Field
		CreatedAt   respjson.Field
		Enabled     respjson.Field
		Events      respjson.Field
		Name        respjson.Field
		URL         respjson.Field
		Uuid        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookNewResponseData) RawJSON added in v0.3.0

func (r WebhookNewResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookNewResponseData) UnmarshalJSON added in v0.3.0

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

type WebhookService

type WebhookService struct {
	Options []option.RequestOption
}

WebhookService contains methods and other services that help with interacting with the ark 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

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

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

Delete a webhook

func (*WebhookService) Get

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

Get webhook details

func (*WebhookService) List

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

Get all configured webhook endpoints

func (*WebhookService) New

Create a webhook endpoint to receive email event notifications.

**Available events:**

- `MessageSent` - Email accepted by recipient server - `MessageDeliveryFailed` - Delivery permanently failed - `MessageDelayed` - Delivery temporarily failed, will retry - `MessageBounced` - Email bounced - `MessageHeld` - Email held for review - `MessageLinkClicked` - Recipient clicked a link - `MessageLoaded` - Recipient opened the email - `DomainDNSError` - Domain DNS issue detected

func (*WebhookService) Test

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

Send a test payload to your webhook endpoint and verify it receives the data correctly.

Use this to:

- Verify your webhook URL is accessible - Test your signature verification code - Ensure your server handles the payload format correctly

**Test payload format:** The test payload is identical to real webhook payloads, containing sample data for the specified event type. Your webhook should respond with a 2xx status code.

func (*WebhookService) Update

func (r *WebhookService) Update(ctx context.Context, webhookID string, body WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookUpdateResponse, err error)

Update a webhook

type WebhookTestParams

type WebhookTestParams struct {
	// Event type to simulate
	//
	// Any of "MessageSent", "MessageDelayed", "MessageDeliveryFailed", "MessageHeld",
	// "MessageBounced", "MessageLinkClicked", "MessageLoaded", "DomainDNSError".
	Event WebhookTestParamsEvent `json:"event,omitzero,required"`
	// contains filtered or unexported fields
}

func (WebhookTestParams) MarshalJSON

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

func (*WebhookTestParams) UnmarshalJSON

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

type WebhookTestParamsEvent

type WebhookTestParamsEvent string

Event type to simulate

const (
	WebhookTestParamsEventMessageSent           WebhookTestParamsEvent = "MessageSent"
	WebhookTestParamsEventMessageDelayed        WebhookTestParamsEvent = "MessageDelayed"
	WebhookTestParamsEventMessageDeliveryFailed WebhookTestParamsEvent = "MessageDeliveryFailed"
	WebhookTestParamsEventMessageHeld           WebhookTestParamsEvent = "MessageHeld"
	WebhookTestParamsEventMessageBounced        WebhookTestParamsEvent = "MessageBounced"
	WebhookTestParamsEventMessageLinkClicked    WebhookTestParamsEvent = "MessageLinkClicked"
	WebhookTestParamsEventMessageLoaded         WebhookTestParamsEvent = "MessageLoaded"
	WebhookTestParamsEventDomainDNSError        WebhookTestParamsEvent = "DomainDNSError"
)

type WebhookTestResponse

type WebhookTestResponse struct {
	Data    WebhookTestResponseData `json:"data,required"`
	Meta    shared.APIMeta          `json:"meta,required"`
	Success bool                    `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookTestResponse) RawJSON

func (r WebhookTestResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookTestResponse) UnmarshalJSON

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

type WebhookTestResponseData

type WebhookTestResponseData struct {
	// Request duration in milliseconds
	Duration int64 `json:"duration,required"`
	// Event type that was tested
	Event string `json:"event,required"`
	// HTTP status code from the webhook endpoint
	StatusCode int64 `json:"statusCode,required"`
	// Whether the webhook endpoint responded with a 2xx status
	Success bool `json:"success,required"`
	// Response body from the webhook endpoint (truncated if too long)
	Body string `json:"body,nullable"`
	// Error message if the request failed
	Error string `json:"error,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Duration    respjson.Field
		Event       respjson.Field
		StatusCode  respjson.Field
		Success     respjson.Field
		Body        respjson.Field
		Error       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookTestResponseData) RawJSON

func (r WebhookTestResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookTestResponseData) UnmarshalJSON

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

type WebhookUpdateParams

type WebhookUpdateParams struct {
	AllEvents param.Opt[bool]   `json:"allEvents,omitzero"`
	Enabled   param.Opt[bool]   `json:"enabled,omitzero"`
	Name      param.Opt[string] `json:"name,omitzero"`
	URL       param.Opt[string] `json:"url,omitzero" format:"uri"`
	Events    []string          `json:"events,omitzero"`
	// contains filtered or unexported fields
}

func (WebhookUpdateParams) MarshalJSON

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

func (*WebhookUpdateParams) UnmarshalJSON

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

type WebhookUpdateResponse added in v0.3.0

type WebhookUpdateResponse struct {
	Data    WebhookUpdateResponseData `json:"data,required"`
	Meta    shared.APIMeta            `json:"meta,required"`
	Success bool                      `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookUpdateResponse) RawJSON added in v0.3.0

func (r WebhookUpdateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookUpdateResponse) UnmarshalJSON added in v0.3.0

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

type WebhookUpdateResponseData added in v0.3.0

type WebhookUpdateResponseData struct {
	// Webhook ID
	ID string `json:"id,required"`
	// Whether subscribed to all events
	AllEvents bool      `json:"allEvents,required"`
	CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
	// Whether the webhook is active
	Enabled bool `json:"enabled,required"`
	// Subscribed events
	//
	// Any of "MessageSent", "MessageDelayed", "MessageDeliveryFailed", "MessageHeld",
	// "MessageBounced", "MessageLinkClicked", "MessageLoaded", "DomainDNSError".
	Events []string `json:"events,required"`
	// Webhook name for identification
	Name string `json:"name,required"`
	// Webhook endpoint URL
	URL  string `json:"url,required" format:"uri"`
	Uuid string `json:"uuid,required" format:"uuid"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		AllEvents   respjson.Field
		CreatedAt   respjson.Field
		Enabled     respjson.Field
		Events      respjson.Field
		Name        respjson.Field
		URL         respjson.Field
		Uuid        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookUpdateResponseData) RawJSON added in v0.3.0

func (r WebhookUpdateResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookUpdateResponseData) UnmarshalJSON added in v0.3.0

func (r *WebhookUpdateResponseData) 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

Jump to

Keyboard shortcuts

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