# REST API Reference

The Receiver.email REST API is available at `https://api.receiver.email/api/v1`. Every endpoint except login and the health check takes a Bearer token.

## Authentication

API requests are authenticated using a Bearer token in the `Authorization` header. You can use either an API key (for SDK/automation) or a JWT access token (for browser sessions).

```bash
curl https://api.receiver.email/api/v1/projects \
  -H "Authorization: Bearer recv_live_your_api_key"
```

An **API key** belongs to one project. It can read that project (with `GET /projects`, which returns only that project, or `GET /projects/:id`), mint addresses, wait for, list, stream, read and delete mail, download attachments, and send a test email to its own project. Everything else needs a dashboard session: a JWT access token from `/auth/otp/verify`. Those endpoints start with **JWT only**, and an API key on one of them gets `403 FORBIDDEN`.

An API key used on another project's routes gets `403 FORBIDDEN`. A dashboard session gets `404 NOT_FOUND` for a project or organization it is not a member of, exactly as if it did not exist. Viewers can read but get `403 FORBIDDEN` on every change.

The login endpoints (`/auth/otp/send`, `/auth/otp/verify`, `/auth/refresh` and `/auth/logout`) take no token and start with **No token needed**. An access token lasts 15 minutes; get a new one with `/auth/refresh`.

GET`/whoami`

Who the credentials belong to. With an API key it returns the key's project, so a client can start from RECEIVER_API_KEY alone.

```bash
curl https://api.receiver.email/api/v1/whoami \
  -H "Authorization: Bearer recv_live_..."
```

Response (API key)

```json
{
  "authType": "apikey",
  "project": {
    "id": "proj_abc",
    "name": "Signup tests",
    "identifier": "a3kx9p2m",
    "emailSuffix": "[email protected]"
  },
  "organizationId": "org_abc123",
  "apiKey": { "id": "key_xyz", "name": "CI Pipeline" }
}
```

Response (JWT)

```json
{ "authType": "jwt", "user": { "id": "[email protected]", "email": "[email protected]" } }
```

POST`/auth/otp/send`

No token needed. Email a 6-digit login code to an address. The code expires in 10 minutes.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `email` | string | The address to log in with (required) |

```bash
curl -X POST https://api.receiver.email/api/v1/auth/otp/send \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'
```

Response (200)

```json
{
  "message": "OTP sent to [email protected]"
}
```

Project inbox addresses (`…[email protected]`) can't sign in: they are `400 INVALID_REQUEST`. Use your own email address.

POST`/auth/otp/verify`

No token needed. Check the login code and start a session. The first login also creates a default organization with you as admin.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `email` | string | The address the code was sent to (required) |
| `code` | string | The 6-digit code (required) |

```bash
curl -X POST https://api.receiver.email/api/v1/auth/otp/verify \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "code": "123456"}'
```

Response (200)

```json
{
  "accessToken": "eyJhbGci...",
  "refreshToken": "eyJhbGci...",
  "user": {
    "id": "[email protected]",
    "email": "[email protected]",
    "createdAt": "2026-10-01T09:00:00.000Z",
    "lastLoginAt": "2026-11-05T09:59:00.000Z"
  },
  "organization": { "id": "org_abc123", "name": "user's organization", "slug": "org-1759309200000", "subscriptionTier": "free", "role": "admin", ... },
  "organizations": [ ... ]
}
```

The access token lasts 15 minutes and the refresh token 30 days. `organization` is the first entry of `organizations`; each has the shape of `GET /organizations/:id`. A wrong or expired code, or too many guesses, is `401 INVALID_OTP`.

POST`/auth/refresh`

No token needed. Exchange a refresh token for a new access token and a new refresh token. Each refresh token works once; reusing an old one signs the session out.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `refreshToken` | string | The refresh token from login or the last refresh (required) |

Response (200)

```json
{ "accessToken": "eyJhbGci...", "refreshToken": "eyJhbGci..." }
```

An invalid, expired, reused or signed-out refresh token is `401 UNAUTHORIZED`: log in again.

GET`/auth/me`

JWT only. The logged-in user and their organizations, with limits and usage.

Response (200)

```json
{
  "user": {
    "id": "[email protected]",
    "email": "[email protected]",
    "createdAt": "2026-10-01T09:00:00.000Z",
    "lastLoginAt": "2026-11-05T09:59:00.000Z"
  },
  "organization": { "id": "org_abc123", "name": "Acme QA", "role": "admin", "limits": { ... }, "usage": { ... }, ... },
  "organizations": [ ... ]
}
```

The same as the login response without the tokens. `organization` is `null` when you belong to none.

POST`/auth/logout`

No token needed. Sign out: revokes the session of the refresh token in the body or, without one, of the access token in the Authorization header. Always returns 204, even for an unknown token.

Body (optional)

| Parameter | Type | Description |
| --- | --- | --- |
| `refreshToken` | string | The session to sign out |

Response (204)

No body.

GET`/auth/sessions`

JWT only. List the devices signed in to your account, most recently used first.

Response (200)

```json
{
  "sessions": [
    {
      "id": "sess_abc",
      "createdAt": "2026-11-01T08:00:00.000Z",
      "lastUsedAt": "2026-11-05T10:00:00.000Z",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ...",
      "current": true
    }
  ]
}
```

`current` marks the session making the request. Signed-out and expired sessions are left out. Not paginated.

POST`/auth/sessions/revoke-others`

JWT only. Sign out every session except the current one.

Response (200)

```json
{ "revoked": 2 }
```

Their refresh tokens stop working at once; access tokens already issued last until they expire, at most 15 minutes.

DELETE`/auth/sessions/:sessionId`

JWT only. Sign out one of your sessions, such as a lost device, by the id from GET /auth/sessions.

```bash
curl -X DELETE https://api.receiver.email/api/v1/auth/sessions/sess_abc   -H "Authorization: Bearer <access_token>"
```

Response (204)

No body.

