Documentation
¶
Overview ¶
Package axene is the official Go client for the Axene Mailer API.
Axene Mailer is an email marketing and transactional sending platform. This package wraps the REST API at https://mail.axene.io behind a small, typed client. Construct a client with an API key (it starts with axm_k_) and reach the API through resource fields:
client := axene.New("axm_k_...")
resp, err := client.Emails.Send(ctx, axene.SendEmail{
From: axene.Addr("hello@yourdomain.com"),
To: []axene.Address{axene.Addr("customer@example.com")},
Subject: "Your receipt",
HTML: "<p>Thanks for your order.</p>",
})
The client owns one transport layer (transport.go) that handles bearer authentication, JSON encoding, the from -> from_ wire mapping, retries on 429 and 5xx with backoff (honoring Retry-After), and error mapping to *Error. Resource types (Emails, Domains, Contacts, Suppressions, Templates, Webhooks) are thin and delegate to that transport. Every method takes a context.Context as its first argument.
Pagination is zero-based: page 0 is the first page. Most list endpoints return a bare slice; suppressions list and webhook deliveries return a Page[T] envelope.
Index ¶
- type AddContactParams
- type AddSuppressionParams
- type Address
- type Attachment
- type BatchResult
- type BulkSendParams
- type BulkSendResult
- type BulkSuppressionResult
- type Client
- type Contact
- type ContactList
- type ContactListDetail
- type Contacts
- func (c *Contacts) AddContact(ctx context.Context, listID string, params AddContactParams) (*Contact, error)
- func (c *Contacts) BulkSend(ctx context.Context, listID string, params BulkSendParams) (*BulkSendResult, error)
- func (c *Contacts) CreateList(ctx context.Context, params CreateListParams) (*ContactList, error)
- func (c *Contacts) DeleteList(ctx context.Context, id string) error
- func (c *Contacts) GetList(ctx context.Context, id string, params ListContactsParams) (*ContactListDetail, error)
- func (c *Contacts) ListLists(ctx context.Context) ([]ContactList, error)
- func (c *Contacts) RemoveContact(ctx context.Context, listID, contactID string) error
- func (c *Contacts) UpdateList(ctx context.Context, id string, params UpdateListParams) (*ContactList, error)
- func (c *Contacts) UploadCSV(ctx context.Context, listID string, file []byte, filename string) (*CsvImportResult, error)
- type CreateListParams
- type CreateTemplateParams
- type CreateWebhookParams
- type CsvImportResult
- type DkimRotation
- type DnsRecord
- type Domain
- type DomainAvailability
- type DomainCheck
- type DomainDiagnosis
- type DomainHealth
- type DomainHealthCheck
- type DomainHealthRecord
- type DomainHealthSummary
- type DomainListItem
- type DomainTransfer
- type Domains
- func (d *Domains) Check(ctx context.Context, name string) (*DomainCheck, error)
- func (d *Domains) CheckAvailability(ctx context.Context, name string) (*DomainAvailability, error)
- func (d *Domains) Create(ctx context.Context, name string) (*Domain, error)
- func (d *Domains) Delete(ctx context.Context, id string) error
- func (d *Domains) Diagnose(ctx context.Context, id string) (*DomainDiagnosis, error)
- func (d *Domains) Get(ctx context.Context, id string) (*Domain, error)
- func (d *Domains) Health(ctx context.Context, id string) (*DomainHealth, error)
- func (d *Domains) List(ctx context.Context) ([]DomainListItem, error)
- func (d *Domains) MxStatus(ctx context.Context, id string) (map[string]any, error)
- func (d *Domains) PublishedRecords(ctx context.Context, id string) (map[string]any, error)
- func (d *Domains) RotateDkim(ctx context.Context, id string) (*DkimRotation, error)
- func (d *Domains) Transfer(ctx context.Context, id string, params TransferParams) (*DomainTransfer, error)
- func (d *Domains) Verify(ctx context.Context, id string) (*Domain, error)
- type Email
- type EmailDetail
- type EmailEvent
- type EmailSearchHit
- type Emails
- func (e *Emails) CancelScheduled(ctx context.Context, id string) (*IDStatus, error)
- func (e *Emails) Events(ctx context.Context, id string) ([]EmailEvent, error)
- func (e *Emails) Get(ctx context.Context, id string) (*EmailDetail, error)
- func (e *Emails) GetSavedSearches(ctx context.Context) ([]SavedSearch, error)
- func (e *Emails) List(ctx context.Context, params ListEmailsParams) ([]Email, error)
- func (e *Emails) ListScheduled(ctx context.Context) ([]ScheduledEmail, error)
- func (e *Emails) Retry(ctx context.Context, id string) (*SendResult, error)
- func (e *Emails) Search(ctx context.Context, params SearchEmailsParams) ([]EmailSearchHit, error)
- func (e *Emails) Send(ctx context.Context, msg SendEmail) (*SendResult, error)
- func (e *Emails) SendBatch(ctx context.Context, msgs []SendEmail) (*BatchResult, error)
- func (e *Emails) SendScheduledNow(ctx context.Context, id string) (*IDStatus, error)
- func (e *Emails) SetSavedSearches(ctx context.Context, searches []SavedSearch) ([]SavedSearch, error)
- func (e *Emails) Updates(ctx context.Context, since string) ([]Email, error)
- func (e *Emails) Validate(ctx context.Context, msg SendEmail) (*ValidationResult, error)
- type Error
- type IDStatus
- type ListContactsParams
- type ListDeliveriesParams
- type ListEmailsParams
- type ListSuppressionsParams
- type Option
- type Page
- type SavedSearch
- type ScheduledEmail
- type SearchEmailsParams
- type SendEmail
- type SendResult
- type Suppression
- type Suppressions
- func (s *Suppressions) Add(ctx context.Context, params AddSuppressionParams) (*Suppression, error)
- func (s *Suppressions) BulkUpload(ctx context.Context, file []byte, filename string) (*BulkSuppressionResult, error)
- func (s *Suppressions) List(ctx context.Context, params ListSuppressionsParams) (*Page[Suppression], error)
- func (s *Suppressions) Remove(ctx context.Context, id string) error
- type Template
- type Templates
- func (t *Templates) Create(ctx context.Context, params CreateTemplateParams) (*Template, error)
- func (t *Templates) Delete(ctx context.Context, id string) error
- func (t *Templates) Duplicate(ctx context.Context, id string) (*Template, error)
- func (t *Templates) Get(ctx context.Context, id string) (*Template, error)
- func (t *Templates) List(ctx context.Context) ([]Template, error)
- func (t *Templates) Update(ctx context.Context, id string, params UpdateTemplateParams) (*Template, error)
- type TransferParams
- type UpdateListParams
- type UpdateTemplateParams
- type UpdateWebhookParams
- type ValidationIssue
- type ValidationResult
- type ValidationUsage
- type Webhook
- type WebhookDelivery
- type WebhookDeliveryDetail
- type WebhookTestResult
- type Webhooks
- func (w *Webhooks) Create(ctx context.Context, params CreateWebhookParams) (*Webhook, error)
- func (w *Webhooks) Delete(ctx context.Context, id string) error
- func (w *Webhooks) GetDelivery(ctx context.Context, id, deliveryID string) (*WebhookDeliveryDetail, error)
- func (w *Webhooks) List(ctx context.Context) ([]Webhook, error)
- func (w *Webhooks) ListDeliveries(ctx context.Context, id string, params ListDeliveriesParams) (*Page[WebhookDelivery], error)
- func (w *Webhooks) Test(ctx context.Context, id string) (*WebhookTestResult, error)
- func (w *Webhooks) Update(ctx context.Context, id string, params UpdateWebhookParams) (*Webhook, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddContactParams ¶
type AddContactParams struct {
Email string `json:"email"`
Name *string `json:"name,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
AddContactParams is the body for Contacts.AddContact.
type AddSuppressionParams ¶
type AddSuppressionParams struct {
Email string `json:"email_address"`
Reason string `json:"reason,omitempty"`
}
AddSuppressionParams is the body for Suppressions.Add. Email maps to the wire field email_address.
type Address ¶
Address is a recipient or sender. Email is required; Name is optional. Use Addr to build one from a bare email string.
type Attachment ¶
type Attachment struct {
Filename string `json:"filename"`
ContentBase64 string `json:"content_base64"`
ContentType string `json:"content_type,omitempty"`
}
Attachment is a file attached to an email. ContentBase64 is the raw base64 content with no "data:" prefix.
type BatchResult ¶
type BatchResult struct {
Total int `json:"total"`
Sent int `json:"sent"`
Failed int `json:"failed"`
Results []SendResult `json:"results"`
}
BatchResult is the result of Emails.SendBatch.
type BulkSendParams ¶
type BulkSendParams struct {
ContactListID string `json:"contact_list_id,omitempty"`
SenderAddressID string `json:"sender_address_id"`
Subject string `json:"subject"`
HTML string `json:"html,omitempty"`
Text string `json:"text,omitempty"`
Tags []string `json:"tags,omitempty"`
}
BulkSendParams is the body for Contacts.BulkSend. ContactListID is injected automatically from the list id by BulkSend, so callers leave it unset.
type BulkSendResult ¶
type BulkSendResult struct {
Queued int `json:"queued"`
Skipped int `json:"skipped"`
Errors []string `json:"errors"`
}
BulkSendResult is the result of Contacts.BulkSend.
type BulkSuppressionResult ¶
type BulkSuppressionResult struct {
Added int `json:"added"`
Skipped int `json:"skipped"`
TotalProcessed int `json:"total_processed"`
}
BulkSuppressionResult is the result of Suppressions.BulkUpload.
type Client ¶
type Client struct {
// Emails sends, searches, schedules, and inspects messages.
Emails *Emails
// Domains registers, verifies, and transfers sending domains.
Domains *Domains
// Contacts manages subscriber lists and bulk sends.
Contacts *Contacts
// Suppressions manages the do-not-send list.
Suppressions *Suppressions
// Templates manages reusable email templates.
Templates *Templates
// Webhooks manages event webhooks and inspects deliveries.
Webhooks *Webhooks
// contains filtered or unexported fields
}
Client is the Axene Mailer API client. Construct it with New and reach the API through its resource fields. Client is safe for concurrent use.
type Contact ¶
type Contact struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt string `json:"created_at"`
}
Contact is a single contact in a list.
type ContactList ¶
type ContactList struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
IconSeed string `json:"icon_seed,omitempty"`
ContactCount int `json:"contact_count"`
CreatedAt string `json:"created_at"`
}
ContactList is a subscriber list.
type ContactListDetail ¶
type ContactListDetail struct {
ContactList
Contacts []Contact `json:"contacts"`
}
ContactListDetail is a contact list with a page of its contacts.
type Contacts ¶
type Contacts struct {
// contains filtered or unexported fields
}
Contacts is the contacts resource, reached as client.Contacts.
func (*Contacts) AddContact ¶
func (c *Contacts) AddContact(ctx context.Context, listID string, params AddContactParams) (*Contact, error)
AddContact adds a single contact to a list.
func (*Contacts) BulkSend ¶
func (c *Contacts) BulkSend(ctx context.Context, listID string, params BulkSendParams) (*BulkSendResult, error)
BulkSend sends a templated email to every contact in a list. The list id is injected as contact_list_id automatically. Subject/HTML/Text may use {{email}}, {{name}}, and {{metadata_key}} placeholders.
func (*Contacts) CreateList ¶
func (c *Contacts) CreateList(ctx context.Context, params CreateListParams) (*ContactList, error)
CreateList creates a subscriber list.
func (*Contacts) DeleteList ¶
DeleteList deletes a list and all of its contacts.
func (*Contacts) GetList ¶
func (c *Contacts) GetList(ctx context.Context, id string, params ListContactsParams) (*ContactListDetail, error)
GetList gets a list with a page of its contacts (zero-based page).
func (*Contacts) ListLists ¶
func (c *Contacts) ListLists(ctx context.Context) ([]ContactList, error)
ListLists returns all subscriber lists in the active workspace.
func (*Contacts) RemoveContact ¶
RemoveContact removes a contact from a list.
func (*Contacts) UpdateList ¶
func (c *Contacts) UpdateList(ctx context.Context, id string, params UpdateListParams) (*ContactList, error)
UpdateList updates a list's name, description, or icon (partial).
type CreateListParams ¶
type CreateListParams struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
IconSeed *string `json:"icon_seed,omitempty"`
}
CreateListParams is the body for Contacts.CreateList. IconSeed maps to the wire field icon_seed. Use pointers so unset fields are omitted.
type CreateTemplateParams ¶
type CreateTemplateParams struct {
Name string `json:"name"`
Subject *string `json:"subject,omitempty"`
HTML *string `json:"html_body,omitempty"`
Text *string `json:"text_body,omitempty"`
BlocksJSON map[string]any `json:"blocks_json,omitempty"`
}
CreateTemplateParams is the body for Templates.Create. HTML maps to html_body and Text maps to text_body.
type CreateWebhookParams ¶
CreateWebhookParams is the body for Webhooks.Create.
type CsvImportResult ¶
type CsvImportResult struct {
Imported int `json:"imported"`
Skipped int `json:"skipped"`
Errors []string `json:"errors"`
}
CsvImportResult is the result of Contacts.UploadCSV.
type DkimRotation ¶
type DkimRotation struct {
DkimRecordHost string `json:"dkim_record_host"`
DkimRecordValue string `json:"dkim_record_value"`
Domain Domain `json:"domain"`
}
DkimRotation is the result of Domains.RotateDkim: the new record and domain.
type DnsRecord ¶
type DnsRecord struct {
ID string `json:"id"`
RecordType string `json:"record_type"`
Purpose string `json:"purpose"`
Host string `json:"host"`
Value string `json:"value"`
IsVerified bool `json:"is_verified"`
LastCheckedAt string `json:"last_checked_at,omitempty"`
}
DnsRecord is a DNS record the API expects you to publish for a domain.
type Domain ¶
type Domain struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
DkimSelector string `json:"dkim_selector"`
VerifiedAt string `json:"verified_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
DnsRecords []DnsRecord `json:"dns_records"`
PlatformWarning string `json:"platform_warning,omitempty"`
}
Domain is a sending domain with its DKIM selector and DNS records.
type DomainAvailability ¶
type DomainAvailability struct {
Available bool `json:"available"`
Reason string `json:"reason,omitempty"`
Detail string `json:"detail,omitempty"`
StaleTokens *int `json:"stale_tokens,omitempty"`
}
DomainAvailability is the result of Domains.CheckAvailability.
type DomainCheck ¶
type DomainCheck struct {
Exists bool `json:"exists"`
Verified bool `json:"verified"`
Status string `json:"status,omitempty"`
Domain string `json:"domain"`
ID string `json:"id,omitempty"`
}
DomainCheck is the result of Domains.Check.
type DomainDiagnosis ¶
type DomainDiagnosis struct {
Domain string `json:"domain"`
Issues []map[string]any `json:"issues"`
HealthScore int `json:"health_score"`
}
DomainDiagnosis is the result of Domains.Diagnose. Issue shapes vary.
type DomainHealth ¶
type DomainHealth struct {
Domain string `json:"domain"`
Checks []DomainHealthCheck `json:"checks"`
Summary DomainHealthSummary `json:"summary"`
}
DomainHealth is the result of Domains.Health.
type DomainHealthCheck ¶
type DomainHealthCheck struct {
Key string `json:"key"`
Label string `json:"label"`
Status string `json:"status"`
Detail string `json:"detail"`
Recommendation string `json:"recommendation,omitempty"`
Record *DomainHealthRecord `json:"record,omitempty"`
}
DomainHealthCheck is one row of a domain health report.
type DomainHealthRecord ¶
type DomainHealthRecord struct {
Type string `json:"type"`
Host string `json:"host"`
Value string `json:"value"`
}
DomainHealthRecord is the optional DNS record on a health check row.
type DomainHealthSummary ¶
type DomainHealthSummary struct {
OK int `json:"ok"`
Warn int `json:"warn"`
Error int `json:"error"`
Info int `json:"info"`
}
DomainHealthSummary is the tally of check statuses in a health report.
type DomainListItem ¶
type DomainListItem struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
CreatedAt string `json:"created_at,omitempty"`
PlatformWarning string `json:"platform_warning,omitempty"`
}
DomainListItem is a row from Domains.List.
type DomainTransfer ¶
type DomainTransfer struct {
ID string `json:"id"`
DomainID string `json:"domain_id"`
DomainName string `json:"domain_name,omitempty"`
SourceUserID string `json:"source_user_id,omitempty"`
SourceOrgID string `json:"source_org_id,omitempty"`
SourceLabel string `json:"source_label,omitempty"`
TargetEmail string `json:"target_email"`
TargetUserID string `json:"target_user_id,omitempty"`
TargetOrgID string `json:"target_org_id,omitempty"`
Status string `json:"status"`
Note string `json:"note,omitempty"`
CooloffUntil string `json:"cooloff_until,omitempty"`
InitiatedAt string `json:"initiated_at"`
AcceptedAt string `json:"accepted_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
ExpiresAt string `json:"expires_at"`
}
DomainTransfer is a domain transfer record returned by Domains.Transfer.
type Domains ¶
type Domains struct {
// contains filtered or unexported fields
}
Domains is the domains resource, reached as client.Domains.
func (*Domains) CheckAvailability ¶
CheckAvailability checks whether a domain name is available to add.
func (*Domains) Create ¶
Create registers a new sending domain and returns the DNS records to publish.
func (*Domains) List ¶
func (d *Domains) List(ctx context.Context) ([]DomainListItem, error)
List returns your sending domains and their verification status.
func (*Domains) PublishedRecords ¶
PublishedRecords returns the values currently published in DNS for each of the domain's records (an open map).
func (*Domains) RotateDkim ¶
RotateDkim rotates the domain's DKIM key, returning the new record to publish.
func (*Domains) Transfer ¶
func (d *Domains) Transfer(ctx context.Context, id string, params TransferParams) (*DomainTransfer, error)
Transfer initiates a transfer of this domain to another Axene account.
type Email ¶
type Email struct {
ID string `json:"id"`
FromAddress string `json:"from_address"`
ToAddresses []string `json:"to_addresses"`
Subject string `json:"subject,omitempty"`
Status string `json:"status"`
Source string `json:"source,omitempty"`
OpenedCount int `json:"opened_count"`
ClickedCount int `json:"clicked_count"`
Tags []string `json:"tags,omitempty"`
ScheduledAt string `json:"scheduled_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
SentAt string `json:"sent_at,omitempty"`
DeliveredAt string `json:"delivered_at,omitempty"`
RetryOfID string `json:"retry_of_id,omitempty"`
}
Email is a stored email and its current status.
type EmailDetail ¶
type EmailDetail struct {
Email
CCAddresses []string `json:"cc_addresses,omitempty"`
BCCAddresses []string `json:"bcc_addresses,omitempty"`
TextBody string `json:"text_body,omitempty"`
HTMLBody string `json:"html_body,omitempty"`
Headers map[string]any `json:"headers,omitempty"`
MessageID string `json:"message_id,omitempty"`
Events []EmailEvent `json:"events"`
}
EmailDetail is a stored email with its bodies and events, from Emails.Get.
type EmailEvent ¶
type EmailEvent struct {
ID string `json:"id"`
EventType string `json:"event_type"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt string `json:"created_at"`
}
EmailEvent is a delivery, open, click, or bounce event for a message.
type EmailSearchHit ¶
type EmailSearchHit struct {
ID string `json:"id"`
FromAddress string `json:"from_address"`
ToAddresses []string `json:"to_addresses"`
Subject string `json:"subject,omitempty"`
Status string `json:"status"`
Tags []string `json:"tags,omitempty"`
Source string `json:"source,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
DeliveredAt string `json:"delivered_at,omitempty"`
}
EmailSearchHit is a search result row from Emails.Search.
type Emails ¶
type Emails struct {
// contains filtered or unexported fields
}
Emails is the emails resource, reached as client.Emails.
func (*Emails) CancelScheduled ¶
CancelScheduled cancels a scheduled email.
func (*Emails) GetSavedSearches ¶
func (e *Emails) GetSavedSearches(ctx context.Context) ([]SavedSearch, error)
GetSavedSearches returns the caller's saved email searches.
func (*Emails) ListScheduled ¶
func (e *Emails) ListScheduled(ctx context.Context) ([]ScheduledEmail, error)
ListScheduled lists emails scheduled for future delivery, soonest first.
func (*Emails) Search ¶
func (e *Emails) Search(ctx context.Context, params SearchEmailsParams) ([]EmailSearchHit, error)
Search searches emails. q supports inline tokens (to:, from:, status:, domain:, tag:); leftover words are matched as free text.
func (*Emails) SendBatch ¶
SendBatch sends up to the plan's batch limit in one call. The API accepts a bare array of messages and returns a per-message result set.
func (*Emails) SendScheduledNow ¶
SendScheduledNow sends a scheduled email immediately instead of waiting.
func (*Emails) SetSavedSearches ¶
func (e *Emails) SetSavedSearches(ctx context.Context, searches []SavedSearch) ([]SavedSearch, error)
SetSavedSearches replaces the caller's saved email searches (max 50).
type Error ¶
type Error struct {
// Status is the HTTP status code. 0 indicates a transport or network
// failure where no response was received.
Status int
// Code is the machine-readable error code from the API body, when present.
Code string
// Message is a human-readable description of the failure.
Message string
}
Error is raised for any non-2xx API response, or for a transport failure that survives all retries. Inspect Status and Code to branch on specific failures (for example a 422 with code "invalid").
type ListContactsParams ¶
ListContactsParams are the query parameters for Contacts.GetList.
type ListDeliveriesParams ¶
ListDeliveriesParams are the query parameters for Webhooks.ListDeliveries.
type ListEmailsParams ¶
ListEmailsParams are the query parameters for Emails.List.
type ListSuppressionsParams ¶
ListSuppressionsParams are the query parameters for Suppressions.List.
type Option ¶
type Option func(*transport)
Option configures a Client. Pass options to New.
func WithBaseURL ¶
WithBaseURL overrides the API base URL (default https://mail.axene.io).
func WithHTTPClient ¶
WithHTTPClient injects a custom *http.Client (for testing or proxies).
func WithMaxRetries ¶
WithMaxRetries sets the total number of attempts on 429/5xx, including the first (default 3).
func WithTimeout ¶
WithTimeout sets the per-request timeout (default 30s).
type Page ¶
type Page[T any] struct { Items []T `json:"items"` Total int `json:"total"` Page int `json:"page"` Limit int `json:"limit"` }
Page is the envelope returned by endpoints that paginate with a total count: suppressions list and webhook deliveries.
type SavedSearch ¶
type SavedSearch struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Query string `json:"query,omitempty"`
Range string `json:"range,omitempty"`
Status string `json:"status,omitempty"`
Domain string `json:"domain,omitempty"`
Source string `json:"source,omitempty"`
}
SavedSearch is one stored email search. The server normalizes its fields.
type ScheduledEmail ¶
type ScheduledEmail struct {
ID string `json:"id"`
FromAddress string `json:"from_address"`
ToAddresses []string `json:"to_addresses"`
Subject string `json:"subject,omitempty"`
Status string `json:"status"`
Tags []string `json:"tags,omitempty"`
ScheduledAt string `json:"scheduled_at,omitempty"`
SecondsUntilSend int `json:"seconds_until_send"`
CreatedAt string `json:"created_at,omitempty"`
}
ScheduledEmail is an email awaiting future delivery.
type SearchEmailsParams ¶
SearchEmailsParams are the query parameters for Emails.Search.
type SendEmail ¶
type SendEmail struct {
// From is the sender address. It must be on a verified domain.
From Address `json:"from_"`
// To is one or more recipients.
To []Address `json:"to"`
// Subject is the email subject line.
Subject string `json:"subject"`
// HTML is the HTML body. Provide HTML, Text, or both.
HTML string `json:"html,omitempty"`
// Text is the plain-text body. Provide HTML, Text, or both.
Text string `json:"text,omitempty"`
// CC is an optional list of carbon-copy recipients.
CC []Address `json:"cc,omitempty"`
// BCC is an optional list of blind-carbon-copy recipients.
BCC []Address `json:"bcc,omitempty"`
// ReplyTo overrides the reply-to address.
ReplyTo *Address `json:"reply_to,omitempty"`
// Headers are custom headers to attach to the message.
Headers map[string]string `json:"headers,omitempty"`
// Tags label the message for filtering and analytics.
Tags []string `json:"tags,omitempty"`
// SendAt schedules delivery for later (ISO 8601). Starter plan and up.
SendAt string `json:"send_at,omitempty"`
// Attachments are files to attach to the message.
Attachments []Attachment `json:"attachments,omitempty"`
}
SendEmail is the body for Emails.Send, Emails.SendBatch, and Emails.Validate. The From field serializes to the wire key "from_" (trailing underscore).
type SendResult ¶
type SendResult struct {
ID string `json:"id"`
Status string `json:"status"`
MessageID string `json:"message_id,omitempty"`
RejectionReason string `json:"rejection_reason,omitempty"`
}
SendResult is the result of a send: the queued message id and its status.
type Suppression ¶
type Suppression struct {
ID string `json:"id"`
EmailAddress string `json:"email_address"`
Reason string `json:"reason"`
CreatedAt string `json:"created_at,omitempty"`
}
Suppression is a suppressed recipient address.
type Suppressions ¶
type Suppressions struct {
// contains filtered or unexported fields
}
Suppressions is the suppressions resource, reached as client.Suppressions.
func (*Suppressions) Add ¶
func (s *Suppressions) Add(ctx context.Context, params AddSuppressionParams) (*Suppression, error)
Add suppresses a single address. Reason defaults to "manual" when empty.
func (*Suppressions) BulkUpload ¶
func (s *Suppressions) BulkUpload(ctx context.Context, file []byte, filename string) (*BulkSuppressionResult, error)
BulkUpload imports suppressions from a file (one email per line). The upload is sent as multipart/form-data under the field name "file".
func (*Suppressions) List ¶
func (s *Suppressions) List(ctx context.Context, params ListSuppressionsParams) (*Page[Suppression], error)
List returns suppressed addresses as a paginated envelope (zero-based page).
type Template ¶
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
Subject string `json:"subject,omitempty"`
HTMLBody string `json:"html_body,omitempty"`
TextBody string `json:"text_body,omitempty"`
Variables []string `json:"variables,omitempty"`
BlocksJSON map[string]any `json:"blocks_json,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Template is a reusable email template. Variables is derived server-side and is read-only.
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates is the templates resource, reached as client.Templates. Templates are available on the Starter plan and up.
func (*Templates) Create ¶
Create creates a template. Variables are derived server-side from {{name}} placeholders, so you do not pass them.
func (*Templates) Duplicate ¶
Duplicate duplicates a template. The copy's blocks_json is not carried over.
type TransferParams ¶
type TransferParams struct {
TargetEmail string `json:"target_email"`
Note string `json:"note,omitempty"`
}
TransferParams is the body for Domains.Transfer.
type UpdateListParams ¶
type UpdateListParams struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
IconSeed *string `json:"icon_seed,omitempty"`
}
UpdateListParams is the partial body for Contacts.UpdateList.
type UpdateTemplateParams ¶
type UpdateTemplateParams struct {
Name *string `json:"name,omitempty"`
Subject *string `json:"subject,omitempty"`
HTML *string `json:"html_body,omitempty"`
Text *string `json:"text_body,omitempty"`
BlocksJSON map[string]any `json:"blocks_json,omitempty"`
}
UpdateTemplateParams is the partial body for Templates.Update.
type UpdateWebhookParams ¶
type UpdateWebhookParams struct {
URL *string `json:"url,omitempty"`
Events []string `json:"events,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
UpdateWebhookParams is the partial body for Webhooks.Update. IsActive maps to the wire field is_active.
type ValidationIssue ¶
ValidationIssue is a single reason a message would not send.
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
CanSend bool `json:"can_send"`
Issues []ValidationIssue `json:"issues"`
Plan string `json:"plan"`
Usage ValidationUsage `json:"usage"`
}
ValidationResult is the result of Emails.Validate, a dry-run that never sends.
type ValidationUsage ¶
type ValidationUsage struct {
Daily int `json:"daily"`
DailyLimit int `json:"daily_limit"`
Monthly int `json:"monthly"`
MonthlyLimit int `json:"monthly_limit"`
}
ValidationUsage is the sending-quota usage returned alongside a validation.
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
URL string `json:"url"`
Events []string `json:"events"`
Secret string `json:"secret"`
IsActive bool `json:"is_active"`
CreatedAt string `json:"created_at"`
}
Webhook is a configured webhook endpoint. Secret is returned in plaintext.
type WebhookDelivery ¶
type WebhookDelivery struct {
ID string `json:"id"`
WebhookID string `json:"webhook_id"`
EventType string `json:"event_type,omitempty"`
Status string `json:"status"`
ResponseStatus *int `json:"response_status,omitempty"`
Attempt int `json:"attempt"`
NextRetryAt string `json:"next_retry_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
WebhookDelivery is a summary of one webhook delivery attempt.
type WebhookDeliveryDetail ¶
type WebhookDeliveryDetail struct {
WebhookDelivery
Payload map[string]any `json:"payload"`
ResponseBody string `json:"response_body,omitempty"`
EndpointURL string `json:"endpoint_url"`
}
WebhookDeliveryDetail is a delivery with the full payload and endpoint response.
type WebhookTestResult ¶
WebhookTestResult is the result of Webhooks.Test.
type Webhooks ¶
type Webhooks struct {
// contains filtered or unexported fields
}
Webhooks is the webhooks resource, reached as client.Webhooks.
func (*Webhooks) GetDelivery ¶
func (w *Webhooks) GetDelivery(ctx context.Context, id, deliveryID string) (*WebhookDeliveryDetail, error)
GetDelivery fetches one delivery with its full payload and endpoint response.
func (*Webhooks) ListDeliveries ¶
func (w *Webhooks) ListDeliveries(ctx context.Context, id string, params ListDeliveriesParams) (*Page[WebhookDelivery], error)
ListDeliveries lists delivery attempts for a webhook as a paginated envelope.