sendry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package sendry provides a Go client for the Sendry email API.

See https://api.sendry.online for the API reference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr is a helper that returns a pointer to a bool literal.

func IntPtr

func IntPtr(n int) *int

IntPtr is a helper that returns a pointer to an int literal.

func StringPtr

func StringPtr(s string) *string

StringPtr is a helper that returns a pointer to a string literal.

func VerifyWebhookSignature

func VerifyWebhookSignature(payload, signature, secret string) bool

VerifyWebhookSignature verifies the HMAC-SHA256 signature of a webhook payload.

The signature header format is: "t=<unix_timestamp>,v1=<hex_digest>"

This function parses the header, recomputes the HMAC over "<timestamp>.<payload>" using the provided secret, and performs a constant-time comparison to prevent timing attacks.

Returns true if the signature is valid, false otherwise.

Example:

valid := sendry.VerifyWebhookSignature(
    string(body),
    r.Header.Get("Sendry-Signature"),
    "whsec_your_signing_secret",
)
if !valid {
    http.Error(w, "invalid signature", http.StatusUnauthorized)
    return
}

Types

type ABSplitStepConfig added in v0.2.0

type ABSplitStepConfig struct {
	A    int    `json:"a"`
	B    int    `json:"b"`
	Seed string `json:"seed,omitempty"`
}

ABSplitStepConfig builds a map[string]any config for an A/B split step.

func (ABSplitStepConfig) ToConfig added in v0.2.0

func (s ABSplitStepConfig) ToConfig() map[string]any

ToConfig converts the typed step config to a generic map.

type APIError

type APIError struct {
	// StatusCode is the HTTP status code returned by the API.
	StatusCode int
	// Code is the machine-readable error code (e.g. "rate_limit_error").
	Code string
	// Message is the human-readable error description.
	Message string
}

APIError is the base error type for all API errors returned by the Sendry API. It implements the error interface and includes the HTTP status code, error code, and human-readable message from the API response.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

type APIKey

type APIKey struct {
	ID         string  `json:"id"`
	Name       string  `json:"name"`
	Scope      string  `json:"scope"`
	KeyPrefix  string  `json:"key_prefix"`
	LastUsedAt *string `json:"last_used_at"`
	CreatedAt  string  `json:"created_at"`
}

APIKey represents an existing API key (key value is masked).

type APIKeyCreated

type APIKeyCreated struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Scope     string `json:"scope"`
	Key       string `json:"key"`
	CreatedAt string `json:"created_at"`
}

APIKeyCreated is returned immediately after creating a new API key. The Key field contains the full key and is only shown once.

type APIKeyScope

type APIKeyScope string

APIKeyScope represents the permission level of an API key.

const (
	APIKeyScopeFullAccess    APIKeyScope = "full_access"
	APIKeyScopeSendingAccess APIKeyScope = "sending_access"
	APIKeyScopeReadOnly      APIKeyScope = "read_only"
)

type APIKeysResource

type APIKeysResource struct {
	// contains filtered or unexported fields
}

APIKeysResource provides methods for managing API keys.

func (*APIKeysResource) Create

Create creates a new API key. The full key value is only returned once in the response — store it securely.

Example:

created, err := client.APIKeys.Create(ctx, sendry.CreateAPIKeyParams{
    Name:  "Production Key",
    Scope: sendry.APIKeyScopeSendingAccess,
})
// Store created.Key securely — it cannot be retrieved again.

func (*APIKeysResource) List

List returns all API keys. The key values are masked; only the prefix is shown.

Example:

page, err := client.APIKeys.List(ctx, nil)

func (*APIKeysResource) Remove

func (r *APIKeysResource) Remove(ctx context.Context, id string) (*DeleteResponse, error)

Remove revokes (deletes) an API key.

Example:

_, err := client.APIKeys.Remove(ctx, "key_abc123")

type AddAutomationStepParams added in v0.2.0

type AddAutomationStepParams struct {
	ParentStepID *string        `json:"parent_step_id,omitempty"`
	BranchLabel  *string        `json:"branch_label,omitempty"`
	Position     *int           `json:"position,omitempty"`
	Config       map[string]any `json:"config"`
}

AddAutomationStepParams are the parameters for adding a step to an automation.

type AddContactsToAudienceParams

type AddContactsToAudienceParams struct {
	ContactIDs []string `json:"contact_ids"`
}

AddContactsToAudienceParams are the parameters for adding contacts to an audience.

type AddContactsToAudienceResult

type AddContactsToAudienceResult struct {
	Added int `json:"added"`
}

AddContactsToAudienceResult is returned after adding contacts to an audience.

type AddSuppressionParams

type AddSuppressionParams struct {
	Email  string            `json:"email"`
	Reason SuppressionReason `json:"reason,omitempty"`
}

AddSuppressionParams are the parameters for adding an address to the suppression list.

type AffectedComponent added in v0.2.0

type AffectedComponent struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

AffectedComponent identifies a component affected by an incident.

type AnalyticsBucket

type AnalyticsBucket struct {
	Date       string `json:"date"`
	Sent       int    `json:"sent"`
	Delivered  int    `json:"delivered"`
	Opened     int    `json:"opened"`
	Clicked    int    `json:"clicked"`
	Bounced    int    `json:"bounced"`
	Complained int    `json:"complained"`
}

AnalyticsBucket holds aggregated metrics for a single time bucket.

type AnalyticsParams

type AnalyticsParams struct {
	From        string `json:"from"`
	To          string `json:"to"`
	Granularity string `json:"granularity,omitempty"` // "hour" | "day" | "week" | "month"
	Tag         string `json:"tag,omitempty"`
	Domain      string `json:"domain,omitempty"`
}

AnalyticsParams are the query parameters for fetching analytics.

type AnalyticsResource

type AnalyticsResource struct {
	// contains filtered or unexported fields
}

AnalyticsResource provides methods for fetching email analytics and event logs.

func (*AnalyticsResource) ExportData

func (r *AnalyticsResource) ExportData(ctx context.Context, params ExportParams) (any, error)

ExportData exports analytics data as CSV or JSON. The returned string is raw CSV or JSON depending on the params.Format field.

Example:

data, err := client.Analytics.ExportData(ctx, sendry.ExportParams{
    From:   "2025-01-01",
    To:     "2025-01-31",
    Format: "csv",
})

func (*AnalyticsResource) GetBenchmarks

func (r *AnalyticsResource) GetBenchmarks(ctx context.Context, params BenchmarkParams) (*BenchmarkResponse, error)

GetBenchmarks returns cross-organisation benchmark comparisons.

Example:

benchmarks, err := client.Analytics.GetBenchmarks(ctx, sendry.BenchmarkParams{
    From: "2025-01-01",
    To:   "2025-01-31",
})

func (*AnalyticsResource) GetBreakdowns

func (r *AnalyticsResource) GetBreakdowns(ctx context.Context, params BreakdownParams) (*BreakdownResponse, error)

GetBreakdowns returns analytics broken down by domain or template.

Example:

result, err := client.Analytics.GetBreakdowns(ctx, sendry.BreakdownParams{
    From:    "2025-01-01",
    To:      "2025-01-31",
    GroupBy: "domain",
})

func (*AnalyticsResource) GetCohorts

func (r *AnalyticsResource) GetCohorts(ctx context.Context, params CohortParams) (*CohortResponse, error)

GetCohorts returns cohort analysis data showing engagement decay over time.

Example:

cohorts, err := client.Analytics.GetCohorts(ctx, sendry.CohortParams{
    From:   "2025-01-01",
    To:     "2025-01-31",
    Metric: "open_rate",
})

func (*AnalyticsResource) GetComparison

func (r *AnalyticsResource) GetComparison(ctx context.Context, params AnalyticsParams) (*ComparisonResponse, error)

GetComparison compares current period metrics against the equivalent previous period.

Example:

comparison, err := client.Analytics.GetComparison(ctx, sendry.AnalyticsParams{
    From: "2025-01-01",
    To:   "2025-01-31",
})
fmt.Println(comparison.Changes.OpenRateDelta)

func (*AnalyticsResource) Logs

Logs returns a cursor-paginated list of email tracking events.

Example:

logs, err := client.Analytics.Logs(ctx, &sendry.LogsParams{
    EmailID: "em_abc123",
    Type:    "delivered",
})

func (*AnalyticsResource) Stats

Stats returns aggregated email analytics including a summary and timeseries breakdown.

Example:

stats, err := client.Analytics.Stats(ctx, sendry.AnalyticsParams{
    From:        "2025-01-01",
    To:          "2025-01-31",
    Granularity: "day",
})
fmt.Println(stats.Summary.DeliveryRate)

func (*AnalyticsResource) ToggleBenchmarkOptIn

func (r *AnalyticsResource) ToggleBenchmarkOptIn(ctx context.Context, optIn bool) error

ToggleBenchmarkOptIn opts the organisation in or out of anonymous benchmark data sharing.

Example:

err := client.Analytics.ToggleBenchmarkOptIn(ctx, true)

type AnalyticsResponse

type AnalyticsResponse struct {
	Summary    AnalyticsSummary  `json:"summary"`
	Timeseries []AnalyticsBucket `json:"timeseries"`
}

AnalyticsResponse is returned by the analytics stats endpoint.

type AnalyticsSummary

type AnalyticsSummary struct {
	Sent          int     `json:"sent"`
	Delivered     int     `json:"delivered"`
	Opened        int     `json:"opened"`
	Clicked       int     `json:"clicked"`
	Bounced       int     `json:"bounced"`
	Complained    int     `json:"complained"`
	DeliveryRate  float64 `json:"delivery_rate"`
	OpenRate      float64 `json:"open_rate"`
	ClickRate     float64 `json:"click_rate"`
	BounceRate    float64 `json:"bounce_rate"`
	ComplaintRate float64 `json:"complaint_rate"`
}

AnalyticsSummary holds aggregate totals and rates across all time buckets.

type AssignIpParams added in v0.2.0

type AssignIpParams struct {
	DomainID string `json:"domain_id"`
}

AssignIpParams are the parameters for assigning a dedicated IP to a domain.

type Attachment

type Attachment struct {
	// Filename is the file name including extension (e.g. "report.pdf").
	Filename string `json:"filename"`
	// Content is the base64-encoded file content.
	Content string `json:"content"`
	// ContentType is the MIME type. Defaults to application/octet-stream.
	ContentType string `json:"content_type,omitempty"`
}

Attachment represents a file attachment to include in an email.

type Audience

type Audience struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	MemberCount int     `json:"member_count"`
	CreatedAt   string  `json:"created_at"`
	UpdatedAt   string  `json:"updated_at"`
}

Audience represents a contact list (audience) in Sendry.

type AudiencesResource

type AudiencesResource struct {
	// contains filtered or unexported fields
}

AudiencesResource provides methods for managing audiences (contact lists).

func (*AudiencesResource) AddContacts

AddContacts adds one or more contacts to an audience by their IDs (max 100 per call).

Example:

result, err := client.Audiences.AddContacts(ctx, "aud_abc123", sendry.AddContactsToAudienceParams{
    ContactIDs: []string{"ct_1", "ct_2"},
})
fmt.Println(result.Added)

func (*AudiencesResource) Create

Create creates a new audience.

Example:

audience, err := client.Audiences.Create(ctx, sendry.CreateAudienceParams{
    Name:        "Newsletter Subscribers",
    Description: "Weekly newsletter list",
})

func (*AudiencesResource) Get

func (r *AudiencesResource) Get(ctx context.Context, id string) (*Audience, error)

Get retrieves an audience by its ID.

Example:

audience, err := client.Audiences.Get(ctx, "aud_abc123")
fmt.Println(audience.MemberCount)

func (*AudiencesResource) List

List returns all audiences with cursor-based pagination.

Example:

page, err := client.Audiences.List(ctx, nil)

func (*AudiencesResource) ListContacts

func (r *AudiencesResource) ListContacts(ctx context.Context, audienceID string, params *PaginationParams) (*PaginatedResponse[Contact], error)

ListContacts returns all contacts in an audience.

Example:

page, err := client.Audiences.ListContacts(ctx, "aud_abc123", nil)

func (*AudiencesResource) Remove

Remove deletes an audience. Contacts themselves are not deleted.

Example:

_, err := client.Audiences.Remove(ctx, "aud_abc123")

func (*AudiencesResource) RemoveContact

func (r *AudiencesResource) RemoveContact(ctx context.Context, audienceID, contactID string) (*DeleteResponse, error)

RemoveContact removes a contact from an audience.

Example:

_, err := client.Audiences.RemoveContact(ctx, "aud_abc123", "ct_xyz456")

func (*AudiencesResource) Update

Update updates an audience's name or description.

Example:

updated, err := client.Audiences.Update(ctx, "aud_abc123", sendry.UpdateAudienceParams{
    Name: "VIP Subscribers",
})

type AuthenticationError

type AuthenticationError struct {
	*APIError
}

AuthenticationError is returned when the API key is invalid or missing (HTTP 401).

type Automation added in v0.2.0

type Automation struct {
	ID                     string                `json:"id"`
	Name                   string                `json:"name"`
	Description            *string               `json:"description"`
	Status                 AutomationStatus      `json:"status"`
	TriggerType            AutomationTriggerType `json:"trigger_type"`
	TriggerConfig          map[string]any        `json:"trigger_config"`
	EntrySegmentID         *string               `json:"entry_segment_id"`
	ReentryPolicy          string                `json:"reentry_policy"`
	ReentryCooldownSeconds *int                  `json:"reentry_cooldown_seconds"`
	TotalRuns              int                   `json:"total_runs"`
	ActiveRuns             int                   `json:"active_runs"`
	CompletedRuns          int                   `json:"completed_runs"`
	FailedRuns             int                   `json:"failed_runs"`
	CreatedAt              string                `json:"created_at"`
	UpdatedAt              string                `json:"updated_at"`
}

Automation represents an automation workflow definition.

type AutomationReentryPolicy added in v0.2.0

type AutomationReentryPolicy string

AutomationReentryPolicy describes how a contact may re-enter an automation.

