Skip to the page

SDK

The API as a typed TypeScript client: every method, with the same names and the same input.

Get it

The package is not on npm yet. Until it is published, use it from the repository, where it lives in packages/opensend. After that it installs as @open-send/opensend.

It runs wherever fetch does: Node.js 20 or newer, Bun, Deno and edge runtimes. It has no dependencies. This is version 0.1.0.

Make a client

With nothing given, the client reads the key from OPENSEND_API_KEY and calls our cloud, at https://api.opensend.sh. Set OPENSEND_API_URL to reach a server of your own.

TypeScript
import { OpenSend } from '@open-send/opensend' export const opensend = new OpenSend()

Or give them yourself.

TypeScript
import { OpenSend } from '@open-send/opensend' export const opensend = new OpenSend(process.env.OPENSEND_API_KEY, {  baseUrl: 'http://localhost:2222',  timeoutMs: 10_000,})
Option
baseUrl
Meaning
The address of the API. Without it the client reads OPENSEND_API_URL, and without that it calls our cloud.
Option
timeoutMs
Meaning
How long to wait for an answer. Without it the client waits 30 seconds.
Option
fetch
Meaning
A fetch of your own, for a proxy or a test.

createOpenSend(key, options) makes the same client without new.

Call a method

A method is opensend.<resource>.<method>(input), and it answers with what the API answers. A method that acts on one thing also takes the id first.

TypeScript
import { OpenSend } from '@open-send/opensend' const opensend = new OpenSend() const list = await opensend.emails.list({ status: 'bounced', limit: 20 }) const email = await opensend.emails.get('em_02') const moved = await opensend.emails.update('em_09', { scheduledAt: '2026-12-05T09:00:00Z' }) const stopper = new AbortController()const sent = await opensend.emails.send(  {    from: 'Acme <hello@mail.example.com>',    to: 'ada@example.com',    subject: 'Your receipt for November',    text: 'Thanks for your order.',  },  { idempotencyKey: 'receipt-2026-11-ada', signal: stopper.signal },) console.log(list.total, email.status, moved.scheduledAt, sent.id)

The last argument holds what belongs to this one call.

Option
idempotencyKey
Meaning
Sent as the idempotency-key header, so a retry sends nothing twice.
Option
signal
Meaning
An AbortSignal that gives the call up early.

The input and the answer of every method are typed, from the same schemas the API checks them with.

Errors

A call that fails throws OpenSendError. Its code is the one to branch on, status is the HTTP status, message says what is wrong, and requestId finds the request in the logs.

TypeScript
import { OpenSend, OpenSendError } from '@open-send/opensend' const opensend = new OpenSend() try {  await opensend.domains.create({ name: 'mail.example.com' })} catch (error) {  if (!(error instanceof OpenSendError)) throw error  if (error.code === 'domain_taken') {    console.log(error.message, error.status, error.requestId)  }}

The API has its own error codes. The client adds these for what goes wrong before or without an answer, with status set to null.

Code
missing_api_key
Meaning
No key was given to the client, and none is in the environment.
Code
missing_parameter
Meaning
A value the request needs, such as an id, was not given.
Code
network_error
Meaning
The API could not be reached.
Code
timeout
Meaning
The API did not answer in time.
Code
unexpected_response
Meaning
The API answered with something that is not JSON.
Code
invalid_signature
Meaning
The signature of a webhook is missing, too old or wrong.

Webhooks

verifyWebhook checks the signature of a request to your endpoint and returns the event. Webhooks shows a whole handler. The name of the header, opensend-signature, is exported too, as OPENSEND_SIGNATURE_HEADER.

Other languages

TypeScript is the only SDK there is. From any other language, call the API over HTTP: the reference shows every request as cURL, and GET /v1/openapi.json is an OpenAPI document that a generator can turn into a client.

Every method

Emails

What it does
Send email
What it does
Send emails in a batch
What it does
Reschedule email
What it does
Cancel email
What it does
Retrieve email
What it does
List emails

Received emails

What it does
List received emails
What it does
Retrieve received email

Domains

What it does
Add domain
What it does
Verify domain
What it does
Retrieve domain
What it does
List domains
What it does
Update domain
What it does
Delete domain

Templates

What it does
Create template
What it does
Get template
What it does
List templates
What it does
Update template
What it does
Edit template design
What it does
Publish template
What it does
Send test of template
What it does
Render template design
What it does
Duplicate template
What it does
List template versions
What it does
Get template version
What it does
Restore template version
What it does
Delete template
What it does
List template starters
What it does
Get template starter

Images

What it does
Add image
What it does
Upload image
What it does
List images
What it does
Retrieve image
What it does
Delete image

Broadcasts

What it does
Create broadcast
What it does
Update broadcast
What it does
Send broadcast
What it does
Send test of broadcast
What it does
Duplicate broadcast
What it does
Retrieve broadcast
What it does
List broadcasts
What it does
Delete broadcast

Audiences

What it does
Create audience
What it does
List audiences
What it does
Retrieve audience
What it does
Rename audience
What it does
Delete audience
What it does
Add contact to audience
What it does
Remove contact from audience

Contacts

What it does
Add contact
What it does
List contacts
What it does
Retrieve contact
What it does
Update contact
What it does
Delete contact

Contact properties

What it does
Create contact property
What it does
List contact properties
What it does
Retrieve contact property
What it does
Update contact property
What it does
Delete contact property

Topics

What it does
Create topic
What it does
List topics
What it does
Retrieve topic
What it does
Update topic
What it does
Delete topic

Suppressions

What it does
Suppress an address
What it does
List suppressed addresses
What it does
Remove a suppressed address

Automations

What it does
Create automation
What it does
Update automation
What it does
Publish automation
What it does
Pause automation
What it does
Resume automation
What it does
Test automation
What it does
Enrol in automation
What it does
Duplicate automation
What it does
Retrieve automation
What it does
List automations
What it does
Delete automation

Runs

What it does
List runs
What it does
Retrieve run
What it does
Cancel run
What it does
Retry run

Events

What it does
Send event
What it does
Define event
What it does
List events
What it does
Retrieve event
What it does
Update event
What it does
Delete event

Webhooks

What it does
Add webhook
What it does
List webhooks
What it does
Update webhook
What it does
Delete webhook
What it does
Send test event
What it does
List webhook deliveries

Metrics

What it does
Retrieve metrics

Logs

What it does
List logs
What it does
Retrieve log

API keys

What it does
Create API key
What it does
Enroll existing API key
What it does
List API keys
What it does
Revoke API key

Imports

What it does
Look into another account
What it does
Start import
What it does
Retrieve import
What it does
List imports
What it does
Cancel import

Workspace

What it does
Retrieve workspace
What it does
Update workspace
What it does
Close workspace

Members

What it does
Invite member
What it does
List members
What it does
Update member
What it does
Remove member

Billing

What it does
List plans
What it does
Start checkout
What it does
Open billing portal
What it does
List invoices

Server

What it does
Retrieve server settings
What it does
Update server settings

Account

What it does
Retrieve account

Methods

What it does
List methods

Assistant

What it does
Ask the assistant
What it does
List chats
What it does
Retrieve chat
What it does
Keep chat
What it does
Forget chat