# API reference

Every method of the API, with its parameters, its answer and an example that was run before it was printed.

## Requests

Every method is one HTTP request to the API, under `/v1`. The examples write the address as `$OPENSEND_API_URL`, which is `https://api.opensend.sh` on our cloud, and the key as `$OPENSEND_API_KEY`.

- A `GET` or `DELETE` takes its input in the query string.
- A `POST` or `PATCH` takes its input as a JSON object in the body, with `Content-Type: application/json`. Anything else is refused with `body_invalid`.
- A value in braces in a path, such as `{id}`, is part of the address.

cURL:

```bash
curl "$OPENSEND_API_URL/v1/emails?status=bounced&limit=20" \
  -H "Authorization: Bearer $OPENSEND_API_KEY"
```

TypeScript:

```ts
await opensend.emails.list({
  status: 'bounced',
  limit: 20,
})
```

CLI:

```bash
opensend emails list --status bounced --limit 20
```

MCP:

```json
{
  "name": "emails_list",
  "arguments": {
    "status": "bounced",
    "limit": 20
  }
}
```

## Answers

An answer is JSON. Every object says what it is in `object` and carries an `id`. A time is an ISO 8601 string in UTC. A field that has no value is `null` rather than left out. The reference marks the few that can be absent as optional.

| Thing | Id starts with |
| --- | --- |
| Email | `em_` |
| Received email | `in_` |
| Domain | `dom_` |
| Template | `tmpl_` |
| Broadcast | `bc_` |
| Audience | `aud_` |
| Contact | `con_` |
| Automation | `auto_` |
| Webhook | `wh_` |
| Webhook event | `evt_` |
| API key | `key_` |
| Log entry | `log_` |
| Member | `mem_` |
| Workspace | `ws_` |
| Request | `req_` |

A failed request answers with a `4xx` or `5xx` status and an `error` object. [Errors](https://opensend.sh/docs/errors) lists every code.

## Lists and pages

A method that lists things answers with one page of them, newest first. `limit` is how many you get, from 1 to 100, and 25 when you leave it out. `offset` is how many to skip. `q` keeps only what contains a text of up to 40 characters.

emails.list:

```json
{
  "object": "list",
  "data": [
    {
      "object": "email",
      "id": "em_04",
      "from": "Acme <hello@mail.example.com>",
      "to": [
        "margaret@example.net"
      ],
      "subject": "Welcome aboard",
      "status": "bounced",
      "mode": "live",
      "domain": "mail.example.com",
      "cc": [],
      "bcc": [],
      "replyTo": null,
      "scheduledAt": null,
      "createdAt": "2026-11-27T06:30:00.000Z"
    }
  ],
  "total": 1,
  "hasMore": false
}
```

`total` is how many there are in all, and `hasMore` says whether another page follows. To read everything, raise `offset` by `limit` until `hasMore` is `false`.

Some lists take a period: `range` is `today`, `week`, `month`, `year`, `all` or `custom`, and `custom` needs `from` and `to` as dates. The suppression list is the one list with a cursor, explained in [Suppressions](https://opensend.sh/docs/suppressions).

## Safe retries

A read can always be repeated. To repeat a send safely, give it a key of your own in the `idempotency-key` header: a repeat with the same key answers with the first result and sends nothing. [Sending email](https://opensend.sh/docs/sending) has the rules.

## Request ids

Every answer has a `x-request-id` header, and an error repeats it as `requestId`. Send the header yourself and your value is used. Quote it when you report a problem: it finds the request in the server logs.

Requests made with a key are also kept as [log entries](https://opensend.sh/docs/api/logs), with the path, the status and how long each took.

## For tools

- `GET /v1/openapi.json` is the whole API as an OpenAPI document. It needs no key.
- `GET /v1/health` answers when the API is up. It needs no key.
- The [method catalog](https://opensend.sh/docs/api/methods) lists every method with its schemas, as the API itself.

This reference, the OpenAPI document, the SDK, the command line and the MCP tools are all written from the same list of methods, so they cannot disagree.

## Resources

- [Emails](https://opensend.sh/docs/api/emails): Send one email or a batch, schedule it for later, and read what happened to it.
- [Received emails](https://opensend.sh/docs/api/inbound): Mail that arrived on your domains, with its text, its HTML and a list of its files.
- [Domains](https://opensend.sh/docs/api/domains): The domains you send from and receive on, their DNS records and their tracking settings.
- [Templates](https://opensend.sh/docs/api/templates): Emails you keep and reuse. A template has variables, and it is sent in the version you published.
- [Images](https://opensend.sh/docs/api/images): The images of your emails, served from here. One is copied from its address, so it keeps loading when it moves or goes away on its own site, or uploaded as a file.
- [Broadcasts](https://opensend.sh/docs/api/broadcasts): One email for a whole audience, sent now or at a time you choose.
- [Audiences](https://opensend.sh/docs/api/audiences): The lists your broadcasts go to.
- [Contacts](https://opensend.sh/docs/api/contacts): The people of the workspace, each once, with their properties, their audiences and whether they still want your mail.
- [Contact properties](https://opensend.sh/docs/api/contact-properties): The values a contact can hold, such as a plan: each with a type, and a fallback for contacts who have none.
- [Topics](https://opensend.sh/docs/api/topics): The kinds of mail a reader can say yes or no to. A broadcast on a topic only reaches those who get it.
- [Suppressions](https://opensend.sh/docs/api/suppressions): The addresses nothing is sent to, because they bounced, complained or you put them there.
- [Automations](https://opensend.sh/docs/api/automations): Flows that start from a trigger and walk each person through emails, waits and conditions. You edit a copy, and publishing makes it the one that runs.
- [Runs](https://opensend.sh/docs/api/runs): One run for each time a person goes through an automation: where they are, and what every step did.
- [Events](https://opensend.sh/docs/api/events): What your app tells the workspace about a person. An event starts automations, lets waiting runs go on, and can end them.
- [Webhooks](https://opensend.sh/docs/api/webhooks): Addresses of yours that are told, with a signed request, when something happens to an email.
- [Metrics](https://opensend.sh/docs/api/metrics): What you sent, counted by day and by domain, with the rates.
- [Logs](https://opensend.sh/docs/api/logs): The requests your API keys made, each with its answer.
- [API keys](https://opensend.sh/docs/api/api-keys): The keys a program calls this API with.
- [Imports](https://opensend.sh/docs/api/imports): Bring an account over from Resend: its domains, contacts, templates, webhooks and more, with a report of what came and what did not.
- [Workspace](https://opensend.sh/docs/api/workspace): The workspace itself: its name, plan, usage, limits and unsubscribe page.
- [Members](https://opensend.sh/docs/api/members): The people in the workspace and what each one may do.
- [Billing](https://opensend.sh/docs/api/billing): The plans, a checkout for a new plan, the customer portal and the invoices.
- [Server](https://opensend.sh/docs/api/server): The server itself, where a team hosts the product: whether anybody may sign up, and what each workspace on it may use.
- [Account](https://opensend.sh/docs/api/account): Who is calling: the key or the person behind a request, and what it may do.
- [Methods](https://opensend.sh/docs/api/methods): This API described as data: every method with its schemas, for tools that build on it.
- [Assistant](https://opensend.sh/docs/api/ask): Ask about the workspace in plain words. A change it wants to make comes back as a proposal to confirm.
