Skip to main content
The Go SDK is the module github.com/Sendflit/sendflit-go. It uses only the standard library, so it has no third-party dependencies. The package name is sendflit. It requires Go 1.21 or later.
Looking for another language? See the SDK overview.

Install

Import it in your code:

Create a client

New returns a client with a 15 second timeout and 2 retries. To point the client at a test server, use NewWithBaseURL(apiKey, baseURL). You can also change the HTTP and MaxRetries fields on the returned *Client. Every method takes a context.Context first. Use it to cancel a call or to set a deadline:

Send an email

Send takes an Email struct and returns a *SendResult.
Fields on Email: SendResult has ID, Status, and To.

Attachments

Use Attach for text content and AttachBytes for binary content. Both base64-encode the data for you.
Limits:
  • Up to 10 attachments per message.
  • Up to 10 MB per attachment. Larger files are rejected with 422.

Send a batch

Batch sends up to 100 emails in one request and returns a []SendResult in the same order as your input.
An empty slice, or more than 100 emails, returns an error before any request is made. See Batch sending.
The Go SDK doesn’t send an Idempotency-Key header yet. If a send times out and you retry it, the email can be sent twice. For now, check the result of the earlier call before you retry, or send the request yourself with the header. See Idempotency.

List emails

The Go SDK doesn’t offer get-by-id or cancel methods yet. Call GET /v1/emails/{id} or DELETE /v1/emails/{id} directly if you need them. See the API reference.

Domains

VerifyDomain returns only an error. A nil error means the call succeeded. Check the domain’s state in the dashboard or with the API if you need the details. For DNS setup, see Domains.

Suppressions

Suppressed addresses never receive email from your account. See Emails.

Health

Health calls GET /health. It doesn’t need a valid key.

Verify webhooks

VerifyWebhookSignature returns true or false. It compares signatures in constant time. See Webhooks for the event list.

Errors and retries

Failed API calls return an *APIError: Network failures return a regular error with no status.
Requests that fail with 429 or 5xx are retried up to MaxRetries times. The SDK waits for the Retry-After header when present, and otherwise backs off exponentially. Other 4xx responses are not retried. See Errors, retries and limits.

Method reference

Next steps