const (
	AutomationReentryOncePerContact AutomationReentryPolicy = "once_per_contact"
	AutomationReentryCooldown       AutomationReentryPolicy = "cooldown"
	AutomationReentryAlways         AutomationReentryPolicy = "always"
)

type AutomationRun added in v0.2.0

type AutomationRun struct {
	ID             string              `json:"id"`
	AutomationID   string              `json:"automation_id"`
	ContactID      *string             `json:"contact_id"`
	ContactEmail   string              `json:"contact_email"`
	TriggerEventID *string             `json:"trigger_event_id"`
	Status         AutomationRunStatus `json:"status"`
	CurrentStepID  *string             `json:"current_step_id"`
	Context        map[string]any      `json:"context"`
	StartedAt      string              `json:"started_at"`
	CompletedAt    *string             `json:"completed_at"`
	FailedAt       *string             `json:"failed_at"`
	FailureReason  *string             `json:"failure_reason"`
	CreatedAt      string              `json:"created_at"`
	UpdatedAt      string              `json:"updated_at"`
}

AutomationRun represents a single contact's execution of an automation.

type AutomationRunStatus added in v0.2.0

type AutomationRunStatus string

AutomationRunStatus is the lifecycle status of a single run.

const (
	AutomationRunPending    AutomationRunStatus = "pending"
	AutomationRunInProgress AutomationRunStatus = "in_progress"
	AutomationRunCompleted  AutomationRunStatus = "completed"
	AutomationRunFailed     AutomationRunStatus = "failed"
	AutomationRunCancelled  AutomationRunStatus = "cancelled"
)

type AutomationRunStep added in v0.2.0

type AutomationRunStep struct {
	ID           string                  `json:"id"`
	RunID        string                  `json:"run_id"`
	StepID       string                  `json:"step_id"`
	Status       AutomationRunStepStatus `json:"status"`
	EmailID      *string                 `json:"email_id"`
	BranchTaken  *string                 `json:"branch_taken"`
	ScheduledFor *string                 `json:"scheduled_for"`
	StartedAt    *string                 `json:"started_at"`
	CompletedAt  *string                 `json:"completed_at"`
	Error        *string                 `json:"error"`
	CreatedAt    string                  `json:"created_at"`
}

AutomationRunStep is a single step's execution record within a run.

type AutomationRunStepStatus added in v0.2.0

type AutomationRunStepStatus string

AutomationRunStepStatus is the lifecycle status of a single run step.

const (
	AutomationRunStepPending    AutomationRunStepStatus = "pending"
	AutomationRunStepInProgress AutomationRunStepStatus = "in_progress"
	AutomationRunStepCompleted  AutomationRunStepStatus = "completed"
	AutomationRunStepSkipped    AutomationRunStepStatus = "skipped"
	AutomationRunStepFailed     AutomationRunStepStatus = "failed"
)

type AutomationStatus added in v0.2.0

type AutomationStatus string

AutomationStatus represents the lifecycle state of an automation.

const (
	AutomationStatusDraft    AutomationStatus = "draft"
	AutomationStatusActive   AutomationStatus = "active"
	AutomationStatusPaused   AutomationStatus = "paused"
	AutomationStatusArchived AutomationStatus = "archived"
)

type AutomationStep added in v0.2.0

type AutomationStep struct {
	ID           string             `json:"id"`
	AutomationID string             `json:"automation_id"`
	ParentStepID *string            `json:"parent_step_id"`
	BranchLabel  *string            `json:"branch_label"`
	Position     int                `json:"position"`
	Type         AutomationStepType `json:"type"`
	Config       map[string]any     `json:"config"`
	CreatedAt    string             `json:"created_at"`
	UpdatedAt    string             `json:"updated_at"`
}

AutomationStep represents a single step within an automation.

type AutomationStepType added in v0.2.0

type AutomationStepType string

AutomationStepType identifies an automation step's kind.

const (
	AutomationStepSendEmail AutomationStepType = "send_email"
	AutomationStepWait      AutomationStepType = "wait"
	AutomationStepBranch    AutomationStepType = "branch"
	AutomationStepABSplit   AutomationStepType = "ab_split"
)

type AutomationTriggerType added in v0.2.0

type AutomationTriggerType string

AutomationTriggerType describes how an automation is triggered.

const (
	AutomationTriggerEvent                 AutomationTriggerType = "event"
	AutomationTriggerContactAddedToSegment AutomationTriggerType = "contact_added_to_segment"
	AutomationTriggerSchedule              AutomationTriggerType = "schedule"
	AutomationTriggerManual                AutomationTriggerType = "manual"
)

type AutomationsResource added in v0.2.0

type AutomationsResource struct {
	// contains filtered or unexported fields
}

AutomationsResource provides methods for managing automation workflows, their steps, and execution runs.

func (*AutomationsResource) Activate added in v0.2.0

func (r *AutomationsResource) Activate(ctx context.Context, id string) (*Automation, error)

Activate activates a draft or paused automation.

Example:

automation, err := client.Automations.Activate(ctx, "auto_abc123")

func (*AutomationsResource) AddStep added in v0.2.0

func (r *AutomationsResource) AddStep(ctx context.Context, automationID string, params AddAutomationStepParams) (*AutomationStep, error)

AddStep adds a new step to an automation. Use one of the typed *StepConfig constructors (SendEmailStepConfig, WaitStepConfig, BranchStepConfig, ABSplitStepConfig) and call .ToConfig() to build the Config field.

Example:

step, err := client.Automations.AddStep(ctx, "auto_abc123", sendry.AddAutomationStepParams{
    Config: sendry.WaitStepConfig{DurationSeconds: 86400}.ToConfig(),
})

func (*AutomationsResource) Archive added in v0.2.0

func (r *AutomationsResource) Archive(ctx context.Context, id string) (*Automation, error)

Archive archives an automation.

Example:

automation, err := client.Automations.Archive(ctx, "auto_abc123")

func (*AutomationsResource) CancelRun added in v0.2.0

func (r *AutomationsResource) CancelRun(ctx context.Context, automationID, runID string) (*AutomationRun, error)

CancelRun cancels an in-progress automation run.

Example:

run, err := client.Automations.CancelRun(ctx, "auto_abc123", "run_xyz")

func (*AutomationsResource) Create added in v0.2.0

Create creates a new automation in draft status.

Example:

automation, err := client.Automations.Create(ctx, sendry.CreateAutomationParams{
    Name:        "Welcome series",
    TriggerType: sendry.AutomationTriggerEvent,
})

func (*AutomationsResource) CreateRun added in v0.2.0

func (r *AutomationsResource) CreateRun(ctx context.Context, automationID string, params CreateAutomationRunParams) (*AutomationRun, error)

CreateRun creates a new manual automation run for a contact.

Example:

run, err := client.Automations.CreateRun(ctx, "auto_abc123", sendry.CreateAutomationRunParams{
    ContactEmail: "jane@example.com",
})

func (*AutomationsResource) Delete added in v0.2.0

Delete deletes an automation.

Example:

_, err := client.Automations.Delete(ctx, "auto_abc123")

func (*AutomationsResource) DeleteStep added in v0.2.0

func (r *AutomationsResource) DeleteStep(ctx context.Context, automationID, stepID string) (*DeleteResponse, error)

DeleteStep deletes a step from an automation.

Example:

_, err := client.Automations.DeleteStep(ctx, "auto_abc123", "step_xyz")

func (*AutomationsResource) Get added in v0.2.0

Get retrieves a single automation by ID.

Example:

automation, err := client.Automations.Get(ctx, "auto_abc123")

func (*AutomationsResource) GetRun added in v0.2.0

func (r *AutomationsResource) GetRun(ctx context.Context, automationID, runID string) (*AutomationRun, error)

GetRun retrieves a single automation run by ID.

Example:

run, err := client.Automations.GetRun(ctx, "auto_abc123", "run_xyz")

func (*AutomationsResource) List added in v0.2.0

List returns automations with cursor-based pagination and optional status filter.

Example:

page, err := client.Automations.List(ctx, &sendry.ListAutomationsParams{
    Status: sendry.AutomationStatusActive,
})

func (*AutomationsResource) ListRunSteps added in v0.2.0

func (r *AutomationsResource) ListRunSteps(ctx context.Context, automationID, runID string) ([]AutomationRunStep, error)

ListRunSteps returns all step-execution records for an automation run.

Example:

steps, err := client.Automations.ListRunSteps(ctx, "auto_abc123", "run_xyz")

func (*AutomationsResource) ListRuns added in v0.2.0

ListRuns returns automation runs with cursor-based pagination and optional status filter.

Example:

page, err := client.Automations.ListRuns(ctx, "auto_abc123", nil)

func (*AutomationsResource) ListSteps added in v0.2.0

func (r *AutomationsResource) ListSteps(ctx context.Context, automationID string) ([]AutomationStep, error)

ListSteps returns all steps belonging to an automation.

Example:

steps, err := client.Automations.ListSteps(ctx, "auto_abc123")

func (*AutomationsResource) Pause added in v0.2.0

func (r *AutomationsResource) Pause(ctx context.Context, id string) (*Automation, error)

Pause pauses an active automation.

Example:

automation, err := client.Automations.Pause(ctx, "auto_abc123")

func (*AutomationsResource) Update added in v0.2.0

Update patches an automation. Only provided fields are changed.

Example:

updated, err := client.Automations.Update(ctx, "auto_abc123", sendry.UpdateAutomationParams{
    Name: "Renamed automation",
})

func (*AutomationsResource) UpdateStep added in v0.2.0

func (r *AutomationsResource) UpdateStep(ctx context.Context, automationID, stepID string, params UpdateAutomationStepParams) (*AutomationStep, error)

UpdateStep patches an existing automation step.

Example:

step, err := client.Automations.UpdateStep(ctx, "auto_abc123", "step_xyz", sendry.UpdateAutomationStepParams{
    Position: sendry.IntPtr(2),
})

type BatchEmailItem

type BatchEmailItem struct {
	From        interface{}    `json:"from,omitempty"`
	To          interface{}    `json:"to"`
	CC          interface{}    `json:"cc,omitempty"`
	BCC         interface{}    `json:"bcc,omitempty"`
	ReplyTo     string         `json:"reply_to,omitempty"`
	Subject     string         `json:"subject,omitempty"`
	HTML        string         `json:"html,omitempty"`
	Text        string         `json:"text,omitempty"`
	Tags        []Tag          `json:"tags,omitempty"`
	Variables   map[string]any `json:"variables,omitempty"`
	Attachments []Attachment   `json:"attachments,omitempty"`
}

BatchEmailItem is a single email within a batch send request.

type BatchEmailResponse

type BatchEmailResponse struct {
	Data []struct {
		ID     string `json:"id"`
		Status string `json:"status"`
	} `json:"data"`
}

BatchEmailResponse is returned after a batch send operation.

type BatchUnsubscribeParams

type BatchUnsubscribeParams struct {
	Emails []string `json:"emails"`
	ListID string   `json:"list_id,omitempty"`
	Reason string   `json:"reason,omitempty"`
}

BatchUnsubscribeParams are the parameters for bulk-adding unsubscribe records.

type BatchUnsubscribeResponse

type BatchUnsubscribeResponse struct {
	Inserted int `json:"inserted"`
}

BatchUnsubscribeResponse is returned after a batch unsubscribe operation.

type BenchmarkBucket

type BenchmarkBucket struct {
	Date             string  `json:"date"`
	YourDeliveryRate float64 `json:"your_delivery_rate"`
	YourOpenRate     float64 `json:"your_open_rate"`
	YourClickRate    float64 `json:"your_click_rate"`
	AvgDeliveryRate  float64 `json:"avg_delivery_rate"`
	AvgOpenRate      float64 `json:"avg_open_rate"`
	AvgClickRate     float64 `json:"avg_click_rate"`
	P50DeliveryRate  float64 `json:"p50_delivery_rate"`
	P50OpenRate      float64 `json:"p50_open_rate"`
	P50ClickRate     float64 `json:"p50_click_rate"`
	P75DeliveryRate  float64 `json:"p75_delivery_rate"`
	P75OpenRate      float64 `json:"p75_open_rate"`
	P75ClickRate     float64 `json:"p75_click_rate"`
}

BenchmarkBucket holds benchmark comparison data for a single date bucket.

type BenchmarkParams

type BenchmarkParams struct {
	From        string `json:"from"`
	To          string `json:"to"`
	Granularity string `json:"granularity,omitempty"` // "day" | "week" | "month"
}

BenchmarkParams are the query parameters for benchmark comparisons.

type BenchmarkResponse

type BenchmarkResponse struct {
	Data           []BenchmarkBucket `json:"data"`
	BenchmarkOptIn bool              `json:"benchmark_opt_in"`
	OrgCount       int               `json:"org_count"`
}

BenchmarkResponse is returned by the analytics benchmarks endpoint.

type BillingPlan

type BillingPlan struct {
	Plan            string `json:"plan"`
	HasSubscription bool   `json:"hasSubscription"`
	BillingPeriod   string `json:"billingPeriod"` // "monthly" | "annual"
}

BillingPlan represents the organisation's current billing plan.

type BillingResource

type BillingResource struct {
	// contains filtered or unexported fields
}

BillingResource provides methods for managing billing plans and Stripe sessions.

func (*BillingResource) CreateCheckout

func (r *BillingResource) CreateCheckout(ctx context.Context, params CreateCheckoutParams) (*CheckoutSession, error)

CreateCheckout creates a Stripe Checkout session for upgrading to a paid plan. Redirect the user to the returned URL to complete payment.

Example:

session, err := client.Billing.CreateCheckout(ctx, sendry.CreateCheckoutParams{
    Plan:          "pro",
    BillingPeriod: "annual",
    SuccessURL:    "https://app.acme.com/billing?success=1",
})
// Redirect user to session.URL

func (*BillingResource) CreatePortal

func (r *BillingResource) CreatePortal(ctx context.Context, params *CreatePortalParams) (*PortalSession, error)