A session that is already signed out is `204` too. One that does not exist or is not yours is `404 NOT_FOUND`. Signing out the current session works like logout. Access tokens already issued to the session last until they expire, at most 15 minutes.

## Inboxes

An inbox is any address under a project: `{prefix}{emailSuffix}`. Nothing is stored until mail arrives, so there is nothing to create or clean up. Minting addresses through the API guarantees they are unique and well formed.

POST`/projects/:projectId/inboxes`

Mint a new address. Stores nothing. The returned createdAt is the natural since for waiting on it.

Body (optional)

| Parameter | Type | Description |
| --- | --- | --- |
| `prefix` | string | Start of the address. A random 6-character suffix is added (signup becomes signup-k2m9qa). Allowed: a-z, 0-9 and . _ + -, 1 to 40 characters, lowercased. Omitted: inbox- plus 8 random characters. |

```bash
curl -X POST https://api.receiver.email/api/v1/projects/proj_abc/inboxes \
  -H "Authorization: Bearer recv_live_..." \
  -H "Content-Type: application/json" \
  -d '{"prefix": "signup"}'
```

Response (201)

```json
{
  "address": "[email protected]",
  "prefix": "signup-k2m9qa",
  "projectId": "proj_abc",
  "createdAt": "2026-11-05T10:00:00.000Z"
}
```

## Emails

### Email shapes

Every endpoint returns an email in one of four shapes:

- **Summary**: `id`, `projectId`, `sendTo`, `sender`, `subject` and `receivedAt`. The OTP endpoint's `email` and each candidate's.
- **List item**: the summary plus `textBodyPreview`, `hasAttachments`, `attachmentCount`, `size`, `links` and `otp`. Each email of the list, the stream's `email`, and wait's `email`, which adds `textBody`.
- **Detail**: everything, from `GET /projects/:projectId/emails/:emailId`: both bodies, headers and attachments.
- **Webhook payload**: the summary plus `links` and `textBodyPreview`, sent as `data.email` with `data.otp` beside it.

`otp` is the code the OTP endpoint would extract with no `codeLength`, or `null`.

GET`/projects/:projectId/emails`

List a project's emails, newest first, with optional filters. Paged with cursor.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `recipient` | string | Only mail to this address (exact match, case-insensitive) |
| `sender` | string | Only mail from this address (exact match) |
| `subject` | string | Subject contains this text (case-insensitive) |
| `hasAttachments` | boolean | true for only mail with attachments, false for only mail without |
| `since` | ISO 8601 | Only mail received strictly after this time. receivedAfter is accepted as an alias. |
| `receivedBefore` | ISO 8601 | Only mail received at or before this time |
| `limit` | number | Emails per page, 1 to 100 (default 50) |
| `cursor` | string | The nextCursor of the previous page |

```bash
curl "https://api.receiver.email/api/v1/projects/proj_abc/[email protected]&limit=10" \
  -H "Authorization: Bearer recv_live_..."
```

Response (200)

```json
{
  "emails": [
    {
      "id": "email_xyz789",
      "projectId": "proj_abc",
      "sendTo": "[email protected]",
      "sender": "[email protected]",
      "subject": "Reset your password",
      "textBodyPreview": "Click the link below to reset...",
      "hasAttachments": false,
      "attachmentCount": 0,
      "size": 2048,
      "receivedAt": "2026-01-15T10:30:00.000Z",
      "links": ["https://example.com/reset?token=abc123"],
      "otp": null
    }
  ],
  "hasMore": true,
  "nextCursor": "email_xyz789"
}
```

`nextCursor` is present only when `hasMore` is true. With `subject` or `hasAttachments`, a page can hold fewer than `limit` emails, even none, while `hasMore` is true: keep following `nextCursor`. An invalid date or cursor is `400 INVALID_REQUEST`. Each email is a list item: `textBodyPreview` is the first 500 characters of the text body, and `otp` is the code the OTP endpoint would extract, or `null`.

### The `since` parameter

The list, `wait`, `otp` and `stream` take `since`, an ISO 8601 timestamp. They match only mail whose `receivedAt` is **strictly after** it. Wait from an inbox's `createdAt` for its first email, and from the last email's `receivedAt` for the next one. When omitted, `wait` and `otp` look back 60 seconds, `stream` starts from now and the list has no lower bound. `receivedAfter` is accepted as an alias everywhere; when both are given, `since` wins.

GET`/projects/:projectId/emails/wait`

Long-poll for an email. The server holds the request until a matching email arrives or the timeout expires. Both outcomes return 200; a timeout is not an error.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `recipient` | string | Only mail to this address |
| `sender` | string | Only mail from this address |
| `subject` | string | Subject contains this text (case-insensitive) |
| `since` | ISO 8601 | Only mail received strictly after this time (default: now minus 60 seconds). receivedAfter is accepted as an alias. |
| `timeout` | number | Seconds to wait (default 30, max 60) |

```bash
curl "https://api.receiver.email/api/v1/projects/proj_abc/emails/[email protected]&since=2026-11-05T10:00:00.000Z&timeout=60" \
  -H "Authorization: Bearer recv_live_..."
```

Response: received

```json
{
  "status": "received",
  "email": {
    "id": "email_xyz789",
    "projectId": "proj_abc",
    "sendTo": "[email protected]",
    "sender": "[email protected]",
    "subject": "Your Acme code",
    "receivedAt": "2026-11-05T10:00:04.120Z",
    "textBodyPreview": "Your verification code is 847291...",
    "hasAttachments": false,
    "attachmentCount": 0,
    "size": 2048,
    "links": ["https://acme.example/verify?token=abc123"],
    "otp": { "code": "847291", "codeLength": 6, "source": "body" },
    "textBody": "Your verification code is 847291..."
  }
}
```

Response: timeout

```json
{ "status": "timeout", "since": "2026-11-05T10:00:00.000Z", "waitedSeconds": 60, "retry": true }
```

