Skip to content

SDKs

Go SDK

github.com/deveryidea/voaaro-go v0.4.0 for Go 1.21 and later: standard library only, the same calls as resend-go, retries and Iter[T] iterators.

Installing

Shell
go get github.com/deveryidea/voaaro-go@latest

Version 0.4.0. Go 1.21 or later, no dependencies (standard library). Package voaaro.

Configuring

Go
import "github.com/deveryidea/voaaro-go"

client := voaaro.NewClient(os.Getenv("VOAARO_API_KEY"),
	voaaro.WithBaseURL("https://mail.example.com"),
	voaaro.WithMaxRetries(2)) // default; 0: no retry and no idempotency key drawn

Options: WithBaseURL, WithMaxRetries, WithHTTPClient, WithUserAgent, WithHeader. Default timeout: 60 seconds. Always give your instance's address with WithBaseURL (or VOAARO_BASE_URL).

Sending

Go
pdf, _ := os.ReadFile("guide.pdf")

sent, err := client.Emails.SendWithOptions(ctx, &voaaro.SendEmailRequest{
	From:        "Acme <notifications@example.com>",
	To:          []string{"client@example.org"},
	Subject:     "Welcome",
	Html:        "<p>Your account is ready.</p>",
	Attachments: []*voaaro.Attachment{{Filename: "guide.pdf", Content: pdf}}, // raw bytes
}, &voaaro.SendEmailOptions{IdempotencyKey: "welcome-42"})
if err != nil {
	var apiErr *voaaro.Error
	if errors.As(err, &apiErr) {
		log.Println(apiErr.StatusCode, apiErr.Name, apiErr.Message, apiErr.RetryAfter)
	}
	return err
}
log.Println(sent.Id)

Each method also exists as …WithContext(ctx, …).

Retries and idempotency

  • The SDK retries a request on its own after a network error, a 429 rate_limit_exceeded or a 500, 502, 503, 504: 2 retries by default (WithMaxRetries(n)). Never after daily_quota_exceeded nor another 4xx error. Wait: Retry-After (60 seconds at most), otherwise 0.5 s × 2^n with jitter, 8 seconds at most; canceling the context stops the wait.
  • Each creation request has an IdempotencyKey field (CreateContactRequest, CreateWebhookRequest, AddSuppressionRequest, CreateFormRequest…); for any other POST, voaaro.WithIdempotencyKey(ctx, key) with the WithContext variant.
  • Without a key, and as long as retries are allowed, the SDK draws a UUID v4 for each POST, the same from one attempt to the next.
Go
ctx := voaaro.WithIdempotencyKey(context.Background(), "cancel-broadcast-42")
client.Broadcasts.CancelWithContext(ctx, broadcastId)

Pagination

Each cursor list has an Iter[T] iterator (no range-over-func, for Go 1.21):

Go
it := client.Contacts.ListAll(ctx, &voaaro.ListContactsOptions{SegmentId: segmentId})
for it.Next() {
	c := it.Current()
	fmt.Println(c.Id, c.Email)
}
if err := it.Err(); err != nil {
	log.Fatal(err)
}

all, err := client.Webhooks.ListAll(ctx, nil).All() // everything at once, for a short list
  • Pages of 100 (or Limit), after followed as long as has_more; a page is only requested when needed. The option's filters are kept on each page; Before is ignored.
  • An error stops the walk: Next returns false and Err gives it.
  • ListAll on Emails, Emails.Receiving, ApiKeys, Domains, Suppressions, Contacts, Contacts.Imports, Segments, Broadcasts, Forms, NewsletterTemplates, Automations, Webhooks, Webhooks.Deliveries; and Emails.EventsAll, Segments.ListContactsAll, Broadcasts.RecipientsAll, Forms.SignupsAll, Automations.RunsAll.

The rest

Go
client.Batch.SendWithOptions(ctx, reqs, &voaaro.BatchSendEmailOptions{BatchValidation: voaaro.BatchValidationPermissive})
client.Emails.Get(id)
client.Emails.List()
client.Emails.Update(&voaaro.UpdateEmailRequest{Id: id, ScheduledAt: "in 2 hours"})
client.Emails.Cancel(id)
client.Emails.Events(&voaaro.ListEmailEventsOptions{Type: "bounced", CreatedAfter: "2026-11-01T00:00:00Z"})
client.Emails.Receiving.List(&voaaro.ListReceivedOptions{ListOptions: voaaro.ListOptions{Limit: 10}})
client.Domains.Create(&voaaro.CreateDomainRequest{Name: "notify.example.com"})
client.Suppressions.Add(&voaaro.AddSuppressionRequest{Email: "former.customer@example.org", Domain: "example.com"})
client.ApiKeys.Create(&voaaro.CreateApiKeyRequest{Name: "CI", Permission: voaaro.PermissionSendingAccess})
client.Contacts.Create(&voaaro.CreateContactRequest{Email: "ada@example.org", FirstName: "Ada"})
client.Broadcasts.Create(&voaaro.CreateBroadcastRequest{SegmentId: segmentId, From: from, Subject: subject, Html: html, Send: true})