CreatePortal creates a Stripe Billing Portal session for managing the subscription. Redirect the user to the returned URL to manage their plan.

Example:

portal, err := client.Billing.CreatePortal(ctx, &sendry.CreatePortalParams{
    ReturnURL: "https://app.acme.com/billing",
})
// Redirect user to portal.URL

func (*BillingResource) GetPlan

func (r *BillingResource) GetPlan(ctx context.Context) (*BillingPlan, error)

GetPlan returns the organisation's current billing plan and subscription status.

Example:

plan, err := client.Billing.GetPlan(ctx)
fmt.Println(plan.Plan, plan.BillingPeriod) // "pro" "monthly"

func (*BillingResource) GetUsage

func (r *BillingResource) GetUsage(ctx context.Context) (*BillingUsage, error)

GetUsage returns the current billing usage summary for the organisation.

Example:

usage, err := client.Billing.GetUsage(ctx)
fmt.Printf("%d / %d emails sent this period\n", usage.EmailsSentThisPeriod, usage.PlanLimit)

type BillingUsage

type BillingUsage struct {
	EmailsSentThisPeriod int      `json:"emails_sent_this_period"`
	PlanLimit            int      `json:"plan_limit"`
	OverageCount         int      `json:"overage_count"`
	OverageRate          *float64 `json:"overage_rate"`
	PeriodEnd            *string  `json:"period_end"`
}

BillingUsage represents the organisation's current billing usage summary.

type BimiConfig

type BimiConfig struct {
	ID         string  `json:"id"`
	DomainID   string  `json:"domain_id"`
	LogoURL    string  `json:"logo_url"`
	VmcURL     *string `json:"vmc_url"`
	Selector   string  `json:"selector"`
	Status     string  `json:"status"`
	DnsRecord  *string `json:"dns_record"`
	VerifiedAt *string `json:"verified_at"`
	CreatedAt  string  `json:"created_at"`
	UpdatedAt  string  `json:"updated_at"`
}

BimiConfig represents the BIMI configuration for a domain.

type BlocklistAlertItem added in v0.2.0

type BlocklistAlertItem struct {
	ID         string  `json:"id"`
	Target     string  `json:"target"`
	TargetType string  `json:"target_type"`
	Provider   string  `json:"provider"`
	Status     string  `json:"status"`
	ListedAt   string  `json:"listed_at"`
	ResolvedAt *string `json:"resolved_at"`
}

BlocklistAlertItem is an active blocklist alert.

type BlocklistCheckBody added in v0.2.0

type BlocklistCheckBody struct {
	Target     string `json:"target"`
	TargetType string `json:"target_type"` // "domain" | "ip"
}

BlocklistCheckBody are the parameters for an on-demand blocklist check.

type BlocklistCheckItem added in v0.2.0

type BlocklistCheckItem struct {
	ID             string  `json:"id"`
	Target         string  `json:"target"`
	TargetType     string  `json:"target_type"`
	Provider       string  `json:"provider"`
	Listed         bool    `json:"listed"`
	ListingReason  *string `json:"listing_reason"`
	ResponseTimeMS *int    `json:"response_time_ms"`
	CheckedAt      string  `json:"checked_at"`
}

BlocklistCheckItem is a single blocklist check result.

type BlocklistQuery added in v0.2.0

type BlocklistQuery struct {
	Target     string `json:"target,omitempty"`
	TargetType string `json:"target_type,omitempty"` // "domain" | "ip"
}

BlocklistQuery are the query parameters for fetching blocklist status.

type BlocklistResponse added in v0.2.0

type BlocklistResponse struct {
	Checks  []BlocklistCheckItem `json:"checks"`
	Alerts  []BlocklistAlertItem `json:"alerts"`
	Summary BlocklistSummary     `json:"summary"`
}

BlocklistResponse is returned by the blocklist status endpoint.

type BlocklistSummary added in v0.2.0

type BlocklistSummary struct {
	TotalTargets int `json:"total_targets"`
	ListedCount  int `json:"listed_count"`
	CleanCount   int `json:"clean_count"`
}

BlocklistSummary summarises blocklist check totals.

type BranchStepCondition added in v0.2.0

type BranchStepCondition struct {
	Op            string `json:"op"`
	Property      string `json:"property,omitempty"`
	Value         any    `json:"value,omitempty"`
	SegmentID     string `json:"segment_id,omitempty"`
	EventName     string `json:"event_name,omitempty"`
	WithinSeconds *int   `json:"within_seconds,omitempty"`
}

BranchStepCondition is the condition payload for a branch step.

type BranchStepConfig added in v0.2.0

type BranchStepConfig struct {
	Condition BranchStepCondition `json:"condition"`
}

BranchStepConfig builds a map[string]any config for a branch step.

func (BranchStepConfig) ToConfig added in v0.2.0

func (s BranchStepConfig) ToConfig() map[string]any

ToConfig converts the typed step config to a generic map.

type BrandingSettings added in v0.2.0

type BrandingSettings struct {
	BrandColor             string  `json:"brand_color"`
	UnsubscribeHeading     *string `json:"unsubscribe_heading"`
	UnsubscribeMessage     *string `json:"unsubscribe_message"`
	UnsubscribeRedirectURL *string `json:"unsubscribe_redirect_url"`
}

BrandingSettings are the organisation's branding settings.

type BreakdownItem

type BreakdownItem struct {
	ID           *string `json:"id"`
	Name         *string `json:"name"`
	Sent         int     `json:"sent"`
	Delivered    int     `json:"delivered"`
	Opened       int     `json:"opened"`
	Clicked      int     `json:"clicked"`
	Bounced      int     `json:"bounced"`
	Complained   int     `json:"complained"`
	DeliveryRate float64 `json:"delivery_rate"`
	OpenRate     float64 `json:"open_rate"`
	ClickRate    float64 `json:"click_rate"`
}

BreakdownItem holds metrics for a single dimension in a breakdown report.

type BreakdownParams

type BreakdownParams struct {
	From    string `json:"from"`
	To      string `json:"to"`
	GroupBy string `json:"group_by"` // "domain" | "template"
	Limit   *int   `json:"limit,omitempty"`
}

BreakdownParams are the query parameters for analytics breakdowns.

type BreakdownResponse

type BreakdownResponse struct {
	Data    []BreakdownItem `json:"data"`
	GroupBy string          `json:"group_by"`
}

BreakdownResponse is returned by the analytics breakdowns endpoint.

type BulkImportContactItem