`email` is a list item plus `textBody`; get the email by id for its HTML, headers and attachments. On a timeout, call again with the same `since`. The SDKs loop for you, so their `timeout` can be any length.

GET`/projects/:projectId/emails/otp`

Extract a verification code (4 to 8 digits, with or without separators, or alphanumeric) from matching emails, from the subject or the body. Scans up to 10 matching emails, newest first. Waits only if you pass a timeout.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `recipient, sender, subject, since` | | The same filters as wait. since defaults to now minus 60 seconds, so an old code never matches. |
| `receivedBefore` | ISO 8601 | Only mail received at or before this time |
| `codeLength` | number | Only codes of this length, 4 to 8. Without it, 5 and 7 digit codes are not found. |
| `timeout` | number | Seconds to wait for a code (default 0: answer now; max 60) |

```bash
curl "https://api.receiver.email/api/v1/projects/proj_abc/emails/[email protected]&since=2026-11-05T10:00:00.000Z&timeout=60" \
  -H "Authorization: Bearer recv_live_..."
```

Response: found

```json
{
  "status": "found",
  "code": "847291",
  "codeLength": 6,
  "source": "subject",
  "email": {
    "id": "email_xyz789",
    "projectId": "proj_abc",
    "sendTo": "[email protected]",
    "sender": "[email protected]",
    "subject": "Your Acme code is 847291",
    "receivedAt": "2026-11-05T10:00:04.120Z"
  },
  "candidates": [
    { "code": "847291", "codeLength": 6, "source": "subject", "email": { "id": "email_xyz789", ... } }
  ]
}
```

`code` is the newest code. `candidates` lists every code found in the matching emails, newest first. When nothing is found the response is the same `{ "status": "timeout", ... }` as wait.

GET`/projects/:projectId/emails/stream`

Server-Sent Events: every new email as it arrives, oldest first. The server ends the stream after 55 seconds; reconnect with the since it sends.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `recipient` | string | Only mail to this address |
| `sender` | string | Only mail from this address (exact match) |
| `subject` | string | Subject contains this text (case-insensitive) |
| `since` | ISO 8601 | Only mail received strictly after this time (default: now). receivedAfter is accepted as an alias. |

```bash
curl -N "https://api.receiver.email/api/v1/projects/proj_abc/emails/[email protected]" \
  -H "Authorization: Bearer recv_live_..."
```

Events

```
event: email
id: email_xyz789
data: {"email": {"id": "email_xyz789", "projectId": "proj_abc", "sender": "[email protected]", "subject": "Your Acme code", "receivedAt": "2026-11-05T10:00:04.120Z", "textBodyPreview": "Your verification code is 847291...", "links": [...], "otp": {...}, ...}, "otp": {"code": "847291", "codeLength": 6, "source": "body"}}

: ping

event: end
data: {"since": "2026-11-05T10:00:04.120Z"}
```

`email` is a list item. A `: ping` comment arrives every 15 seconds. `otp` is `null` when the email has no code. The SDKs' `stream()` reconnects for you.

GET`/projects/:projectId/emails/:emailId`

Get one email with its text and HTML bodies, headers, links, OTP code and attachment list.

```bash
curl https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789 \
  -H "Authorization: Bearer recv_live_..."
```

Response (200)

```json
{
  "id": "email_xyz789",
  "projectId": "proj_abc",
  "sendTo": "[email protected]",
  "recipient": "[email protected]",
  "sender": "[email protected]",
  "subject": "Your Acme code",
  "textBody": "Your verification code is 847291.\n\nOr verify here: https://acme.example/verify?token=abc123",
  "htmlBody": "<p>Your verification code is <b>847291</b>.</p><p><a href=\"https://acme.example/verify?token=abc123\">Verify</a></p>",
  "textBodyPreview": "Your verification code is 847291.\n\nOr verify here: https://acme.example/verify?token=abc123",
  "htmlBodyPreview": "<p>Your verification code is <b>847291</b>.</p><p><a href=\"https://acme.example/verify?token=abc123\">Verify</a></p>",
  "hasAttachments": true,
  "attachmentCount": 2,
  "omittedAttachmentCount": 1,
  "links": ["https://acme.example/verify?token=abc123"],
  "otp": { "code": "847291", "codeLength": 6, "source": "body" },
  "attachments": [
    { "filename": "invoice.pdf", "contentType": "application/pdf", "size": 48213, "url": "https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789/attachments/0" },
    { "filename": "recording.mov", "contentType": "video/quicktime", "size": 6291456, "omitted": "too_large" }
  ],
  "receivedAt": "2026-11-05T10:00:04.120Z",
  "processedAt": "2026-11-05T10:00:04.290Z",
  "size": 8441856,
  "headers": { "message-id": "<[email protected]>", "date": "2026-11-05T10:00:03.000Z", ... }
}
```

Bodies larger than 100,000 characters are stored separately. Then `textBody` or `htmlBody` holds only a preview (the first 500 characters) and `textBodyUri` or `htmlBodyUri` is set to the URL of the full body: `/text` or `/html` below. Like each attachment's `url`, these are API URLs: request them with the same `Authorization` header. They are not links a browser can open on its own.

`recipient` is a deprecated alias of `sendTo`; read `sendTo`.

An attachment larger than your plan allows is listed with `"omitted": "too_large"` and no `url`. It counts in `attachmentCount` and `omittedAttachmentCount`, and cannot be downloaded. `otp` is `null` when the email has no code.

GET`/projects/:projectId/emails/:emailId/text`

The full plain text body, whatever its size, as Content-Type: text/plain; charset=utf-8.

```bash
curl https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789/text \
  -H "Authorization: Bearer recv_live_..."
```

Response (200, text/plain)

```
Your verification code is 847291.

Or verify here: https://acme.example/verify?token=abc123
```

An email without a text part returns an empty body.

GET`/projects/:projectId/emails/:emailId/html`

The full HTML body, whatever its size, as Content-Type: text/html; charset=utf-8. It is served with a restrictive Content-Security-Policy, so opening it in a browser cannot run scripts.