Services: Emails (with Attachments and Receiving), Batch, ApiKeys, Domains, Suppressions, Contacts (with Imports), Segments, Audiences, Topics, ContactProperties, Broadcasts, Newsletter, Forms, NewsletterTemplates, Automations, Events, Webhooks (with Deliveries), Organizations (operator key mko_…).

Newsletters

Go
client.Newsletter.UpdateSettings(&voaaro.UpdateNewsletterSettingsRequest{
	From:          voaaro.String("Acme <news@example.com>"),
	PostalAddress: voaaro.String("Acme\n12 Lilac Street\nSpringfield"),
})
o, _ := client.Newsletter.Overview(&voaaro.NewsletterOverviewOptions{Days: 30})

f, _ := client.Forms.Create(&voaaro.CreateFormRequest{Name: "Website newsletter", SegmentIds: []string{segmentId}})
filter := &voaaro.SegmentFilter{Match: "all", Conditions: []voaaro.SegmentCondition{{"field": "opened", "op": "none", "days": 90}}}
preview, _ := client.Segments.Preview(&voaaro.PreviewSegmentRequest{Filter: filter})

client.Broadcasts.Links(broadcastId)
client.Broadcasts.ChooseWinner(broadcastId, "b")
csv, _ := client.Broadcasts.Export(broadcastId) // []byte

tpl, _ := client.NewsletterTemplates.Create(&voaaro.CreateNewsletterTemplateRequest{Name: "Monthly letter", Subject: "What's new", Html: html})
client.Events.Send(&voaaro.SendEventRequest{Email: "ada@example.org", Name: "purchase", Data: map[string]any{"total": 42}})
client.Contacts.Cleanup(&voaaro.CleanupContactsRequest{Days: 180}) // simulation; DryRun: voaaro.Bool(false) to act

Automations.Create takes an AutomationTrigger and AutomationStep values; the Domain field names the domain when the key covers several. Route details: Newsletters.

Subscribing and unsubscribing from your application (server: Newsletter.Subscribe, Unsubscribe, GetSubscription; browser: NewPublicForm, SolveChallenge), campaign scheduling (Broadcasts.Schedule, Unschedule, SendNow, ListScheduled, Check): see the guides Your own signup form, Unsubscribing from your application and Scheduling a campaign, with examples for each SDK.

Contact quality and deliverability: verifying an address without storing it (Contacts.VerifyEmail) or a contact's address (Contacts.Reverify), engagement and address status filters (Engagement, EmailStatus), CSV export (Contacts.Export), importing without invalid addresses (SkipInvalid) and a broadcast's deliverability score (Broadcasts.Deliverability): see Contacts, segments and topics and Broadcasts, with examples for each SDK.

Webhooks

Go
event, err := voaaro.VerifyWebhookRequest(r, os.Getenv("VOAARO_WEBHOOK_SECRET"))

Reads the body (at most 5 MB) and puts it back, checks the signature and the age (5 minutes); an error satisfies errors.Is(err, voaaro.ErrWebhookVerification).

Several secrets: voaaro.VerifyWebhookRequestWithSecrets(r, newSecret, oldSecret), voaaro.VerifyWebhookWithSecrets(body, signature, newSecret, oldSecret), or the WebhookSecrets field of VerifyWebhookOptions for client.Webhooks.Verify. The notification is accepted if one of the secrets matches one of the header's v1. Full example and rotation: Signature.

Managing endpoints (details):

Go
hook, _ := client.Webhooks.Create(&voaaro.CreateWebhookRequest{
	Endpoint: "https://app.example.com/webhooks/voaaro",
	Events:   []string{"email.bounced"},
})
secret := hook.SigningSecret // shown only once
client.Webhooks.RotateSecret(hook.Id, &voaaro.RotateWebhookSecretRequest{GraceHours: voaaro.Int(24)})

it := client.Webhooks.Deliveries.ListAll(ctx, hook.Id, &voaaro.ListWebhookDeliveriesOptions{Status: "failed"})
for it.Next() {
	client.Webhooks.Deliveries.Replay(hook.Id, it.Current().Id)
}
Esc