type BulkImportContactItem struct {
	Email        string         `json:"email"`
	FirstName    string         `json:"first_name,omitempty"`
	LastName     string         `json:"last_name,omitempty"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	Unsubscribed *bool          `json:"unsubscribed,omitempty"`
}

BulkImportContactItem is a single contact in a bulk import operation.

type BulkImportContactsParams

type BulkImportContactsParams struct {
	Contacts   []BulkImportContactItem `json:"contacts"`
	AudienceID string                  `json:"audience_id,omitempty"`
}

BulkImportContactsParams are the parameters for bulk-importing contacts.

type BulkImportResult

type BulkImportResult struct {
	Created int `json:"created"`
	Updated int `json:"updated"`
	Total   int `json:"total"`
}

BulkImportResult is returned after a bulk contact import.

type Campaign

type Campaign struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	Subject       string        `json:"subject"`
	From          string        `json:"from"`
	ReplyTo       *string       `json:"reply_to"`
	PreviewText   *string       `json:"preview_text"`
	AudienceID    string        `json:"audience_id"`
	TemplateID    *string       `json:"template_id"`
	HTML          *string       `json:"html"`
	Text          *string       `json:"text"`
	Status        string        `json:"status"`
	ScheduledAt   *string       `json:"scheduled_at"`
	SendStartedAt *string       `json:"send_started_at"`
	SentAt        *string       `json:"sent_at"`
	Stats         CampaignStats `json:"stats"`
	CreatedAt     string        `json:"created_at"`
	UpdatedAt     string        `json:"updated_at"`
}

Campaign represents a full campaign with content and stats.

type CampaignActionResponse

type CampaignActionResponse struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

CampaignActionResponse is returned after campaign state-change actions.

type CampaignListItem

type CampaignListItem struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Subject     string        `json:"subject"`
	From        string        `json:"from"`
	AudienceID  string        `json:"audience_id"`
	Status      string        `json:"status"`
	ScheduledAt *string       `json:"scheduled_at"`
	SentAt      *string       `json:"sent_at"`
	Stats       CampaignStats `json:"stats"`
	CreatedAt   string        `json:"created_at"`
	UpdatedAt   string        `json:"updated_at"`
}

CampaignListItem is a campaign summary for list responses.

type CampaignStats

type CampaignStats struct {
	TotalRecipients   int `json:"total_recipients"`
	SentCount         int `json:"sent_count"`
	DeliveredCount    int `json:"delivered_count"`
	OpenedCount       int `json:"opened_count"`
	ClickedCount      int `json:"clicked_count"`
	BouncedCount      int `json:"bounced_count"`
	ComplainedCount   int `json:"complained_count"`
	UnsubscribedCount int `json:"unsubscribed_count"`
	FailedCount       int `json:"failed_count"`
}

CampaignStats holds delivery statistics for a campaign.

type CampaignStatus

type CampaignStatus string

CampaignStatus represents the status of a campaign.

const (
	CampaignStatusDraft     CampaignStatus = "draft"
	CampaignStatusScheduled CampaignStatus = "scheduled"
	CampaignStatusSending   CampaignStatus = "sending"
	CampaignStatusPaused    CampaignStatus = "paused"
	CampaignStatusSent      CampaignStatus = "sent"
	CampaignStatusCancelled CampaignStatus = "cancelled"
)

type CampaignsResource

type CampaignsResource struct {
	// contains filtered or unexported fields
}

CampaignsResource provides methods for creating and managing email campaigns.

func (*CampaignsResource) Cancel

Cancel cancels a scheduled or paused campaign.

Example:

result, err := client.Campaigns.Cancel(ctx, "cp_abc123")

func (*CampaignsResource) Create

Create creates a new campaign in draft status.

Example:

campaign, err := client.Campaigns.Create(ctx, sendry.CreateCampaignParams{
    Name:       "March Newsletter",
    Subject:    "What's new in March",
    From:       "Acme <hello@acme.com>",
    AudienceID: "aud_abc123",
    HTML:       "<h1>Hello!</h1>",
})

func (*CampaignsResource) Get

func (r *CampaignsResource) Get(ctx context.Context, id string) (*Campaign, error)

Get retrieves a campaign by its ID, including delivery statistics.

Example:

campaign, err := client.Campaigns.Get(ctx, "cp_abc123")
fmt.Println(campaign.Stats.DeliveredCount)

func (*CampaignsResource) List

List returns campaigns with cursor-based pagination and optional status filter.

Example:

page, err := client.Campaigns.List(ctx, &sendry.ListCampaignsParams{Status: "draft"})

func (*CampaignsResource) Pause

Pause pauses a campaign that is currently sending.

Example:

result, err := client.Campaigns.Pause(ctx, "cp_abc123")

func (*CampaignsResource) Remove

Remove deletes a campaign. Only draft or cancelled campaigns can be deleted.

Example:

_, err := client.Campaigns.Remove(ctx, "cp_abc123")

func (*CampaignsResource) Resume

Resume resumes a paused campaign.

Example:

result, err := client.Campaigns.Resume(ctx, "cp_abc123")

func (*CampaignsResource) Schedule

Schedule schedules a draft campaign to be sent at a specific time.

Example:

result, err := client.Campaigns.Schedule(ctx, "cp_abc123", sendry.ScheduleCampaignParams{
    ScheduledAt: "2026-03-15T10:00:00Z",
})

func (*CampaignsResource) Send

Send immediately enqueues a draft or scheduled campaign for sending.

Example:

result, err := client.Campaigns.Send(ctx, "cp_abc123")

func (*CampaignsResource) Update

Update modifies a campaign. Only draft campaigns can be updated.

Example:

updated, err := client.Campaigns.Update(ctx, "cp_abc123", sendry.UpdateCampaignParams{
    Subject: "Updated subject line",
})

type CancelEmailResponse

type CancelEmailResponse struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

CancelEmailResponse is returned after cancelling a queued email.

type CheckoutSession

type CheckoutSession struct {
	URL string `json:"url"`
}

CheckoutSession contains the URL to redirect the user to for Stripe Checkout.

type Client

type Client struct {

	// Resource accessors
	Emails                  *EmailsResource
	Domains                 *DomainsResource
	Templates               *TemplatesResource
	APIKeys                 *APIKeysResource
	Webhooks                *WebhooksResource
	Analytics               *AnalyticsResource
	Suppression             *SuppressionResource
	Unsubscribes            *UnsubscribesResource
	Contacts                *ContactsResource
	Audiences               *AudiencesResource
	Campaigns               *CampaignsResource
	Billing                 *BillingResource
	Team                    *TeamResource
	DedicatedIps            *DedicatedIpsResource
	Deliverability          *DeliverabilityResource
	Inbound                 *InboundResource
	NotificationPreferences *NotificationPreferencesResource
	Organizations           *OrganizationsResource
	Regions                 *RegionsResource
	Status                  *StatusResource
	TestEmails              *TestEmailsResource
	Automations             *AutomationsResource
	Events                  *EventsResource
	// contains filtered or unexported fields
}

Client is the Sendry API client. Create one with NewClient and call methods on the resource fields (e.g. client.Emails.Send).

func NewClient

func NewClient(apiKey string, opts ...Option) *Client

NewClient creates a new Sendry API client authenticated with the given API key. Pass functional options to customise the base URL, HTTP client, or timeout.

Example:

client := sendry.NewClient("sn_live_abc123")

// With options
client := sendry.NewClient(
    "sn_live_abc123",
    sendry.WithTimeout(10*time.Second),
    sendry.WithBaseURL("https://api.sendry.online"),
)

type CohortBucket

type CohortBucket struct {
	CohortDate   string  `json:"cohort_date"`
	PeriodOffset int     `json:"period_offset"`
	TotalSent    int     `json:"total_sent"`
	MetricValue  float64 `json:"metric_value"`
}

CohortBucket holds cohort analysis data for a specific period offset.

type CohortParams

type CohortParams struct {
	From        string `json:"from"`
	To          string `json:"to"`
	Granularity string `json:"granularity,omitempty"` // "day" | "week" | "month"
	Metric      string `json:"metric,omitempty"`      // "open_rate" | "click_rate" | "delivery_rate"
}

CohortParams are the query parameters for cohort analysis.

type CohortResponse

type CohortResponse struct {
	Cohorts     []CohortBucket `json:"cohorts"`
	Granularity string         `json:"granularity"`
	Metric      string         `json:"metric"`
}

CohortResponse is returned by the analytics cohorts endpoint.

type ComparisonChanges

type ComparisonChanges struct {
	SentPct            float64 `json:"sent_pct"`
	DeliveredPct       float64 `json:"delivered_pct"`
	OpenedPct          float64 `json:"opened_pct"`
	ClickedPct         float64 `json:"clicked_pct"`
	BouncedPct         float64 `json:"bounced_pct"`
	ComplainedPct      float64 `json:"complained_pct"`
	DeliveryRateDelta  float64 `json:"delivery_rate_delta"`
	OpenRateDelta      float64 `json:"open_rate_delta"`
	ClickRateDelta     float64 `json:"click_rate_delta"`
	BounceRateDelta    float64 `json:"bounce_rate_delta"`
	ComplaintRateDelta float64 `json:"complaint_rate_delta"`
}

ComparisonChanges holds percentage deltas between periods.

type ComparisonPeriodStats

type ComparisonPeriodStats struct {
	Sent          int     `json:"sent"`
	Delivered     int     `json:"delivered"`
	Opened        int     `json:"opened"`
	Clicked       int     `json:"clicked"`
	Bounced       int     `json:"bounced"`
	Complained    int     `json:"complained"`
	DeliveryRate  float64 `json:"delivery_rate"`
	OpenRate      float64 `json:"open_rate"`
	ClickRate     float64 `json:"click_rate"`
	BounceRate    float64 `json:"bounce_rate"`
	ComplaintRate float64 `json:"complaint_rate"`
}

ComparisonPeriodStats holds metrics for a single comparison period.

type ComparisonResponse

type ComparisonResponse struct {
	Current  ComparisonPeriodStats `json:"current"`
	Previous ComparisonPeriodStats `json:"previous"`
	Changes  ComparisonChanges     `json:"changes"`
}

ComparisonResponse is returned by the analytics comparison endpoint.

type CompileBlocksParams

type CompileBlocksParams struct {
	Design    map[string]any    `json:"design"`
	Variables map[string]string `json:"variables,omitempty"`
}

CompileBlocksParams are the parameters for compiling a visual block design.

type ConfigureBimiParams

type ConfigureBimiParams struct {
	// LogoURL is the SVG logo URL (must be publicly accessible).
	LogoURL string `json:"logo_url"`
	// VmcURL is the Verified Mark Certificate URL (optional).
	VmcURL string `json:"vmc_url,omitempty"`
	// Selector is the BIMI selector name. Defaults to "default".
	Selector string `json:"selector,omitempty"`
}

ConfigureBimiParams are the parameters for setting up BIMI on a domain.

type Contact

type Contact struct {
	ID           string  `json:"id"`
	Email        string  `json:"email"`
	FirstName    *string `json:"first_name"`
	LastName     *string `json:"last_name"`
	Metadata     any     `json:"metadata"`
	Unsubscribed bool    `json:"unsubscribed"`
	CreatedAt    string  `json:"created_at"`
	UpdatedAt    string  `json:"updated_at"`
}

Contact represents a contact stored in Sendry.

type ContactsResource

type ContactsResource struct {
	// contains filtered or unexported fields
}

ContactsResource provides methods for managing contacts.

func (*ContactsResource) BulkImport

BulkImport imports up to 1000 contacts at once. Existing contacts matched by email are updated; new ones are created.

Example:

result, err := client.Contacts.BulkImport(ctx, sendry.BulkImportContactsParams{
    Contacts: []sendry.BulkImportContactItem{
        {Email: "alice@example.com", FirstName: "Alice"},
        {Email: "bob@example.com", FirstName: "Bob"},
    },
    AudienceID: "aud_abc123",
})
fmt.Println(result.Created, result.Updated)

func (*ContactsResource) Create

func (r *ContactsResource) Create(ctx context.Context, params CreateContactParams) (*Contact, error)

Create creates a new contact.

Example:

contact, err := client.Contacts.Create(ctx, sendry.CreateContactParams{
    Email:     "jane@example.com",
    FirstName: "Jane",
    LastName:  "Doe",
})

func (*ContactsResource) Get

func (r *ContactsResource) Get(ctx context.Context, id string) (*Contact, error)

Get retrieves a contact by its ID.

Example:

contact, err := client.Contacts.Get(ctx, "ct_abc123")

func (*ContactsResource) List

List returns a cursor-paginated list of contacts with optional filters.

Example:

page, err := client.Contacts.List(ctx, &sendry.ListContactsParams{
    AudienceID: "aud_abc123",
})

func (*ContactsResource) Remove

func (r *ContactsResource) Remove(ctx context.Context, id string) (*DeleteResponse, error)

Remove deletes a contact.

Example:

_, err := client.Contacts.Remove(ctx, "ct_abc123")

func (*ContactsResource) Update

func (r *ContactsResource) Update(ctx context.Context, id string, params UpdateContactParams) (*Contact, error)

Update updates a contact.

Example:

updated, err := client.Contacts.Update(ctx, "ct_abc123", sendry.UpdateContactParams{
    Unsubscribed: sendry.BoolPtr(true),
})

type CreateAPIKeyParams

type CreateAPIKeyParams struct {
	Name  string      `json:"name"`
	Scope APIKeyScope `json:"scope,omitempty"`
}

CreateAPIKeyParams are the parameters for creating a new API key.

type CreateAudienceParams

type CreateAudienceParams struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

CreateAudienceParams are the parameters for creating an audience.

type CreateAutomationParams added in v0.2.0

type CreateAutomationParams struct {
	Name                   string                  `json:"name"`
	Description            string                  `json:"description,omitempty"`
	TriggerType            AutomationTriggerType   `json:"trigger_type"`
	TriggerConfig          map[string]any          `json:"trigger_config,omitempty"`
	EntrySegmentID         string                  `json:"entry_segment_id,omitempty"`
	ReentryPolicy          AutomationReentryPolicy `json:"reentry_policy,omitempty"`
	ReentryCooldownSeconds *int                    `json:"reentry_cooldown_seconds,omitempty"`
}

CreateAutomationParams are the parameters for creating an automation.

type CreateAutomationRunParams added in v0.2.0

type CreateAutomationRunParams struct {
	ContactID    string         `json:"contact_id,omitempty"`
	ContactEmail string         `json:"contact_email,omitempty"`
	Context      map[string]any `json:"context,omitempty"`
}

CreateAutomationRunParams are the parameters for creating a manual automation run.

type CreateCampaignParams

type CreateCampaignParams struct {
	Name        string `json:"name"`
	Subject     string `json:"subject"`
	From        string `json:"from"`
	ReplyTo     string `json:"reply_to,omitempty"`
	PreviewText string `json:"preview_text,omitempty"`
	AudienceID  string `json:"audience_id"`
	TemplateID  string `json:"template_id,omitempty"`
	HTML        string `json:"html,omitempty"`
	Text        string `json:"text,omitempty"`
}

CreateCampaignParams are the parameters for creating a new campaign.

type CreateCheckoutParams

type CreateCheckoutParams struct {
	Plan          string `json:"plan"`
	BillingPeriod string `json:"billingPeriod,omitempty"` // "monthly" | "annual"
	SuccessURL    string `json:"successUrl,omitempty"`
	CancelURL     string `json:"cancelUrl,omitempty"`
}

CreateCheckoutParams are the parameters for creating a Stripe Checkout session.

type CreateContactParams

type CreateContactParams struct {
	Email        string         `json:"email"`
	FirstName    string         `json:"first_name,omitempty"`
	LastName     string         `json:"last_name,omitempty"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	Unsubscribed *bool          `json:"unsubscribed,omitempty"`
	AudienceID   string         `json:"audience_id,omitempty"`
}

CreateContactParams are the parameters for creating a contact.

type CreateDomainParams

type CreateDomainParams struct {
	Name string `json:"name"`
}

CreateDomainParams are the parameters for adding a domain.

type CreatePortalParams

type CreatePortalParams struct {
	ReturnURL string `json:"returnUrl,omitempty"`
}

CreatePortalParams are the parameters for creating a Stripe Billing Portal session.

type CreateTemplateParams

type CreateTemplateParams struct {
	Name      string                      `json:"name"`
	Subject   string                      `json:"subject,omitempty"`
	HTML      string                      `json:"html,omitempty"`
	Engine    string                      `json:"engine,omitempty"` // "html" | "react"
	Variables map[string]TemplateVariable `json:"variables,omitempty"`
}

CreateTemplateParams are the parameters for creating a new template.

type CreateUnsubscribeParams

type CreateUnsubscribeParams struct {
	Email  string `json:"email"`
	ListID string `json:"list_id,omitempty"`
	Reason string `json:"reason,omitempty"`
}

CreateUnsubscribeParams are the parameters for adding a single unsubscribe record.

type CreateWebhookParams

type CreateWebhookParams struct {
	URL    string   `json:"url"`
	Events []string `json:"events"`
}

CreateWebhookParams are the parameters for creating a webhook endpoint.

type DedicatedIp added in v0.2.0

type DedicatedIp struct {
	ID             string                  `json:"id"`
	IPAddress      string                  `json:"ip_address"`
	Provider       string                  `json:"provider"`
	Status         string                  `json:"status"` // "provisioning" | "warming" | "active" | "inactive"
	WarmupDay      int                     `json:"warmup_day"`
	WarmupProgress int                     `json:"warmup_progress"`
	PoolName       *string                 `json:"pool_name"`
	Assignments    []DedicatedIpAssignment `json:"assignments,omitempty"`
	CreatedAt      string                  `json:"created_at"`
}

DedicatedIp represents a dedicated sending IP provisioned for the organisation.

type DedicatedIpAssignment added in v0.2.0

type DedicatedIpAssignment struct {
	ID         string `json:"id"`
	DomainID   string `json:"domain_id"`
	DomainName string `json:"domain_name"`
	CreatedAt  string `json:"created_at"`
}

DedicatedIpAssignment describes a domain-to-IP assignment summary embedded inside a DedicatedIp.

type DedicatedIpsResource added in v0.2.0

type DedicatedIpsResource struct {
	// contains filtered or unexported fields
}

DedicatedIpsResource provides methods for managing dedicated sending IPs.

func (*DedicatedIpsResource) Assign added in v0.2.0

func (r *DedicatedIpsResource) Assign(ctx context.Context, ipID string, params AssignIpParams) (*IpAssignment, error)

Assign assigns a dedicated IP to a domain. The IP must be in warming or active status.

Example:

assignment, err := client.DedicatedIps.Assign(ctx, "dip_abc123", sendry.AssignIpParams{
    DomainID: "dom_xyz456",
})

func (*DedicatedIpsResource) Get added in v0.2.0

Get retrieves details for a specific dedicated IP.

Example:

ip, err := client.DedicatedIps.Get(ctx, "dip_abc123")

func (*DedicatedIpsResource) List added in v0.2.0

List returns all dedicated IPs for the organisation.

Example:

page, err := client.DedicatedIps.List(ctx, nil)

func (*DedicatedIpsResource) Provision added in v0.2.0

Provision provisions a new dedicated IP address for email sending. Available on Business and Enterprise plans.

Example:

ip, err := client.DedicatedIps.Provision(ctx, &sendry.ProvisionDedicatedIpParams{
    Provider: "ses",
})

func (*DedicatedIpsResource) Release added in v0.2.0

Release releases a dedicated IP address. This deletes the associated SES pool and all domain assignments.

Example:

_, err := client.DedicatedIps.Release(ctx, "dip_abc123")

func (*DedicatedIpsResource) RemoveAssignment added in v0.2.0

func (r *DedicatedIpsResource) RemoveAssignment(ctx context.Context, ipID, assignmentID string) (*DeleteResponse, error)

RemoveAssignment removes a dedicated IP assignment from a domain.

Example:

_, err := client.DedicatedIps.RemoveAssignment(ctx, "dip_abc123", "asgn_xyz456")

type DeleteResponse

type DeleteResponse struct {
	Deleted bool `json:"deleted"`
}

DeleteResponse is returned by DELETE endpoints.

type DeliverabilityAuthentication added in v0.2.0

type DeliverabilityAuthentication struct {
	SPF   bool `json:"spf"`
	DKIM  bool `json:"dkim"`
	DMARC bool `json:"dmarc"`
	BIMI  bool `json:"bimi"`
}

DeliverabilityAuthentication holds authentication status for a domain.

type DeliverabilityBlocklistStatus added in v0.2.0

type DeliverabilityBlocklistStatus struct {
	TotalListsChecked int  `json:"total_lists_checked"`
	ActiveListings    int  `json:"active_listings"`
	Clean             bool `json:"clean"`
}

DeliverabilityBlocklistStatus holds blocklist summary in a deliverability report.

type DeliverabilityInboxPlacement added in v0.2.0

type DeliverabilityInboxPlacement struct {
	InboxPct   float64 `json:"inbox_pct"`
	SpamPct    float64 `json:"spam_pct"`
	MissingPct float64 `json:"missing_pct"`
}

DeliverabilityInboxPlacement holds inbox placement estimates.

type DeliverabilityMetrics added in v0.2.0

type DeliverabilityMetrics struct {
	TotalSent       int     `json:"total_sent"`
	TotalDelivered  int     `json:"total_delivered"`
	TotalBounced    int     `json:"total_bounced"`
	TotalComplained int     `json:"total_complained"`
	DeliveryRate    float64 `json:"delivery_rate"`
	BounceRate      float64 `json:"bounce_rate"`
	ComplaintRate   float64 `json:"complaint_rate"`
	OpenRate        float64 `json:"open_rate"`
	ClickRate       float64 `json:"click_rate"`
}