Response headers (200)

```
Content-Type: text/html; charset=utf-8
Content-Security-Policy: default-src 'none'; img-src * data:; style-src 'unsafe-inline'
```

Images and inline styles load; scripts, frames, fonts and external stylesheets do not. An email without an HTML part returns an empty body.

GET`/projects/:projectId/emails/:emailId/raw`

The original message exactly as received (RFC 822), as Content-Type: message/rfc822. Use it to check headers, MIME structure or signatures.

```bash
curl https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789/raw \
  -H "Authorization: Bearer recv_live_..." -o message.eml
```

Response (200, message/rfc822)

```
From: Acme <[email protected]>
To: [email protected]
Subject: Your Acme code
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="b1"
...
```

GET`/projects/:projectId/emails/:emailId/attachments/:index`

Download one attachment by its position in the email's attachments list (0-based). The response is the file itself, not JSON.

Path Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `index` | number | Position in the attachments list of GET /emails/:emailId, starting at 0 |

```bash
curl https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789/attachments/0 \
  -H "Authorization: Bearer recv_live_..." -o invoice.pdf
```

Response headers (200)

```
Content-Type: application/pdf
Content-Disposition: attachment; filename*=UTF-8''invoice.pdf
```

`Content-Type` is the attachment's own type (`application/octet-stream` when unknown), and the file name is URL-encoded. An index that is not a whole number or is out of range is `404 NOT_FOUND`. An attachment larger than your plan allows was not stored: `410 ATTACHMENT_NOT_STORED`.

DELETE`/projects/:projectId/emails/:emailId`

Delete an email permanently, including its stored raw message, bodies and attachments.

```bash
curl -X DELETE https://api.receiver.email/api/v1/projects/proj_abc/emails/email_xyz789 \
  -H "Authorization: Bearer recv_live_..."
```

Response (204)

No body.

Dashboard viewers get `403 FORBIDDEN`.

POST`/projects/:projectId/test-email`

Send a test email to one of the project's own addresses, to check the whole path end to end. The subject and body carry a random 6-digit code. Limited to 10 per project per hour (429 after that).

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `to` | string | The address to send to (required). Must end with the project's emailSuffix. |

```bash
curl -X POST https://api.receiver.email/api/v1/projects/proj_abc/test-email \
  -H "Authorization: Bearer recv_live_..." \
  -H "Content-Type: application/json" \
  -d '{"to": "[email protected]"}'
```

Response (202)

```json
{ "to": "[email protected]", "sentAt": "2026-11-05T10:00:00.000Z" }
```

A `to` outside the project is `400 INVALID_REQUEST`. Dashboard viewers get `403 FORBIDDEN`. If the email cannot be sent, the API returns `502 EMAIL_SEND_FAILED`.

## Webhooks

A webhook posts every new email to your endpoint as soon as it is stored. A project can have up to 5. Managing them is **JWT only**: use the dashboard, or a dashboard session token.

POST`/projects/:projectId/webhooks`

