Skip to content

SDKs

Node and Bun SDK

@deveryidea/voaaro 0.6.0: TypeScript, ESM and CommonJS, no dependencies, Bun-compatible, retries and pagination included.

Installing

Shell
npm install @deveryidea/voaaro
# or
bun add @deveryidea/voaaro

Version 0.6.0. Node 18 or later (native fetch). Also works with Bun (checked with Bun 1.3: sending and webhook verification).

Configuring

Node / Bun
import { Voaaro } from "@deveryidea/voaaro"

const voaaro = new Voaaro(process.env.VOAARO_API_KEY, {
  baseUrl: "https://mail.example.com",
  maxRetries: 2, // default; 0: no retry and no idempotency key drawn
})

Options: baseUrl, maxRetries, fetch (your own fetch function), headers, sleep (wait between two attempts, for fast tests). Without arguments, the key and the address are read from VOAARO_API_KEY and VOAARO_BASE_URL.

Sending

Node / Bun
const { data, error } = await voaaro.emails.send(
  {
    from: "Acme <notifications@example.com>",
    to: ["client@example.org"],
    subject: "Welcome",
    html: "<p>Your account is ready.</p>",
    scheduledAt: "in 10 min",
  },
  { idempotencyKey: "welcome-42" },
)
if (error) {
  console.error(error.name, error.message) // e.g. validation_error, daily_quota_exceeded
} else {
  console.log(data.id)
}

Fields follow Resend's shape in camelCase (replyTo, scheduledAt, contentType, contentId); an attachment's content accepts a Buffer, a Uint8Array, an ArrayBuffer or base64.

Retries and idempotency

  • A request is retried (maxRetries times, 2 by default) after a network error, a 429 rate_limit_exceeded or a 500, 502, 503, 504; 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.
  • Any creation accepts { idempotencyKey } as the last argument: voaaro.forms.create({ name }, { idempotencyKey: "newsletter-form" }). Without it, the SDK draws a key (UUID v4) per call, the same from one attempt to the next.
  • error.retryAfter (seconds) is filled when the service gave Retry-After; the response headers (RateLimit-Remaining…) are in headers.

Pagination

Node / Bun
for await (const contact of voaaro.contacts.iterate({ segmentId, unsubscribed: false })) {
  console.log(contact.email)
}

// Any list: the function receives { limit, after } to merge with its filters
for await (const e of voaaro.paginate((page) => voaaro.emails.events({ type: "bounced", ...page }), { limit: 50 })) {
  console.log(e.email_id, e.recipient)
}
  • iterate(params) on emails, emails.receiving, apiKeys, domains, suppressions, contacts, contacts.imports, segments, audiences, topics, contactProperties, broadcasts, forms, newsletterTemplates, automations, webhooks, webhooks.deliveries (webhookId, params); and emails.iterateEvents, broadcasts.iterateRecipients, forms.iterateSignups, automations.iterateRuns.
  • Pages of 100 (or the limit given), after followed as long as has_more; a break stops the requests.
  • A refused page (after the retries) throws VoaaroApiError (name, message, statusCode, retryAfter): it is the only case where the SDK throws.

The rest

Node / Bun
await voaaro.batch.send([{ from, to: "a@example.org", subject, text }, { from, to: "b@example.org", subject, text }])
await voaaro.emails.get(id)
await voaaro.emails.list({ limit: 20 })
await voaaro.emails.update({ id, scheduledAt: "2026-11-20T08:00:00Z" })
await voaaro.emails.cancel(id)
await voaaro.emails.events({ type: "bounced", createdAfter: "2026-11-01T00:00:00Z" })
await voaaro.emails.receiving.list({ limit: 10 }) // personal key with receiving
await voaaro.apiKeys.create({ name: "CI", permission: "sending_access" })
await voaaro.domains.create({ name: "notify.example.com" })
await voaaro.suppressions.add({ email: "former.customer@example.org", domain: "example.com" })
await voaaro.contacts.create({ email: "ada@example.org", firstName: "Ada" })
await voaaro.broadcasts.create({ segmentId, from, subject, html, send: true })

Resources: emails (with attachments and receiving), batch, apiKeys, domains, suppressions, contacts (with segments, topics, imports), segments, audiences, topics, contactProperties, broadcasts, newsletter, forms, newsletterTemplates, automations, events, webhooks (with deliveries), organizations (operator key mko_…).

Newsletters

Node / Bun
await voaaro.newsletter.updateSettings({ from: "Acme <news@example.com>", postalAddress: "Acme\n12 Lilac Street\nSpringfield" })
const { data: overview } = await voaaro.newsletter.overview({ days: 30 })

const { data: form } = await voaaro.forms.create({ name: "Website newsletter", doubleOptIn: true, segmentIds: [segmentId] })
const { data: preview } = await voaaro.segments.preview({ filter: { match: "all", conditions: [{ field: "opened", op: "none", days: 90 }] } })

await voaaro.broadcasts.links(broadcastId)
await voaaro.broadcasts.chooseWinner(broadcastId, { variant: "b" })
const { data: csv } = await voaaro.broadcasts.export(broadcastId) // CSV text

const { data: template } = await voaaro.newsletterTemplates.create({ name: "Monthly letter", subject: "What's new", html })
await voaaro.automations.create({ name: "After purchase", trigger: { type: "event", event: "purchase" }, steps, status: "active" })
await voaaro.events.send({ email: "ada@example.org", name: "purchase", data: { total: 42 } })
await voaaro.contacts.cleanup({ days: 180 }) // simulation; dryRun: false to act

Nested objects (trigger, steps, filter, ab) keep the API's names (segment_id, sample_pct…). Route details: Newsletters. The domain parameter names the domain when the key covers several.

Subscribing and unsubscribing from your application (server: newsletter.subscribe, unsubscribe, getSubscription; browser: PublicForm, solveChallenge), campaign scheduling (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

Node / Bun
const event = voaaro.webhooks.verify(rawBody, req.headers, process.env.VOAARO_WEBHOOK_SECRET!)

Throws WebhookVerificationError if the signature is wrong or too old (5 minutes). Several secrets: pass an array [new, old] instead of one secret; the notification is accepted if one of them matches one of the header's v1. Full example and rotation: Signature.

Managing endpoints (details):

Node / Bun
const { data: hook } = await voaaro.webhooks.create({ endpoint: "https://app.example.com/webhooks/voaaro", events: ["email.bounced"] })
const secret = hook!.signing_secret // shown only once
await voaaro.webhooks.rotateSecret(hook!.id, { graceHours: 24 })
for await (const d of voaaro.webhooks.deliveries.iterate(hook!.id, { status: "failed" })) {
  await voaaro.webhooks.deliveries.replay(hook!.id, d.id)
}

From the Resend SDK

resend.emails.send becomes voaaro.emails.send, with the same parameters and the same {data, error} response; only the import, the key and baseUrl change. See what changes.

Esc