DeliverabilityMetrics holds aggregate metrics for a deliverability report.

type DeliverabilityPeriod added in v0.2.0

type DeliverabilityPeriod struct {
	From string `json:"from"`
	To   string `json:"to"`
	Days int    `json:"days"`
}

DeliverabilityPeriod describes the time range covered by a deliverability report.

type DeliverabilityReport added in v0.2.0

type DeliverabilityReport struct {
	Period                 DeliverabilityPeriod          `json:"period"`
	Metrics                DeliverabilityMetrics         `json:"metrics"`
	Reputation             DeliverabilityReputation      `json:"reputation"`
	BlocklistStatus        DeliverabilityBlocklistStatus `json:"blocklist_status"`
	InboxPlacementEstimate DeliverabilityInboxPlacement  `json:"inbox_placement_estimate"`
	Recommendations        []string                      `json:"recommendations"`
	Authentication         DeliverabilityAuthentication  `json:"authentication"`
}

DeliverabilityReport is returned by the deliverability report endpoint.

type DeliverabilityReportQuery added in v0.2.0

type DeliverabilityReportQuery struct {
	DomainID string `json:"domain_id,omitempty"`
	Days     *int   `json:"days,omitempty"`
}

DeliverabilityReportQuery are the query parameters for the deliverability report.

type DeliverabilityReputation added in v0.2.0

type DeliverabilityReputation struct {
	Score  int    `json:"score"`
	Rating string `json:"rating"`
	Trend  string `json:"trend"`
}

DeliverabilityReputation holds reputation summary in a deliverability report.

type DeliverabilityResource added in v0.2.0

type DeliverabilityResource struct {
	// contains filtered or unexported fields
}

DeliverabilityResource provides methods for reputation, blocklist, and deliverability reporting.

func (*DeliverabilityResource) DismissAlert added in v0.2.0

func (r *DeliverabilityResource) DismissAlert(ctx context.Context, alertID string) (map[string]any, error)

DismissAlert dismisses a blocklist alert by ID.

Example:

_, err := client.Deliverability.DismissAlert(ctx, "alert_abc123")

func (*DeliverabilityResource) GetBlocklist added in v0.2.0

func (r *DeliverabilityResource) GetBlocklist(ctx context.Context, params *BlocklistQuery) (*BlocklistResponse, error)

GetBlocklist returns blocklist status for the organisation's domains and IPs.

Example:

bl, err := client.Deliverability.GetBlocklist(ctx, nil)

func (*DeliverabilityResource) GetReport added in v0.2.0

GetReport returns a comprehensive deliverability report for a date range.

Example:

report, err := client.Deliverability.GetReport(ctx, &sendry.DeliverabilityReportQuery{Days: sendry.IntPtr(30)})

func (*DeliverabilityResource) GetReputation added in v0.2.0

GetReputation returns a reputation overview for the organisation or a specific domain.

Example:

rep, err := client.Deliverability.GetReputation(ctx, &sendry.ReputationQuery{Days: sendry.IntPtr(30)})

func (*DeliverabilityResource) GetReputationHistory added in v0.2.0

func (r *DeliverabilityResource) GetReputationHistory(ctx context.Context, domainID string, params *ReputationHistoryQuery) (map[string]any, error)

GetReputationHistory returns reputation score history for a specific domain.

Example:

history, err := client.Deliverability.GetReputationHistory(ctx, "dom_abc123", &sendry.ReputationHistoryQuery{
    From: "2025-01-01", To: "2025-01-31",
})

func (*DeliverabilityResource) RunBlocklistCheck added in v0.2.0

func (r *DeliverabilityResource) RunBlocklistCheck(ctx context.Context, params BlocklistCheckBody) (map[string]any, error)

RunBlocklistCheck runs an on-demand blocklist check for a specific domain or IP.

Example:

_, err := client.Deliverability.RunBlocklistCheck(ctx, sendry.BlocklistCheckBody{
    Target: "example.com", TargetType: "domain",
})

type DnsRecord

type DnsRecord struct {
	Type     string `json:"type"`
	Host     string `json:"host"`
	Value    string `json:"value"`
	Name     string `json:"name"`
	Priority *int   `json:"priority,omitempty"`
	Verified bool   `json:"verified"`
}

DnsRecord is a DNS record that must be added to verify a domain.

type Domain

type Domain struct {
	ID         string      `json:"id"`
	Name       string      `json:"name"`
	Status     string      `json:"status"` // "pending" | "verified" | "failed"
	DnsRecords []DnsRecord `json:"dns_records"`
	CreatedAt  string      `json:"created_at"`
}

Domain represents a sending domain registered in Sendry.

type DomainsResource

type DomainsResource struct {
	// contains filtered or unexported fields
}

DomainsResource provides methods for managing sending domains.

func (*DomainsResource) ConfigureBimi

func (r *DomainsResource) ConfigureBimi(ctx context.Context, domainID string, params ConfigureBimiParams) (*BimiConfig, error)

ConfigureBimi configures BIMI (Brand Indicators for Message Identification) for a domain.

Example:

bimi, err := client.Domains.ConfigureBimi(ctx, "dom_abc123", sendry.ConfigureBimiParams{
    LogoURL: "https://example.com/logo.svg",
})

func (*DomainsResource) Create

func (r *DomainsResource) Create(ctx context.Context, params CreateDomainParams) (*Domain, error)

Create adds a new domain to the organisation.

Example:

domain, err := client.Domains.Create(ctx, sendry.CreateDomainParams{Name: "example.com"})
// domain.DnsRecords contains records to add to your DNS provider

func (*DomainsResource) Get

func (r *DomainsResource) Get(ctx context.Context, id string) (*Domain, error)

Get retrieves a domain by its ID.

Example:

domain, err := client.Domains.Get(ctx, "dom_abc123")

func (*DomainsResource) GetBimi

func (r *DomainsResource) GetBimi(ctx context.Context, domainID string) (*BimiConfig, error)

GetBimi retrieves the BIMI configuration for a domain.

Example:

bimi, err := client.Domains.GetBimi(ctx, "dom_abc123")

func (*DomainsResource) List

List returns all domains registered in the organisation.

Example:

page, err := client.Domains.List(ctx, nil)

func (*DomainsResource) Remove

func (r *DomainsResource) Remove(ctx context.Context, id string) (*DeleteResponse, error)

Remove deletes a domain.

Example:

result, err := client.Domains.Remove(ctx, "dom_abc123")

func (*DomainsResource) RemoveBimi

func (r *DomainsResource) RemoveBimi(ctx context.Context, domainID string) (*DeleteResponse, error)

RemoveBimi deletes the BIMI configuration for a domain.

Example:

_, err := client.Domains.RemoveBimi(ctx, "dom_abc123")

func (*DomainsResource) Verify

Verify triggers DNS verification for a domain.

Example:

result, err := client.Domains.Verify(ctx, "dom_abc123")
if result.SpfVerified && result.DkimVerified {
    fmt.Println("Domain is fully verified!")
}

func (*DomainsResource) VerifyBimi

func (r *DomainsResource) VerifyBimi(ctx context.Context, domainID string) (*VerifyBimiResponse, error)

VerifyBimi triggers DNS verification for a domain's BIMI record.

Example:

result, err := client.Domains.VerifyBimi(ctx, "dom_abc123")

type Email

type Email struct {
	ID          string      `json:"id"`
	From        string      `json:"from"`
	To          []string    `json:"to"`
	Subject     string      `json:"subject"`
	Status      EmailStatus `json:"status"`
	CreatedAt   string      `json:"created_at"`
	SentAt      *string     `json:"sent_at"`
	LastEvent   *string     `json:"last_event"`
	Attachments []struct {
		Filename    string `json:"filename"`
		ContentType string `json:"content_type"`
	} `json:"attachments,omitempty"`
}

Email represents a sent email with its full details and status.

type EmailStatus

type EmailStatus string

EmailStatus represents the delivery status of an email.

const (
	EmailStatusQueued     EmailStatus = "queued"
	EmailStatusSending    EmailStatus = "sending"
	EmailStatusSent       EmailStatus = "sent"
	EmailStatusDelivered  EmailStatus = "delivered"
	EmailStatusBounced    EmailStatus = "bounced"
	EmailStatusComplained EmailStatus = "complained"
	EmailStatusFailed     EmailStatus = "failed"
	EmailStatusCancelled  EmailStatus = "cancelled"
)

type EmailsResource

type EmailsResource struct {
	// contains filtered or unexported fields
}

EmailsResource provides methods for sending and managing emails.

func (*EmailsResource) Cancel

Cancel cancels a queued email. Only emails that have not yet been sent can be cancelled.

Example:

result, err := client.Emails.Cancel(ctx, "em_abc123")

func (*EmailsResource) Get

func (r *EmailsResource) Get(ctx context.Context, id string) (*Email, error)

Get retrieves a single email by its ID.

Example:

email, err := client.Emails.Get(ctx, "em_abc123")

func (*EmailsResource) List

List returns a cursor-paginated list of emails.

Example:

page, err := client.Emails.List(ctx, &sendry.ListEmailsParams{
    PaginationParams: sendry.PaginationParams{Limit: sendry.IntPtr(25)},
})

func (*EmailsResource) Send

Send sends a single transactional email.

Example:

resp, err := client.Emails.Send(ctx, sendry.SendEmailParams{
    From:    "hello@example.com",
    To:      "user@example.com",
    Subject: "Hello",
    HTML:    "<p>World</p>",
})

func (*EmailsResource) SendBatch

func (r *EmailsResource) SendBatch(ctx context.Context, params SendBatchParams) (*BatchEmailResponse, error)

SendBatch sends a batch of up to 100 emails in a single API call.

Example:

result, err := client.Emails.SendBatch(ctx, sendry.SendBatchParams{
    From: "hello@example.com",
    Emails: []sendry.BatchEmailItem{
        {To: "a@example.com", Subject: "Hi A", HTML: "<p>A</p>"},
    },
})

func (*EmailsResource) SendMarketing

SendMarketing sends a marketing email with built-in unsubscribe support.

Example:

resp, err := client.Emails.SendMarketing(ctx, sendry.SendMarketingEmailParams{
    From:           "news@example.com",
    To:             "subscriber@example.com",
    Subject:        "Newsletter",
    HTML:           "<p>News!</p>",
    UnsubscribeURL: "https://example.com/unsub",
})

type EventsResource added in v0.2.0

type EventsResource struct {
	// contains filtered or unexported fields
}

EventsResource provides methods for ingesting and querying automation trigger events.

func (*EventsResource) Get added in v0.2.0

Get retrieves a single ingested event by ID.

Example:

event, err := client.Events.Get(ctx, "evt_abc123")

func (*EventsResource) Ingest added in v0.2.0

Ingest ingests an event into Sendry. Events may trigger automations.

Example:

event, err := client.Events.Ingest(ctx, sendry.IngestEventParams{
    Name:         "signup",
    ContactEmail: "jane@example.com",
    Payload:      map[string]any{"plan": "pro"},
})

func (*EventsResource) List added in v0.2.0

List returns ingested events with cursor-based pagination.

Example:

page, err := client.Events.List(ctx, &sendry.ListEventsParams{Name: "signup"})

type ExportParams

type ExportParams struct {
	From        string `json:"from"`
	To          string `json:"to"`
	Granularity string `json:"granularity,omitempty"` // "hour" | "day" | "week" | "month"
	Format      string `json:"format,omitempty"`      // "csv" | "json"
	Domain      string `json:"domain,omitempty"`
}

ExportParams are the query parameters for exporting analytics data.

type GetLatencyParams added in v0.2.0

type GetLatencyParams struct {
	Component string `json:"component,omitempty"`
	Hours     *int   `json:"hours,omitempty"`
}

GetLatencyParams are the query parameters for the latency endpoint.

type InboundConfig added in v0.2.0

type InboundConfig struct {
	URL    *string `json:"url"`
	Secret *string `json:"secret"`
}

InboundConfig is the inbound webhook forwarding configuration.

type InboundEmail added in v0.2.0

type InboundEmail struct {
	ID               string                   `json:"id"`
	From             string                   `json:"from"`
	To               []string                 `json:"to"`
	CC               []string                 `json:"cc"`
	Subject          *string                  `json:"subject"`
	Text             *string                  `json:"text"`
	HTML             *string                  `json:"html"`
	Headers          map[string]string        `json:"headers"`
	Attachments      []InboundEmailAttachment `json:"attachments"`
	WebhookDelivered bool                     `json:"webhook_delivered"`
	CreatedAt        string                   `json:"created_at"`
}

InboundEmail represents a received inbound email.

type InboundEmailAttachment added in v0.2.0

type InboundEmailAttachment struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int    `json:"size"`
	ContentID   string `json:"contentId,omitempty"`
}

InboundEmailAttachment is an attachment on a received inbound email.

type InboundResource added in v0.2.0

type InboundResource struct {
	// contains filtered or unexported fields
}

InboundResource provides methods for retrieving inbound emails and managing the inbound webhook forwarding configuration.

func (*InboundResource) Get added in v0.2.0

Get retrieves a specific inbound email by ID including body and attachments.

Example:

email, err := client.Inbound.Get(ctx, "inb_abc123")

func (*InboundResource) GetConfig added in v0.2.0

func (r *InboundResource) GetConfig(ctx context.Context) (*InboundConfig, error)

GetConfig returns the inbound webhook forwarding configuration.

Example:

config, err := client.Inbound.GetConfig(ctx)

func (*InboundResource) List added in v0.2.0

List returns received inbound emails with cursor-based pagination.

Example:

page, err := client.Inbound.List(ctx, nil)

func (*InboundResource) UpdateConfig added in v0.2.0

UpdateConfig updates the inbound webhook forwarding configuration.

Example:

url := "https://api.acme.com/webhooks/inbound"
secret := "my-hmac-secret"
config, err := client.Inbound.UpdateConfig(ctx, sendry.UpdateInboundConfigParams{
    URL: &url, Secret: &secret,
})