JWT only. Create a webhook. The url must be https (http://localhost is allowed outside production). The signing secret is returned once, in this response.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `url` | string | Where to send events (required, at most 2048 characters, no credentials in the URL) |
| `events` | string[] | Events to send (default ["email.received"], currently the only event) |

```bash
curl -X POST https://api.receiver.email/api/v1/projects/proj_abc/webhooks \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/receiver", "events": ["email.received"]}'
```

Response (201)

```json
{
  "id": "wh_abc",
  "url": "https://example.com/hooks/receiver",
  "events": ["email.received"],
  "secret": "whsec_...",
  "createdAt": "2026-11-05T10:00:00.000Z"
}
```

A sixth webhook is `403 LIMIT_REACHED`. Viewers get `403 FORBIDDEN`.

GET`/projects/:projectId/webhooks`

JWT only. List webhooks, newest first, with their last delivery time and status. Secrets are returned only when a webhook is created or its secret is rotated.

Response (200)

```json
{
  "webhooks": [
    {
      "id": "wh_abc",
      "url": "https://example.com/hooks/receiver",
      "events": ["email.received"],
      "createdAt": "2026-11-05T10:00:00.000Z",
      "lastDeliveryAt": "2026-11-05T10:00:04.300Z",
      "lastStatus": "succeeded"
    }
  ]
}
```

`lastDeliveryAt` and `lastStatus` appear after the first delivery.

GET`/projects/:projectId/webhooks/:webhookId`

JWT only. Get one webhook, in the same shape as in the list, without its secret.

Response (200)

```json
{
  "id": "wh_abc",
  "url": "https://example.com/hooks/receiver",
  "events": ["email.received"],
  "createdAt": "2026-11-05T10:00:00.000Z",
  "lastDeliveryAt": "2026-11-05T10:00:04.300Z",
  "lastStatus": "succeeded"
}
```

PATCH`/projects/:projectId/webhooks/:webhookId`

JWT only. Change a webhook's url, its events or both. The signing secret and the delivery history stay.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `url` | string | New URL, with the same rules as on create |
| `events` | string[] | New events, with the same rules as on create |

```bash
curl -X PATCH https://api.receiver.email/api/v1/projects/proj_abc/webhooks/wh_abc   -H "Authorization: Bearer <access_token>"   -H "Content-Type: application/json"   -d '{"url": "https://example.com/hooks/receiver-v2"}'
```

Response (200)

The updated webhook, in the shape of `GET /projects/:projectId/webhooks/:webhookId`.

A body with neither field is `400 INVALID_REQUEST`. Viewers get `403 FORBIDDEN`.

POST`/projects/:projectId/webhooks/:webhookId/rotate-secret`

JWT only. Replace the webhook's signing secret. The new secret is returned once, in this response, and signs every new delivery from now on.

Response (200)

```json
{
  "id": "wh_abc",
  "url": "https://example.com/hooks/receiver",
  "events": ["email.received"],
  "createdAt": "2026-11-05T10:00:00.000Z",
  "lastDeliveryAt": "2026-11-05T10:00:04.300Z",
  "lastStatus": "succeeded",
  "secret": "whsec_..."
}
```

Retries of a delivery already under way (about 12 seconds at most) still use the old secret. Deploy the new one to your receiver promptly: deliveries it rejects in the meantime are not sent again. Viewers get `403 FORBIDDEN`.

DELETE`/projects/:projectId/webhooks/:webhookId`

JWT only. Delete a webhook. No more events are sent to it.

Response (204)

No body.

POST`/projects/:projectId/webhooks/:webhookId/test`

JWT only. Send a sample email.received event to the webhook, with one attempt, and return the delivery.

Response (200)

```json
{
  "id": "dlv_abc",
  "eventId": "evt_test_3f9a1c2b7d4e5f60",
  "status": "succeeded",
  "statusCode": 200,
  "attempts": 1,
  "createdAt": "2026-11-05T10:05:00.000Z"
}
```

A failed delivery is still a `200` response, with `"status": "failed"` and an `error` such as `HTTP 500`. It is recorded in the delivery log like any other.

GET`/projects/:projectId/webhooks/:webhookId/deliveries`

JWT only. The last 50 deliveries, newest first: event id, succeeded or failed, status code, attempts and error. Deliveries are kept for 30 days.

Response (200)

```json
{
  "deliveries": [
    {
      "id": "dlv_abd",
      "eventId": "evt_email_xyz789",
      "status": "failed",
      "statusCode": 500,
      "attempts": 3,
      "createdAt": "2026-11-05T10:00:16.400Z",
      "error": "HTTP 500"
    }
  ]
}
```

`statusCode` is absent when your endpoint never answered (for example a timeout). `error` is absent when the delivery succeeded.

### The delivery

Each email is sent as a `POST` with a JSON body, whose `data.email` is the webhook payload shape (see [Email shapes](#email-shapes)), and these headers:

- `Receiver-Event-Id`: `evt_<emailId>`, the same on every retry. Use it to ignore duplicates.
- `Receiver-Signature`: `t=<unix seconds>,v1=<hex HMAC-SHA256>`
- `User-Agent`: `receiver-webhooks/1`

```json
{
  "id": "evt_email_xyz789",
  "type": "email.received",
  "createdAt": "2026-11-05T10:00:04.300Z",
  "data": {
    "email": {
      "id": "email_xyz789",
      "projectId": "proj_abc",
      "sendTo": "[email protected]",
      "sender": "[email protected]",
      "subject": "Your Acme code",
      "receivedAt": "2026-11-05T10:00:04.120Z",
      "links": ["https://acme.example/verify?token=abc123"],
      "textBodyPreview": "Your verification code is 847291..."
    },
    "otp": { "code": "847291", "codeLength": 6, "source": "body" }
  }
}
```

Respond with any 2xx status. Anything else, or no answer within 10 seconds, is retried: 3 attempts in all, immediately, after 2 seconds and after 10 seconds.

### Verifying the signature

The signature is an HMAC-SHA256 of `<t>.<raw body>` with your webhook secret. Compute it over the raw request body (before JSON parsing), compare in constant time, and reject old timestamps to stop replays.

```typescript
import crypto from "node:crypto";

export function verifyReceiverSignature(rawBody: string, header: string, secret: string) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false; // 5 minute tolerance

  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "", "hex");
  const wanted = Buffer.from(expected, "hex");
  return given.length === wanted.length && crypto.timingSafeEqual(given, wanted);
}

// Express: keep the raw body for this route
app.post("/hooks/receiver", express.raw({ type: "application/json" }), (req, res) => {
  const raw = req.body.toString("utf8");
  if (!verifyReceiverSignature(raw, req.get("Receiver-Signature") ?? "", process.env.RECEIVER_WEBHOOK_SECRET!)) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(raw);
  console.log(event.data.otp?.code);
  res.sendStatus(204);
});
```

```python
import hashlib, hmac, time

def verify_receiver_signature(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t = int(parts.get("t", "0"))
    if abs(time.time() - t) > 300:  # 5 minute tolerance
        return False
    signed = f"{t}.".encode() + raw_body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))
```

## Projects

GET`/projects`

List projects, newest first. With a JWT, the projects of one organization; with an API key, only the key's own project. Not paginated.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `organizationId` | string | The organization to list (required with a JWT, 400 without it; ignored with an API key) |

```bash
curl "https://api.receiver.email/api/v1/projects?organizationId=org_abc123" \
  -H "Authorization: Bearer <access_token>"
```

Response (200)

```json
{
  "projects": [
    {
      "id": "proj_abc",
      "organizationId": "org_abc123",
      "name": "Signup tests",
      "identifier": "a3kx9p2m",
      "emailSuffix": "[email protected]",
      "createdAt": "2026-11-01T09:00:00.000Z"
    }
  ]
}
```

POST`/projects`

JWT only. Create a new project. The identifier in its addresses is generated for you.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `organizationId` | string | The organization to create it in (required) |
| `name` | string | Project name, 1 to 100 characters (required) |

```bash
curl -X POST https://api.receiver.email/api/v1/projects \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"organizationId": "org_abc123", "name": "CI Tests"}'
```

Response (201)

```json
{
  "id": "proj_new123",
  "organizationId": "org_abc123",
  "name": "CI Tests",
  "identifier": "b7kx2m9n",
  "emailSuffix": "[email protected]",
  "createdAt": "2026-01-15T10:00:00.000Z"
}
```

Viewers get `403 FORBIDDEN`. An organization at its plan's project limit gets `403 LIMIT_REACHED` with `"details": { "limit": "projects", "max": 1 }`.

GET`/projects/:id`

Get one project, with the number of emails it holds.

```bash
curl https://api.receiver.email/api/v1/projects/proj_abc \
  -H "Authorization: Bearer recv_live_..."
```

Response (200)

```json
{
  "id": "proj_abc",
  "organizationId": "org_abc123",
  "name": "Signup tests",
  "identifier": "a3kx9p2m",
  "emailSuffix": "[email protected]",
  "createdAt": "2026-11-01T09:00:00.000Z",
  "stats": { "emailsTotal": 42 }
}
```

`stats.emailsTotal` counts the emails stored in the project now, within your plan's retention. An API key gets `403 FORBIDDEN` for any other project, and a dashboard session outside the project's organization gets `404 NOT_FOUND`.

PATCH`/projects/:id`

JWT only. Rename a project. Its identifier and addresses do not change.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `name` | string | New name, 1 to 100 characters (required) |

Response (200)

```json
{
  "id": "proj_abc",
  "organizationId": "org_abc123",
  "name": "Signup and reset tests",
  "identifier": "a3kx9p2m",
  "emailSuffix": "[email protected]",
  "createdAt": "2026-11-01T09:00:00.000Z"
}
```

Viewers get `403 FORBIDDEN`.

DELETE`/projects/:id`

JWT only. Delete a project with all its emails, API keys, webhooks and stored files. This cannot be undone.

Response (204)

No body.

Viewers get `403 FORBIDDEN`.

## Organizations

GET`/organizations`

JWT only. List the organizations you belong to, with your role in each. Not paginated.

Response (200)

```json
{
  "organizations": [
    { "id": "org_abc123", "name": "Acme QA", "slug": "acme-qa", "subscriptionTier": "free", "limits": { ... }, "usage": { ... }, "role": "admin", ... }
  ]
}
```

Each organization has the shape of `GET /organizations/:id`.

POST`/organizations`

JWT only. Create a new organization on the free plan, with you as admin.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `name` | string | Organization name, 1 to 100 characters (required) |
| `slug` | string | Unique URL name: lowercase letters and digits, words joined by single hyphens (required) |

Response (201)

The new organization, in the shape of `GET /organizations/:id`, with `"role": "admin"`.

A slug already in use is `409 CONFLICT`. Each account includes one free organization, normally the one made at first sign-in. Another organization needs the first one on a paid plan (see Billing below); until then the answer is `403 LIMIT_REACHED`.

GET`/organizations/:id`

JWT only. Get an organization with its plan limits, usage this month and your role. Anyone who is not a member gets 404.

Response (200)

```json
{
  "id": "org_abc123",
  "name": "Acme QA",
  "slug": "acme-qa",
  "subscriptionTier": "free",
  "subscriptionStatus": "active",
  "createdAt": "2026-10-01T09:00:00.000Z",
  "limits": {
    "emailsPerMonth": 500,
    "retentionDays": 7,
    "maxProjects": 1,
    "maxAttachmentSizeMB": 5,
    "apiRequestsPerMinute": 60,
    "maxMembers": 1
  },
  "usage": {
    "emailsThisMonth": 42,
    "emailsDroppedThisMonth": 0,
    "apiRequestsThisMonth": 0,
    "resetAt": "2026-12-01T00:00:00.000Z"
  },
  "role": "admin"
}
```

`emailsDroppedThisMonth` counts mail that arrived after the plan's cap was reached: the monthly limit on Free, 125% of it on paid plans. It is accepted (senders get no bounce) but not stored.

PATCH`/organizations/:id`

JWT only. Rename an organization or change its slug. Admins only.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `name` | string | New name, 1 to 100 characters (optional) |
| `slug` | string | New slug, same rules as on create (optional) |

Response (200)

The updated organization, in the shape of `GET /organizations/:id`. A slug already in use is `409 CONFLICT`.

GET`/organizations/:id/members`

JWT only. List members and their roles, oldest first. Not paginated.

Response (200)

```json
{
  "members": [
    { "userId": "[email protected]", "email": "[email protected]", "role": "admin", "joinedAt": "2026-10-01T09:00:00.000Z" },
    { "userId": "[email protected]", "email": "[email protected]", "role": "member", "joinedAt": "2026-11-05T11:00:00.000Z" }
  ]
}
```

A user ID is the member's email address.

PATCH`/organizations/:id/members/:userId`

JWT only. Change a member's role. Admins only. An organization always keeps at least one admin.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `role` | string | admin, member or viewer (required) |

Response (200)

```json
{ "userId": "[email protected]", "email": "[email protected]", "role": "viewer", "joinedAt": "2026-11-05T11:00:00.000Z" }
```

Demoting the last admin is `409 CONFLICT`.

DELETE`/organizations/:id/members/:userId`

JWT only. Remove a member (admins), or leave the organization by passing your own user ID.

Response (204)

No body.

Removing the last admin, yourself included, is `409 CONFLICT`.

POST`/organizations/:id/invitations`

JWT only. Invite someone by email with a role. They log in with that address and accept. Admins only. The Free plan has one seat, so there it answers 403 LIMIT_REACHED; paid plans have no member limit.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `email` | string | The address to invite (required) |
| `role` | string | admin, member or viewer (default member) |

```bash
curl -X POST https://api.receiver.email/api/v1/organizations/org_abc123/invitations \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "role": "member"}'
```

Response (201)

```json
{
  "id": "inv_abc",
  "organizationId": "org_abc123",
  "email": "[email protected]",
  "role": "member",
  "status": "pending",
  "invitedBy": "[email protected]",
  "createdAt": "2026-11-05T10:00:00.000Z",
  "expiresAt": "2026-11-12T10:00:00.000Z"
}
```

The invitation expires after 7 days. Inviting a member, or an address with a pending invitation, is `409 CONFLICT`; going over the plan's member limit, which counts pending invitations, is `403 LIMIT_REACHED`.

GET`/organizations/:id/invitations`

JWT only. List pending invitations that have not expired. Admins only. Not paginated.

Response (200)

```json
{
  "invitations": [
    {
      "id": "inv_abc",
      "organizationId": "org_abc123",
      "email": "[email protected]",
      "role": "member",
      "status": "pending",
      "invitedBy": "[email protected]",
      "createdAt": "2026-11-05T10:00:00.000Z",
      "expiresAt": "2026-11-12T10:00:00.000Z"
    }
  ]
}
```

DELETE`/organizations/:id/invitations/:invitationId`

JWT only. Revoke a pending invitation. Admins only.

Response (204)

No body.

An invitation that is not pending (already accepted, declined or revoked) is `404 NOT_FOUND`.

GET`/invitations`

JWT only. List the pending invitations addressed to your email, from any organization. Not paginated.

Response (200)

```json
{
  "invitations": [
    {
      "id": "inv_abc",
      "organizationId": "org_abc123",
      "organizationName": "Acme QA",
      "email": "[email protected]",
      "role": "member",
      "status": "pending",
      "invitedBy": "[email protected]",
      "createdAt": "2026-11-05T10:00:00.000Z",
      "expiresAt": "2026-11-12T10:00:00.000Z"
    }
  ]
}
```

POST`/invitations/:invitationId/accept`

JWT only. Join the organization with the invited role. Use /decline to refuse.

Response (200)

```json
{ "organizationId": "org_abc123", "role": "member", "status": "accepted" }
```

An invitation addressed to someone else is `404 NOT_FOUND`; one that expired or was already answered or revoked is `409 CONFLICT`.

POST`/invitations/:invitationId/decline`

JWT only. Refuse an invitation. You do not join the organization, and the invitation stops being pending.

Response (200)

```json
{ "organizationId": "org_abc123", "role": "member", "status": "declined" }
```

The same errors as accept.

GET`/organizations/:id/audit-log`

JWT only. Who changed what in the organization: projects, API keys, webhooks, members, invitations and settings. Newest first, paged with cursor. Admins only.

Query Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `limit` | number | Entries per page, 1 to 100 (default 50) |
| `cursor` | string | The nextCursor of the previous page |

Response (200)

```json
{
  "entries": [
    {
      "id": "log_abc",
      "action": "api_key.created",
      "actor": { "type": "user", "id": "[email protected]", "email": "[email protected]" },
      "target": { "type": "api_key", "id": "key_xyz", "name": "CI Pipeline" },
      "details": { "projectId": "proj_abc" },
      "createdAt": "2026-11-05T10:00:00.000Z"
    }
  ],
  "hasMore": true,
  "nextCursor": "log_abc"
}
```

`action` is one of organization.created, organization.updated, project.created, project.renamed, project.deleted, api_key.created, api_key.revoked, webhook.created, webhook.updated, webhook.secret_rotated, webhook.deleted, member.role_changed, member.removed, member.left, invitation.created, invitation.revoked, invitation.accepted, invitation.declined, billing.checkout_started, billing.cancelled, billing.resumed and billing.withdrawn, plus billing.subscribed, billing.plan_changed, billing.plan_updated, billing.payment_failed and billing.ended, whose actor is `{ "type": "system", "id": "stripe" }`. `details` is present only for some actions. For webhook.updated it holds what changed: `{ "url": { "from", "to" } }`, `{ "events": { "from", "to" } }` or both.

### Billing

Paid plans are sold through Stripe. These endpoints are for dashboard sessions; everyone in the organization can read the plan, and admins change it. Amounts are in cents, VAT included where it applies.

GET`/organizations/:id/billing`

JWT only. The plan, the prices on sale and the subscription, if any. Every billing change answers with this same shape.

Response (200)

```json
{
  "available": true,
  "plan": "pro",
  "managedByContract": false,
  "canManage": true,
  "prices": [{ "plan": "pro", "interval": "month", "amount": 6900, "currency": "usd" }, ...],
  "subscription": {
    "plan": "pro",
    "interval": "month",
    "status": "active",
    "amount": 6900,
    "currency": "usd",
    "startedAt": "2026-11-23T12:00:00.000Z",
    "currentPeriodEnd": "2026-12-23T12:00:00.000Z",
    "cancelAt": null,
    "startsAt": null,
    "customerType": "business",
    "withdrawal": { "available": true, "deadline": "2026-12-07T23:59:59.000Z" },
    "cancellation": null
  },
  "lastWithdrawal": null,
  "portal": true
}
```

`available` is false where Stripe isn't set up; paid plans are then arranged by email. `status` is Stripe's. `customerType` is what the buyer answered on Stripe's checkout page; `withdrawal` applies to consumers only.

POST`/organizations/:id/billing/checkout`

JWT only, admins. Opens Stripe Checkout for a paid plan and returns its URL. Stripe's page asks whether it's a business purchase (with the VAT number) and has one required box to accept the Terms and start right away. The plan starts when Stripe confirms the payment.

Request Body

| Parameter | Type | Description |
| --- | --- | --- |
| `plan` | string | starter or pro |
| `interval` | string | month or year |
| `termsVersion` | string | Optional: the version of the Terms the dashboard links to, recorded with the order |

Response (201)

```json
{ "url": "https://checkout.stripe.com/c/pay/cs_..." }
```

POST`/organizations/:id/billing/cancel`

JWT only, admins. Ends the plan at the end of the paid period and confirms by email. A consumer's yearly plan that renewed ends after one month instead, with the rest refunded.

POST`/organizations/:id/billing/resume`

JWT only, admins. Undoes a cancellation before it takes effect (not one that came with a refund).

POST`/organizations/:id/billing/withdraw`

JWT only, admins. A consumer's withdrawal within 14 days: ends the plan now, refunds what was paid minus the days used, and confirms by email with the date and time it was received. Body: { "confirm": true }.

POST`/organizations/:id/billing/portal`

JWT only, admins. Returns the URL of Stripe's billing portal: switching plan or billing interval (charged or credited right away), payment method, invoices, billing address and VAT ID.

Request Body

| Parameter | Type | Description |
| --- | --- | --- |
| `flow` | string | Optional: change_plan opens the portal on its plan-switch screen (409 while the plan is set to end) |

Response (201)

```json
{ "url": "https://billing.stripe.com/p/session/..." }
```

## API Keys

GET`/projects/:projectId/api-keys`

JWT only. List the project's API keys, newest first. Only a short prefix of each key is shown, and revoked keys are left out. Not paginated.

Response (200)

```json
{
  "apiKeys": [
    {
      "id": "key_xyz",
      "name": "CI Pipeline",
      "keyPrefix": "recv_live_k3x",
      "createdAt": "2026-11-05T10:00:00.000Z",
      "lastUsedAt": "2026-11-05T10:12:00.000Z",
      "expiresAt": null
    }
  ]
}
```

`lastUsedAt` is absent until the key is first used. `expiresAt` is `null` for a key that never expires.

POST`/projects/:projectId/api-keys`

JWT only. Create a new API key for the project. The full key is only returned in this response.

Body

| Parameter | Type | Description |
| --- | --- | --- |
| `name` | string | A label for the key, 1 to 100 characters (required) |
| `expiresAt` | ISO 8601 | When the key stops working (optional). Must be in the future and at most 365 days ahead. Omitted or null: never expires. Anything else is 400. |

```bash
curl -X POST https://api.receiver.email/api/v1/projects/proj_abc/api-keys \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "CI Pipeline", "expiresAt": "2027-05-01T00:00:00.000Z"}'
```

Response (201)

```json
{
  "id": "key_xyz",
  "key": "recv_live_k3x...",
  "name": "CI Pipeline",
  "keyPrefix": "recv_live_k3x",
  "createdAt": "2026-11-05T10:00:00.000Z",
  "expiresAt": "2027-05-01T00:00:00.000Z"
}
```

Store `key` now: it is shown only once. After `expiresAt` the key is rejected with `401 UNAUTHORIZED`. Viewers get `403 FORBIDDEN`.

GET`/projects/:projectId/api-keys/:keyId`

JWT only. Get one API key's metadata, including when it was last used, when it expires and whether it was revoked.

Response (200)

```json
{
  "id": "key_xyz",
  "name": "CI Pipeline",
  "keyPrefix": "recv_live_k3x",
  "createdAt": "2026-11-05T10:00:00.000Z",
  "lastUsedAt": "2026-11-05T10:12:00.000Z",
  "expiresAt": "2027-05-01T00:00:00.000Z",
  "revokedAt": "2026-11-20T08:00:00.000Z"
}
```

Unlike the list, this also returns revoked keys. `revokedAt` is present only on a revoked key.

DELETE`/projects/:projectId/api-keys/:keyId`

JWT only. Revoke an API key. It stops working immediately: requests with it get 401.

Response (204)

No body.

Revoking a key that is already revoked is `204` too. Viewers get `403 FORBIDDEN`.

## Error Codes

| HTTP Status | Error Code | Description |
| --- | --- | --- |
| 400 | `INVALID_REQUEST` | Missing or malformed parameters, a body that is not valid JSON, or an invalid date or cursor |
| 401 | `UNAUTHORIZED` | Missing, invalid or expired token or API key (a revoked or expired API key too) |
| 401 | `INVALID_OTP` | Wrong or expired login code, or too many attempts |
| 403 | `FORBIDDEN` | An API key on a JWT-only endpoint or on another project, or a role that cannot do this (viewers are read-only; some actions are admins only) |
| 403 | `LIMIT_REACHED` | A limit of the plan or the product: projects, webhooks per project, members (pending invitations count) or free organizations per account. details is { limit, max }, with limit one of projects, webhooks, members or free_organizations. |
| 404 | `NOT_FOUND` | The resource does not exist, or it belongs to an organization you are not a member of |
| 409 | `CONFLICT` | Conflicts with the current state: a slug already taken, an invitation already pending or no longer valid, removing the last admin, or a billing action that doesn't fit the plan (already paid, already cancelled, withdrawal period over) |
| 410 | `ATTACHMENT_NOT_STORED` | The attachment was larger than your plan allows and was not stored |
| 413 | `PAYLOAD_TOO_LARGE` | The request body is larger than 10 MB |
| 429 | `RATE_LIMIT_EXCEEDED` | Too many requests. See the X-RateLimit-Reset header. |
| 500 | `INTERNAL_ERROR` | Unexpected server error |
| 502 | `EMAIL_SEND_FAILED` | The test email could not be sent |
| 503 | `BILLING_UNAVAILABLE` | Paid plans can't be bought here (Stripe is not set up in this environment) |

**Error response format:**

```json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Email not found"
  }
}
```

A wait that ends without mail is not an error: `wait` and `otp` return `200` with `"status": "timeout"`.

## Rate Limits

Requests with an API key count against your organization's limit, which depends on your subscription tier:

- **Free**: 60 requests/minute
- **Starter**: 100 requests/minute
- **Pro**: 1,000 requests/minute
- **Enterprise**: 10,000 requests/minute

Dashboard sessions are limited to 300 requests per minute per user, and login codes to 5 per hour per email address.

Invalid, revoked or expired API keys are limited to 100 different keys per 10 minutes per IP address. Retrying the same bad key doesn't count again. After that, keys from that address get a `429` until the window ends, unless they were recently used successfully.

Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. When rate limited, the API returns a `429` status with a `Retry-After` header indicating when you can retry.

## Pagination

Two lists are paged: `GET /projects/:projectId/emails` and `GET /organizations/:id/audit-log`. They return `hasMore` and, when there is another page, `nextCursor`. Pass it as the `cursor` query parameter to get the next page. Every other list returns all its items at once. The SDKs page through emails for you with `emails.listAll()` and `emails.list_all()`.

## Health

GET`/health`

No token needed. Whether the API is up, at https://api.receiver.email/health (outside /api/v1).

Response (200)

```json
{
  "status": "healthy",
  "service": "api-service",
  "revision": "receiver-api-00042-k7p",
  "timestamp": "2026-11-05T10:00:00.000Z"
}
```

`revision` names the deployed release of the API. Include it when you report a problem.

---

Source: https://www.receiver.email/docs/api-reference