type Incident added in v0.2.0

type Incident struct {
	ID                 string              `json:"id"`
	Title              string              `json:"title"`
	Status             string              `json:"status"`
	Impact             string              `json:"impact"`
	StartsAt           *string             `json:"starts_at"`
	EndsAt             *string             `json:"ends_at"`
	ResolvedAt         *string             `json:"resolved_at"`
	CreatedAt          string              `json:"created_at"`
	UpdatedAt          string              `json:"updated_at"`
	Updates            []IncidentUpdate    `json:"updates"`
	AffectedComponents []AffectedComponent `json:"affected_components"`
}

Incident represents a status-page incident.

type IncidentUpdate added in v0.2.0

type IncidentUpdate struct {
	ID        string `json:"id"`
	Status    string `json:"status"`
	Message   string `json:"message"`
	CreatedAt string `json:"created_at"`
}

IncidentUpdate is a single update posted to an incident.

type IngestEventParams added in v0.2.0

type IngestEventParams struct {
	Name         string         `json:"name"`
	EventID      string         `json:"event_id,omitempty"`
	ContactEmail string         `json:"contact_email,omitempty"`
	ContactID    string         `json:"contact_id,omitempty"`
	Payload      map[string]any `json:"payload,omitempty"`
}

IngestEventParams are the parameters for ingesting an event.

type IngestedEvent added in v0.2.0

type IngestedEvent struct {
	ID            string         `json:"id"`
	ExternalID    *string        `json:"external_id"`
	Name          string         `json:"name"`
	ContactEmail  *string        `json:"contact_email"`
	ContactID     *string        `json:"contact_id"`
	Payload       map[string]any `json:"payload"`
	ReceivedAt    string         `json:"received_at"`
	ProcessedAt   *string        `json:"processed_at"`
	TriggeredRuns int            `json:"triggered_runs"`
	Deduped       bool           `json:"deduped,omitempty"`
}

IngestedEvent represents an event ingested into Sendry.

type InviteTeamMemberParams

type InviteTeamMemberParams struct {
	Email string `json:"email"`
	Role  string `json:"role,omitempty"` // "admin" | "member"
}

InviteTeamMemberParams are the parameters for inviting a new team member.

type IpAssignment added in v0.2.0

type IpAssignment struct {
	ID        string `json:"id"`
	IPID      string `json:"ip_id"`
	DomainID  string `json:"domain_id"`
	CreatedAt string `json:"created_at"`
}

IpAssignment is returned after assigning a dedicated IP to a domain.

type LatencyHourBucket added in v0.2.0

type LatencyHourBucket struct {
	Hour         string   `json:"hour"`
	P50MS        *float64 `json:"p50_ms"`
	P95MS        *float64 `json:"p95_ms"`
	P99MS        *float64 `json:"p99_ms"`
	SampleCount  int      `json:"sample_count"`
	TargetMetPct float64  `json:"target_met_pct"`
}

LatencyHourBucket is an hourly latency rollup.

type LatencyStats added in v0.2.0

type LatencyStats struct {
	Component    string              `json:"component"`
	TargetMS     float64             `json:"target_ms"`
	CurrentP50MS *float64            `json:"current_p50_ms"`
	TargetMet    bool                `json:"target_met"`
	Hourly       []LatencyHourBucket `json:"hourly"`
}

LatencyStats holds latency rollups for a component over a window.

type ListAutomationRunsParams added in v0.2.0

type ListAutomationRunsParams struct {
	PaginationParams
	Status string `json:"status,omitempty"`
}

ListAutomationRunsParams are the query parameters for listing automation runs.

type ListAutomationsParams added in v0.2.0

type ListAutomationsParams struct {
	PaginationParams
	Status AutomationStatus `json:"status,omitempty"`
}

ListAutomationsParams are the query parameters for listing automations.

type ListCampaignsParams

type ListCampaignsParams struct {
	PaginationParams
	Status string `json:"status,omitempty"`
}

ListCampaignsParams are the query parameters for listing campaigns.

type ListContactsParams

type ListContactsParams struct {
	PaginationParams
	Email      string `json:"email,omitempty"`
	AudienceID string `json:"audience_id,omitempty"`
}

ListContactsParams are the query parameters for listing contacts.

type ListEmailsParams

type ListEmailsParams struct {
	PaginationParams
	Status string `json:"status,omitempty"`
}

ListEmailsParams are the query parameters for listing emails.

type ListEventsParams added in v0.2.0

type ListEventsParams struct {
	PaginationParams
	Name string `json:"name,omitempty"`
}

ListEventsParams are the query parameters for listing events.

type ListTeamResponse

type ListTeamResponse struct {
	Data  []TeamMember `json:"data"`
	Seats TeamSeats    `json:"seats"`
	Plan  string       `json:"plan"`
}

ListTeamResponse is returned by the list team endpoint.

type ListUnsubscribesParams

type ListUnsubscribesParams struct {
	PaginationParams
	Email  string `json:"email,omitempty"`
	ListID string `json:"list_id,omitempty"`
}

ListUnsubscribesParams are the query parameters for listing unsubscribe records.

type LogEvent

type LogEvent struct {
	ID        string `json:"id"`
	EmailID   string `json:"email_id"`
	Type      string `json:"type"`
	Recipient string `json:"recipient"`
	Metadata  any    `json:"metadata,omitempty"`
	CreatedAt string `json:"created_at"`
}

LogEvent is a single email tracking event entry.

type LogsParams

type LogsParams struct {
	PaginationParams
	EmailID  string `json:"email_id,omitempty"`
	Type     string `json:"type,omitempty"`
	To       string `json:"to,omitempty"`
	FromDate string `json:"from_date,omitempty"`
	ToDate   string `json:"to_date,omitempty"`
}

LogsParams are the query parameters for fetching email event logs.

type NetworkError

type NetworkError struct {
	// Err is the underlying network error.
	Err error
}

NetworkError is returned when a network-level failure occurs (DNS, connection refused, timeout, etc.) and no HTTP response was received from the server.

func (*NetworkError) Error

func (e *NetworkError) Error() string

Error implements the error interface.

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

Unwrap returns the underlying error so errors.Is and errors.As work correctly.

type NotFoundError

type NotFoundError struct {
	*APIError
}

NotFoundError is returned when the requested resource does not exist (HTTP 404).

type NotificationPreferences added in v0.2.0

type NotificationPreferences struct {
	ID               string `json:"id"`
	BounceAlerts     bool   `json:"bounce_alerts"`
	ComplaintAlerts  bool   `json:"complaint_alerts"`
	DeliveryFailures bool   `json:"delivery_failures"`
	DomainIssues     bool   `json:"domain_issues"`
	DailySummary     bool   `json:"daily_summary"`
	WeeklyDigest     bool   `json:"weekly_digest"`
	MonthlyReport    bool   `json:"monthly_report"`
	AllEvents        bool   `json:"all_events"`
	DeliveryEvents   bool   `json:"delivery_events"`
	EngagementEvents bool   `json:"engagement_events"`
	ComplianceEvents bool   `json:"compliance_events"`
	CreatedAt        string `json:"created_at"`
	UpdatedAt        string `json:"updated_at"`
}

NotificationPreferences represents the current user's notification preferences.

type NotificationPreferencesResource added in v0.2.0

type NotificationPreferencesResource struct {
	// contains filtered or unexported fields
}

NotificationPreferencesResource provides methods for managing notification preferences.

func (*NotificationPreferencesResource) Get added in v0.2.0

Get returns the current user's notification preferences.

Example:

prefs, err := client.NotificationPreferences.Get(ctx)

func (*NotificationPreferencesResource) Update added in v0.2.0

Update updates notification preferences. Only provided fields are changed.

Example:

prefs, err := client.NotificationPreferences.Update(ctx, sendry.UpdateNotificationPreferencesParams{
    BounceAlerts: sendry.BoolPtr(true),
})

type Option

type Option func(*Client)

Option is a functional option for configuring a Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the API base URL. Useful for testing against a local server.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient replaces the default http.Client with a custom one.

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets the maximum number of retry attempts for 5xx / network errors. Defaults to 3. Set to 0 to disable retries.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the per-request timeout. Defaults to 30s.

type OrgRegionSettings added in v0.2.0

type OrgRegionSettings struct {
	DefaultRegion *string `json:"default_region"`
	DataResidency string  `json:"data_residency"`
}

OrgRegionSettings are the organisation-level region settings.

type Organization added in v0.2.0

type Organization struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Plan      string `json:"plan"`
	CreatedAt string `json:"createdAt"`
}

Organization represents the current organisation.

type OrganizationsResource added in v0.2.0

type OrganizationsResource struct {
	// contains filtered or unexported fields
}

OrganizationsResource provides methods for managing the current organisation.

func (*OrganizationsResource) GetBranding added in v0.2.0

GetBranding returns the current organisation's branding settings.

Example:

branding, err := client.Organizations.GetBranding(ctx)

func (*OrganizationsResource) GetCurrent added in v0.2.0

func (r *OrganizationsResource) GetCurrent(ctx context.Context) (*Organization, error)

GetCurrent returns the current organisation's details.

Example:

org, err := client.Organizations.GetCurrent(ctx)

func (*OrganizationsResource) Update added in v0.2.0

Update updates the current organisation's name.

Example:

org, err := client.Organizations.Update(ctx, sendry.UpdateOrganizationParams{Name: "Acme Corp"})

func (*OrganizationsResource) UpdateBranding added in v0.2.0

UpdateBranding updates the current organisation's branding settings.

Example:

color := "#6366f1"
branding, err := client.Organizations.UpdateBranding(ctx, sendry.UpdateBrandingParams{
    BrandColor: &color,
})

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Data       []T     `json:"data"`
	HasMore    bool    `json:"has_more"`
	NextCursor *string `json:"next_cursor"`
}

PaginatedResponse is a cursor-paginated list response returned by list endpoints.

type PaginationParams

type PaginationParams struct {
	// Limit is the maximum number of items to return (e.g. 25).
	Limit *int `json:"limit,omitempty"`
	// Cursor is the opaque cursor from the previous response's next_cursor field.
	Cursor *string `json:"cursor,omitempty"`
}

PaginationParams holds common cursor-based pagination query parameters.

type PortalSession

type PortalSession struct {
	URL string `json:"url"`
}

PortalSession contains the URL to redirect the user to for the Stripe Billing Portal.

type ProvisionDedicatedIpParams added in v0.2.0

type ProvisionDedicatedIpParams struct {
	Provider string `json:"provider,omitempty"` // "ses" | "mailgun"
}

ProvisionDedicatedIpParams are the parameters for provisioning a new dedicated IP.

type RateLimitError

type RateLimitError struct {
	*APIError
	// RetryAfter is the number of seconds to wait before retrying, or 0 if not specified.
	RetryAfter int
}

RateLimitError is returned when the rate limit has been exceeded (HTTP 429).

type Region added in v0.2.0

type Region struct {
	RegionCode  string `json:"region_code"`
	DisplayName string `json:"display_name"`
	IsDefault   bool   `json:"is_default"`
}

Region describes a single SES region available for sending.

type RegionAnalyticsItem added in v0.2.0

type RegionAnalyticsItem struct {
	Region     string  `json:"region"`
	Count      int     `json:"count"`
	Percentage float64 `json:"percentage"`
}

RegionAnalyticsItem is a single region's send breakdown.

type RegionAnalyticsParams added in v0.2.0

type RegionAnalyticsParams struct {
	From string `json:"from"`
	To   string `json:"to"`
}

RegionAnalyticsParams are the query parameters for region analytics.

type RegionAnalyticsResponse added in v0.2.0

type RegionAnalyticsResponse struct {
	Data []RegionAnalyticsItem `json:"data"`
}

RegionAnalyticsResponse is returned by the region analytics endpoint.

type RegionsResource added in v0.2.0

type RegionsResource struct {
	// contains filtered or unexported fields
}

RegionsResource provides methods for managing SES sending regions.

func (*RegionsResource) GetOrgSettings added in v0.2.0

func (r *RegionsResource) GetOrgSettings(ctx context.Context) (*OrgRegionSettings, error)

GetOrgSettings returns the organisation-level default SES sending region and data residency constraint.

Example:

settings, err := client.Regions.GetOrgSettings(ctx)

func (*RegionsResource) GetRegionAnalytics added in v0.2.0

func (r *RegionsResource) GetRegionAnalytics(ctx context.Context, params RegionAnalyticsParams) (*RegionAnalyticsResponse, error)

GetRegionAnalytics returns a breakdown of sent emails by SES region.

Example:

analytics, err := client.Regions.GetRegionAnalytics(ctx, sendry.RegionAnalyticsParams{
    From: "2025-01-01", To: "2025-01-31",
})

func (*RegionsResource) List added in v0.2.0

func (r *RegionsResource) List(ctx context.Context) ([]Region, error)

List returns all active SES regions available for sending.

Example:

regions, err := client.Regions.List(ctx)

func (*RegionsResource) SetDomainRegion added in v0.2.0

func (r *RegionsResource) SetDomainRegion(ctx context.Context, domainID string, params UpdateDomainRegionParams) (map[string]any, error)

SetDomainRegion overrides the SES sending region for a specific domain. Pass a nil Region to clear the override.

Example:

region := "eu-west-1"
_, err := client.Regions.SetDomainRegion(ctx, "dom_abc123", sendry.UpdateDomainRegionParams{Region: &region})

func (*RegionsResource) UpdateOrgSettings added in v0.2.0

func (r *RegionsResource) UpdateOrgSettings(ctx context.Context, params UpdateOrgRegionParams) (*OrgRegionSettings, error)

UpdateOrgSettings sets the organisation-level default SES sending region and optional data residency constraint.

Example:

region := "eu-west-1"
settings, err := client.Regions.UpdateOrgSettings(ctx, sendry.UpdateOrgRegionParams{
    DefaultRegion: &region, DataResidency: "eu",
})

type RenderAdhocParams

type RenderAdhocParams struct {
	HTML      string            `json:"html"`
	Engine    string            `json:"engine,omitempty"` // "html" | "react" | "visual"
	Variables map[string]string `json:"variables,omitempty"`
}

RenderAdhocParams are the parameters for rendering arbitrary HTML without saving.

type RenderTemplateParams

type RenderTemplateParams struct {
	Variables map[string]string `json:"variables,omitempty"`
}

RenderTemplateParams are the parameters for rendering a template.

type RenderTemplateResponse

type RenderTemplateResponse struct {
	HTML string `json:"html"`
	Text string `json:"text"`
}

RenderTemplateResponse is returned after rendering a template.

type ReputationCurrent added in v0.2.0

type ReputationCurrent struct {
	Score           int               `json:"score"`
	Rating          string            `json:"rating"`
	Factors         ReputationFactors `json:"factors"`
	Recommendations []string          `json:"recommendations"`
}

ReputationCurrent describes the current reputation snapshot.

type ReputationDomain added in v0.2.0

type ReputationDomain struct {
	DomainID   string `json:"domain_id"`
	DomainName string `json:"domain_name"`
	Score      int    `json:"score"`
	Rating     string `json:"rating"`
}

ReputationDomain summarises reputation for a single domain.

type ReputationFactors added in v0.2.0

type ReputationFactors struct {
	BounceRate     float64 `json:"bounceRate"`
	ComplaintRate  float64 `json:"complaintRate"`
	DeliveryRate   float64 `json:"deliveryRate"`
	EngagementRate float64 `json:"engagementRate"`
}

ReputationFactors holds the underlying factors that make up a reputation score.

type ReputationHistoryQuery added in v0.2.0

type ReputationHistoryQuery struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

ReputationHistoryQuery are the query parameters for reputation history.

type ReputationQuery added in v0.2.0

type ReputationQuery struct {
	DomainID string `json:"domain_id,omitempty"`
	Days     *int   `json:"days,omitempty"`
}

ReputationQuery are the query parameters for the reputation overview endpoint.

type ReputationResponse added in v0.2.0

type ReputationResponse struct {
	Current ReputationCurrent    `json:"current"`
	History []ReputationSnapshot `json:"history"`
	Domains []ReputationDomain   `json:"domains"`
}

ReputationResponse is returned by the reputation overview endpoint.

type ReputationSnapshot added in v0.2.0

type ReputationSnapshot struct {
	Date            string  `json:"date"`
	TotalSent       int     `json:"total_sent"`
	TotalDelivered  int     `json:"total_delivered"`
	TotalBounced    int     `json:"total_bounced"`
	TotalComplained int     `json:"total_complained"`
	TotalOpened     int     `json:"total_opened"`
	TotalClicked    int     `json:"total_clicked"`
	DeliveryRate    float64 `json:"delivery_rate"`
	BounceRate      float64 `json:"bounce_rate"`
	ComplaintRate   float64 `json:"complaint_rate"`
	OpenRate        float64 `json:"open_rate"`
	ClickRate       float64 `json:"click_rate"`
	ReputationScore int     `json:"reputation_score"`
}

ReputationSnapshot is a single historical reputation data point.

type SLASummary added in v0.2.0

type SLASummary struct {
	Target        float64 `json:"target"`
	CurrentUptime float64 `json:"current_uptime"`
	SLAMet        bool    `json:"sla_met"`
}

SLASummary summarises SLA compliance.

type ScheduleCampaignParams

type ScheduleCampaignParams struct {
	// ScheduledAt is an ISO 8601 datetime to send the campaign.
	ScheduledAt string `json:"scheduled_at"`
}

ScheduleCampaignParams are the parameters for scheduling a campaign.

type SendBatchParams

type SendBatchParams struct {
	From       string           `json:"from,omitempty"`
	Subject    string           `json:"subject,omitempty"`
	TemplateID string           `json:"template_id,omitempty"`
	Emails     []BatchEmailItem `json:"emails"`
}

SendBatchParams are the parameters for sending a batch of emails.

type SendEmailParams

type SendEmailParams struct {
	From        string            `json:"from"`
	To          interface{}       `json:"to"` // string or []string
	CC          interface{}       `json:"cc,omitempty"`
	BCC         interface{}       `json:"bcc,omitempty"`
	ReplyTo     string            `json:"reply_to,omitempty"`
	Subject     string            `json:"subject"`
	HTML        string            `json:"html,omitempty"`
	Text        string            `json:"text,omitempty"`
	Tags        []Tag             `json:"tags,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	ScheduledAt string            `json:"scheduled_at,omitempty"`
	TemplateID  string            `json:"template_id,omitempty"`
	Variables   map[string]any    `json:"variables,omitempty"`
	Attachments []Attachment      `json:"attachments,omitempty"`
	Tracking    *bool             `json:"tracking,omitempty"`
}

SendEmailParams are the parameters for sending a single email.

type SendEmailResponse

type SendEmailResponse struct {
	ID        string   `json:"id"`
	From      string   `json:"from"`
	To        []string `json:"to"`
	Subject   string   `json:"subject"`
	Status    string   `json:"status"`
	CreatedAt string   `json:"created_at"`
}

SendEmailResponse is returned after successfully sending an email.

type SendEmailStepConfig added in v0.2.0

type SendEmailStepConfig struct {
	TemplateID  string            `json:"template_id,omitempty"`
	From        string            `json:"from"`
	ReplyTo     string            `json:"reply_to,omitempty"`
	Subject     string            `json:"subject,omitempty"`
	HTML        string            `json:"html,omitempty"`
	Text        string            `json:"text,omitempty"`
	MessageType string            `json:"message_type,omitempty"` // "transactional" | "marketing"
	TopicID     string            `json:"topic_id,omitempty"`
	Variables   map[string]string `json:"variables,omitempty"`
}

SendEmailStepConfig builds a map[string]any config for a send_email step.

func (SendEmailStepConfig) ToConfig added in v0.2.0

func (s SendEmailStepConfig) ToConfig() map[string]any

ToConfig converts the typed step config to a generic map suitable for the automation step config field. The "type" discriminator is included.

type SendMarketingEmailParams

type SendMarketingEmailParams struct {
	From           string            `json:"from"`
	To             interface{}       `json:"to"`
	Subject        string            `json:"subject"`
	HTML           string            `json:"html,omitempty"`
	Text           string            `json:"text,omitempty"`
	ReplyTo        string            `json:"reply_to,omitempty"`
	Headers        map[string]string `json:"headers,omitempty"`
	Tags           []Tag             `json:"tags,omitempty"`
	UnsubscribeURL string            `json:"unsubscribe_url"`
	ListID         string            `json:"list_id,omitempty"`
	ScheduledAt    string            `json:"scheduled_at,omitempty"`
	TemplateID     string            `json:"template_id,omitempty"`
}

SendMarketingEmailParams are the parameters for sending a marketing email.

type StatusComponent added in v0.2.0

type StatusComponent struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	Group       *string `json:"group"`
	Slug        string  `json:"slug"`
	Status      string  `json:"status"`
	Uptime90d   float64 `json:"uptime_90d"`
	SLATarget   float64 `json:"sla_target"`
	SLAMet      bool    `json:"sla_met"`
}

StatusComponent describes a single component on the status page.

type StatusResource added in v0.2.0

type StatusResource struct {
	// contains filtered or unexported fields
}

StatusResource provides methods for querying Sendry's operational status.

func (*StatusResource) GetCurrent added in v0.2.0

func (r *StatusResource) GetCurrent(ctx context.Context) (*SystemStatus, error)

GetCurrent returns the current operational status of all Sendry components and any active incidents.

Example:

status, err := client.Status.GetCurrent(ctx)

func (*StatusResource) GetHistory added in v0.2.0

GetHistory returns a paginated list of resolved incidents.

Example:

page, err := client.Status.GetHistory(ctx, nil)

func (*StatusResource) GetLatency added in v0.2.0

func (r *StatusResource) GetLatency(ctx context.Context, params *GetLatencyParams) (*LatencyStats, error)

GetLatency returns hourly P50/P95/P99 latency rollups for a component.

Example:

latency, err := client.Status.GetLatency(ctx, &sendry.GetLatencyParams{
    Component: "api-gateway", Hours: sendry.IntPtr(48),
})

type SuppressionEntry

type SuppressionEntry struct {
	Email     string `json:"email"`
	Reason    string `json:"reason"`
	CreatedAt string `json:"created_at"`
}

SuppressionEntry is a single suppressed email address.

type SuppressionReason

type SuppressionReason string

SuppressionReason is the reason an address was added to the suppression list.

const (
	SuppressionReasonHardBounce  SuppressionReason = "hard_bounce"
	SuppressionReasonComplaint   SuppressionReason = "complaint"
	SuppressionReasonUnsubscribe SuppressionReason = "unsubscribe"
	SuppressionReasonManual      SuppressionReason = "manual"
)

type SuppressionResource

type SuppressionResource struct {
	// contains filtered or unexported fields
}

SuppressionResource provides methods for managing the email suppression list.

func (*SuppressionResource) Add

Add adds an email address to the suppression list.

Example:

entry, err := client.Suppression.Add(ctx, sendry.AddSuppressionParams{
    Email:  "bounced@example.com",
    Reason: sendry.SuppressionReasonHardBounce,
})

func (*SuppressionResource) List

List returns all suppressed email addresses.

Example:

page, err := client.Suppression.List(ctx, nil)

func (*SuppressionResource) Remove

func (r *SuppressionResource) Remove(ctx context.Context, email string) (*DeleteResponse, error)

Remove removes an email address from the suppression list.

Example:

_, err := client.Suppression.Remove(ctx, "bounced@example.com")

type SystemStatus added in v0.2.0

type SystemStatus struct {
	Status          string            `json:"status"`
	Components      []StatusComponent `json:"components"`
	ActiveIncidents []Incident        `json:"active_incidents"`
	SLASummary      SLASummary        `json:"sla_summary"`
}

SystemStatus is the current operational status of Sendry.

type Tag

type Tag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Tag is a name/value pair attached to an email for analytics and filtering.

type TeamMember

type TeamMember struct {
	ID        string  `json:"id"`
	OrgID     string  `json:"org_id"`
	UserID    *string `json:"user_id"`
	Email     string  `json:"email"`
	Name      *string `json:"name"`
	Role      string  `json:"role"`
	Status    string  `json:"status"`
	InvitedAt string  `json:"invited_at"`
	JoinedAt  *string `json:"joined_at"`
}

TeamMember represents a member of the organisation's team.

type TeamResource

type TeamResource struct {
	// contains filtered or unexported fields
}

TeamResource provides methods for managing team members.

func (*TeamResource) Invite

Invite sends an email invitation to a new team member. Requires admin or owner role.

Example:

member, err := client.Team.Invite(ctx, sendry.InviteTeamMemberParams{
    Email: "colleague@acme.com",
    Role:  "member",
})

func (*TeamResource) List

List returns all team members including pending invitations, plus seat usage.

Example:

team, err := client.Team.List(ctx)
fmt.Printf("%d / %d seats used\n", team.Seats.Used, team.Seats.Limit)

func (*TeamResource) Remove

func (r *TeamResource) Remove(ctx context.Context, id string) (*DeleteResponse, error)

Remove removes a team member. Requires admin or owner role.

Example:

_, err := client.Team.Remove(ctx, "mem_abc123")

func (*TeamResource) UpdateRole

func (r *TeamResource) UpdateRole(ctx context.Context, id string, params UpdateTeamMemberRoleParams) (*TeamMember, error)

UpdateRole updates a team member's role. Requires admin or owner role.

Example:

updated, err := client.Team.UpdateRole(ctx, "mem_abc123", sendry.UpdateTeamMemberRoleParams{
    Role: "admin",
})

type TeamSeats

type TeamSeats struct {
	Used      int  `json:"used"`
	Limit     int  `json:"limit"`
	Unlimited bool `json:"unlimited"`
}

TeamSeats describes the team seat usage for the organisation.

type Template

type Template struct {
	ID        string                      `json:"id"`
	Name      string                      `json:"name"`
	Subject   *string                     `json:"subject"`
	HTML      *string                     `json:"html"`
	Engine    string                      `json:"engine"`
	Variables map[string]TemplateVariable `json:"variables,omitempty"`
	CreatedAt string                      `json:"created_at"`
	UpdatedAt string                      `json:"updated_at"`
}

Template represents an email template stored in Sendry.

type TemplateStarter

type TemplateStarter struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Subject     string   `json:"subject"`
	HTML        string   `json:"html"`
	Variables   []string `json:"variables"`
	Engine      string   `json:"engine"`
}

TemplateStarter is a pre-built starter template.

type TemplateVariable

type TemplateVariable struct {
	Type     string `json:"type"`
	Required bool   `json:"required,omitempty"`
	Default  any    `json:"default,omitempty"`
}

TemplateVariable describes a variable slot within a template.

type TemplatesResource

type TemplatesResource struct {
	// contains filtered or unexported fields
}

TemplatesResource provides methods for managing and rendering email templates.

func (*TemplatesResource) CompileBlocks

CompileBlocks compiles a visual block design JSON to email-safe HTML.

Example:

result, err := client.Templates.CompileBlocks(ctx, sendry.CompileBlocksParams{
    Design:    myBlockDesign,
    Variables: map[string]string{"name": "Alice"},
})

func (*TemplatesResource) Create

Create creates a new email template.

Example:

tmpl, err := client.Templates.Create(ctx, sendry.CreateTemplateParams{
    Name:    "Welcome Email",
    Subject: "Welcome, {{name}}!",
    HTML:    "<h1>Hello {{name}}</h1>",
})

func (*TemplatesResource) Get

func (r *TemplatesResource) Get(ctx context.Context, id string) (*Template, error)

Get retrieves a template by its ID.

Example:

tmpl, err := client.Templates.Get(ctx, "tmpl_abc123")

func (*TemplatesResource) GetVisualStarter

func (r *TemplatesResource) GetVisualStarter(ctx context.Context, starterID string) (map[string]any, error)

GetVisualStarter retrieves the full design JSON for a visual starter template.

Example:

design, err := client.Templates.GetVisualStarter(ctx, "welcome-blocks")

func (*TemplatesResource) List

List returns all templates with cursor-based pagination.

Example:

page, err := client.Templates.List(ctx, nil)

func (*TemplatesResource) ListStarters

func (r *TemplatesResource) ListStarters(ctx context.Context) ([]TemplateStarter, error)

ListStarters returns all pre-built starter templates.

Example:

starters, err := client.Templates.ListStarters(ctx)

func (*TemplatesResource) ListVisualStarters

func (r *TemplatesResource) ListVisualStarters(ctx context.Context) ([]VisualStarterSummary, error)

ListVisualStarters returns summaries of all available visual (block-based) starter templates.

Example:

starters, err := client.Templates.ListVisualStarters(ctx)

func (*TemplatesResource) Remove

Remove deletes a template.

Example:

_, err := client.Templates.Remove(ctx, "tmpl_abc123")

func (*TemplatesResource) Render

Render renders a saved template with the provided variable values.

Example:

result, err := client.Templates.Render(ctx, "tmpl_abc123", &sendry.RenderTemplateParams{
    Variables: map[string]string{"name": "World"},
})

func (*TemplatesResource) RenderAdhoc

RenderAdhoc renders arbitrary HTML with variable substitution without saving a template.

Example:

result, err := client.Templates.RenderAdhoc(ctx, sendry.RenderAdhocParams{
    HTML:      "<h1>Hello {{name}}</h1>",
    Variables: map[string]string{"name": "Bob"},
})

func (*TemplatesResource) Update

Update updates a template.

Example:

updated, err := client.Templates.Update(ctx, "tmpl_abc123", sendry.UpdateTemplateParams{
    Subject: "Updated Subject",
})

type TestEmail added in v0.2.0

type TestEmail struct {
	ID          string   `json:"id"`
	From        string   `json:"from"`
	To          []string `json:"to"`
	CC          []string `json:"cc"`
	Subject     string   `json:"subject"`
	HTML        *string  `json:"html"`
	Text        *string  `json:"text"`
	MessageType string   `json:"message_type"`
	CreatedAt   string   `json:"created_at"`
}

TestEmail is the full details of a captured test-mode email.

type TestEmailSummary added in v0.2.0

type TestEmailSummary struct {
	ID          string   `json:"id"`
	From        string   `json:"from"`
	To          []string `json:"to"`
	Subject     string   `json:"subject"`
	MessageType string   `json:"message_type"`
	CreatedAt   string   `json:"created_at"`
}

TestEmailSummary is a summary of a test-mode email for list responses.

type TestEmailsResource added in v0.2.0

type TestEmailsResource struct {
	// contains filtered or unexported fields
}

TestEmailsResource provides methods for retrieving test-mode emails.

func (*TestEmailsResource) Get added in v0.2.0

Get returns a specific test email by ID including HTML and plain-text body.

Example:

email, err := client.TestEmails.Get(ctx, "te_abc123")

func (*TestEmailsResource) List added in v0.2.0

List returns test emails captured in test mode with cursor pagination.

Example:

page, err := client.TestEmails.List(ctx, nil)

type UnsubscribeEntry

type UnsubscribeEntry struct {
	ID        string  `json:"id"`
	Email     string  `json:"email"`
	ListID    *string `json:"list_id"`
	Reason    *string `json:"reason"`
	CreatedAt string  `json:"created_at"`
}

UnsubscribeEntry is a single unsubscribe record.

type UnsubscribesResource

type UnsubscribesResource struct {
	// contains filtered or unexported fields
}

UnsubscribesResource provides methods for managing the unsubscribe list.

func (*UnsubscribesResource) Create

Create adds a single email address to the unsubscribe list.

Example:

entry, err := client.Unsubscribes.Create(ctx, sendry.CreateUnsubscribeParams{
    Email:  "user@example.com",
    ListID: "newsletter",
})

func (*UnsubscribesResource) CreateBatch

CreateBatch adds up to 1000 email addresses to the unsubscribe list in one request.

Example:

result, err := client.Unsubscribes.CreateBatch(ctx, sendry.BatchUnsubscribeParams{
    Emails: []string{"a@example.com", "b@example.com"},
    ListID: "newsletter",
})
fmt.Println(result.Inserted)

func (*UnsubscribesResource) Get

Get retrieves a single unsubscribe record by its ID.

Example:

entry, err := client.Unsubscribes.Get(ctx, "unsub_abc123")

func (*UnsubscribesResource) List

List returns unsubscribed email addresses with optional filters.

Example:

page, err := client.Unsubscribes.List(ctx, &sendry.ListUnsubscribesParams{
    ListID: "newsletter",
})

func (*UnsubscribesResource) Remove

Remove deletes an unsubscribe record.

Example:

_, err := client.Unsubscribes.Remove(ctx, "unsub_abc123")

type UpdateAudienceParams

type UpdateAudienceParams struct {
	Name        string  `json:"name,omitempty"`
	Description *string `json:"description"`
}

UpdateAudienceParams are the parameters for updating an audience.

type UpdateAutomationParams added in v0.2.0

type UpdateAutomationParams struct {
	Name                   string                  `json:"name,omitempty"`
	Description            *string                 `json:"description,omitempty"`
	TriggerConfig          map[string]any          `json:"trigger_config,omitempty"`
	EntrySegmentID         *string                 `json:"entry_segment_id,omitempty"`
	ReentryPolicy          AutomationReentryPolicy `json:"reentry_policy,omitempty"`
	ReentryCooldownSeconds *int                    `json:"reentry_cooldown_seconds,omitempty"`
}

UpdateAutomationParams are the parameters for patching an automation.

type UpdateAutomationStepParams added in v0.2.0

type UpdateAutomationStepParams struct {
	ParentStepID *string        `json:"parent_step_id,omitempty"`
	BranchLabel  *string        `json:"branch_label,omitempty"`
	Position     *int           `json:"position,omitempty"`
	Config       map[string]any `json:"config,omitempty"`
}

UpdateAutomationStepParams are the parameters for patching an automation step.

type UpdateBrandingParams added in v0.2.0

type UpdateBrandingParams struct {
	BrandColor             *string `json:"brand_color,omitempty"`
	UnsubscribeHeading     *string `json:"unsubscribe_heading,omitempty"`
	UnsubscribeMessage     *string `json:"unsubscribe_message,omitempty"`
	UnsubscribeRedirectURL *string `json:"unsubscribe_redirect_url,omitempty"`
}

UpdateBrandingParams are the parameters for updating branding settings. All fields are optional and nullable. Use pointer-to-string-pointer-style helpers from the caller if you need to explicitly clear a field; the API treats a missing key as "leave unchanged" and a JSON null as "clear".

type UpdateCampaignParams

type UpdateCampaignParams struct {
	Name        string  `json:"name,omitempty"`
	Subject     string  `json:"subject,omitempty"`
	From        string  `json:"from,omitempty"`
	ReplyTo     *string `json:"reply_to"`
	PreviewText *string `json:"preview_text"`
	AudienceID  string  `json:"audience_id,omitempty"`
	TemplateID  *string `json:"template_id"`
	HTML        *string `json:"html"`
	Text        *string `json:"text"`
}

UpdateCampaignParams are the parameters for updating a campaign.

type UpdateContactParams

type UpdateContactParams struct {
	Email        string         `json:"email,omitempty"`
	FirstName    *string        `json:"first_name"`
	LastName     *string        `json:"last_name"`
	Metadata     map[string]any `json:"metadata"`
	Unsubscribed *bool          `json:"unsubscribed,omitempty"`
}

UpdateContactParams are the parameters for updating an existing contact.

type UpdateDomainRegionParams added in v0.2.0

type UpdateDomainRegionParams struct {
	Region *string `json:"region"`
}

UpdateDomainRegionParams are the parameters for setting a domain's region override.

type UpdateInboundConfigParams added in v0.2.0

type UpdateInboundConfigParams struct {
	URL    *string `json:"url"`
	Secret *string `json:"secret,omitempty"`
}

UpdateInboundConfigParams are the parameters for updating the inbound webhook config.

type UpdateNotificationPreferencesParams added in v0.2.0

type UpdateNotificationPreferencesParams struct {
	BounceAlerts     *bool `json:"bounceAlerts,omitempty"`
	ComplaintAlerts  *bool `json:"complaintAlerts,omitempty"`
	DeliveryFailures *bool `json:"deliveryFailures,omitempty"`
	DomainIssues     *bool `json:"domainIssues,omitempty"`
	DailySummary     *bool `json:"dailySummary,omitempty"`
	WeeklyDigest     *bool `json:"weeklyDigest,omitempty"`
	MonthlyReport    *bool `json:"monthlyReport,omitempty"`
	AllEvents        *bool `json:"allEvents,omitempty"`
	DeliveryEvents   *bool `json:"deliveryEvents,omitempty"`
	EngagementEvents *bool `json:"engagementEvents,omitempty"`
	ComplianceEvents *bool `json:"complianceEvents,omitempty"`
}

UpdateNotificationPreferencesParams are the parameters for updating notification preferences. Note: the API expects camelCase keys here, not snake_case.

type UpdateOrgRegionParams added in v0.2.0

type UpdateOrgRegionParams struct {
	DefaultRegion *string `json:"default_region,omitempty"`
	DataResidency string  `json:"data_residency,omitempty"` // "none" | "eu" | "us" | "ap"
}

UpdateOrgRegionParams are the parameters for updating organisation region settings.

type UpdateOrganizationParams added in v0.2.0

type UpdateOrganizationParams struct {
	Name string `json:"name"`
}

UpdateOrganizationParams are the parameters for updating organisation details.

type UpdateTeamMemberRoleParams

type UpdateTeamMemberRoleParams struct {
	Role string `json:"role"`
}

UpdateTeamMemberRoleParams are the parameters for updating a team member's role.

type UpdateTemplateParams

type UpdateTemplateParams struct {
	Name      string                      `json:"name,omitempty"`
	Subject   string                      `json:"subject,omitempty"`
	HTML      string                      `json:"html,omitempty"`
	Engine    string                      `json:"engine,omitempty"`
	Variables map[string]TemplateVariable `json:"variables,omitempty"`
}

UpdateTemplateParams are the parameters for updating an existing template.

type UpdateWebhookParams

type UpdateWebhookParams struct {
	URL    string   `json:"url,omitempty"`
	Events []string `json:"events,omitempty"`
	Active *bool    `json:"active,omitempty"`
}

UpdateWebhookParams are the parameters for updating a webhook.

type ValidationError

type ValidationError struct {
	*APIError
	// Details contains field-level validation errors from the API.
	Details any
}

ValidationError is returned when the request body or parameters fail validation (HTTP 422).

type VerifyBimiResponse

type VerifyBimiResponse struct {
	Verified bool   `json:"verified"`
	Status   string `json:"status"`
}

VerifyBimiResponse is returned after triggering BIMI DNS verification.

type VerifyDomainResponse

type VerifyDomainResponse struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Status        string `json:"status"`
	SpfVerified   bool   `json:"spf_verified"`
	DkimVerified  bool   `json:"dkim_verified"`
	DmarcVerified bool   `json:"dmarc_verified"`
}

VerifyDomainResponse is returned after triggering domain DNS verification.

type VisualStarterSummary

type VisualStarterSummary struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"`
}

VisualStarterSummary is a summary of a visual (block-based) starter template.

type WaitStepConfig added in v0.2.0

type WaitStepConfig struct {
	DurationSeconds int `json:"duration_seconds"`
}

WaitStepConfig builds a map[string]any config for a wait step.

func (WaitStepConfig) ToConfig added in v0.2.0

func (s WaitStepConfig) ToConfig() map[string]any

ToConfig converts the typed step config to a generic map.

type Webhook

type Webhook struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	Events    []string `json:"events"`
	Secret    string   `json:"secret"`
	Active    bool     `json:"active"`
	CreatedAt string   `json:"created_at"`
	UpdatedAt string   `json:"updated_at"`
}

Webhook represents a webhook endpoint with its signing secret.

type WebhookListItem

type WebhookListItem struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	Events    []string `json:"events"`
	Active    bool     `json:"active"`
	CreatedAt string   `json:"created_at"`
	UpdatedAt string   `json:"updated_at"`
}

WebhookListItem represents a webhook endpoint in a list response (no secret).

type WebhooksResource

type WebhooksResource struct {
	// contains filtered or unexported fields
}

WebhooksResource provides methods for managing webhook endpoints.

func (*WebhooksResource) Create

func (r *WebhooksResource) Create(ctx context.Context, params CreateWebhookParams) (*Webhook, error)

Create registers a new webhook endpoint.

Example:

hook, err := client.Webhooks.Create(ctx, sendry.CreateWebhookParams{
    URL:    "https://example.com/webhook",
    Events: []string{"email.delivered", "email.bounced"},
})
// hook.Secret is the HMAC secret for verifying payloads.

func (*WebhooksResource) Get

func (r *WebhooksResource) Get(ctx context.Context, id string) (*Webhook, error)

Get retrieves a webhook by its ID. The response includes the signing secret.

Example:

hook, err := client.Webhooks.Get(ctx, "wh_abc123")

func (*WebhooksResource) List

List returns all webhook endpoints.

Example:

page, err := client.Webhooks.List(ctx, nil)

func (*WebhooksResource) Remove

func (r *WebhooksResource) Remove(ctx context.Context, id string) (*DeleteResponse, error)

Remove deletes a webhook endpoint.

Example:

_, err := client.Webhooks.Remove(ctx, "wh_abc123")

func (*WebhooksResource) Update

func (r *WebhooksResource) Update(ctx context.Context, id string, params UpdateWebhookParams) (*Webhook, error)

Update modifies a webhook endpoint.

Example:

updated, err := client.Webhooks.Update(ctx, "wh_abc123", sendry.UpdateWebhookParams{
    Active: sendry.BoolPtr(false),
})

Jump to

Keyboard shortcuts

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