description: Every Scribase Mail HTTP endpoint with request and response shapes: emails, batch, domains, API keys, webhooks, auth (magic link, OTP, JWKS), unsubscribe and tracking. Resend-compatible JSON over HTTPS.
---
Base URL: `https://mail-api.scribase.com`. All requests and responses are JSON. Authenticate with `Authorization: Bearer sk_...`. The auth endpoints (`/auth/*`, `/.well-known/jwks.json`) take no API key.
## Conventions
**Keys.** `full_access` keys can call everything. `sending_access` keys can send and read individual emails only; on anything else they get `401 restricted_api_key`. A sending key with a `domain_id` can only use `from` addresses on that domain (`403 validation_error` otherwise).
**Errors.**
```json
{ "statusCode": 422, "name": "validation_error", "message": "`to` may contain at most 50 addresses" }
```
| Status | `name` | Meaning |
|---|---|---|
| 400 | `validation_error` | body is not valid JSON |
| 400 | `invalid_idempotency_key` | header not 1-256 characters |
| 401 | `missing_api_key` | no `Authorization` header |
| 401 | `validation_error` | key unknown or revoked (`"API key is invalid"`) |
| 401 | `restricted_api_key` | sending key on a management endpoint |
| 403 | `validation_error` | domain not verified, recipient suppressed, or key restricted to another domain |
| 404 | `not_found` | unknown id or route |
| 409 | `invalid_idempotent_request` | same `Idempotency-Key`, different body |
| 409 | `validation_error` | state conflict, e.g. cancel of an already sent email |
| 422 | `validation_error` | a field is present but wrong |
| 429 | `rate_limit_exceeded` | over 10 requests per second for this key |
| 503 | `dns_lookup_failed` | verification could not reach DNS |
| 500 | `application_error` | our fault; the message is generic, details are in our logs |
**Timestamps.** Objects use `2026-11-12 21:15:12.548000+00` (UTC). Webhook payloads use RFC 3339 `2026-11-12T21:15:12.548Z`. Input `scheduled_at` must be RFC 3339 (`2026-11-13T10:00:00Z`).
**Idempotency.** Send `Idempotency-Key: <1-256 chars>` on `POST /emails` or `POST /emails/batch`. The same key with the same body returns the original response for 24 hours without sending again.
| `attachments[]` | object | `filename` + base64 `content` required; optional `content_type`, `cid`; `path` is not supported; 40 MB total |
| `tags[]` | object | `name` and `value`: ASCII letters, digits, `_`, `-`, max 256 characters |
Response `200`:
```json
{ "id": "7af8001f-54d6-4607-b951-ee1cc2ad60d5" }
```
Recipients on your suppression list are dropped silently from the send; if every recipient is suppressed the call returns `403 validation_error`.
### POST /emails/batch
Up to 100 emails in one call; the body is a JSON array of the objects above. Attachments are not allowed. Each item is validated before any is queued, so a bad item fails the whole batch. Any key.
List emails, newest first. Full access only. Query: `limit` (1-100, default 20), `after` or `before` (an email id, not both), `test` (`true` = only `sk_test_` sends, `false` = only live sends; omitted = both).
`last_event` is one of `queued`, `scheduled`, `sent`, `delivered`, `delivery_delayed`, `bounced`, `complained`, `failed`, `canceled`, `opened`, `clicked`.
### PATCH /emails/{id}
Reschedule. Body `{ "scheduled_at": "2026-11-13T12:00:00Z" }`. Only emails that have not been sent yet. Any key.
```json
{ "object": "email", "id": "7af8001f-..." }
```
### POST /emails/{id}/cancel
Cancel a queued or scheduled email. Returns `{ "object": "email", "id": "..." }`; `409` if already sent. Any key.
The status history of one email, oldest first: every `email.*` event with its timestamp and a one-line detail (the SMTP reply on a bounce, the relay error on a failure, the recipients concerned). Full access only.
Every webhook delivery attempted for this email's events, newest first (up to 200). Full access only. Items have the same shape as [`GET /webhooks/{id}/deliveries`](#get-webhooksiddeliveries).
`type`: `bounced`, `complained` or `delivered`. Updates `last_event`, suppresses the recipient on bounce/complaint (all recipients when `recipient` is omitted), and fires the matching webhook event. Returns `{ "object": "email", "id": "..." }`.
## Domains
Full access only. See [Domains and DNS](../domains-dns/) for what the records mean.
Runs real DNS lookups and stores the result. Returns `{ "object": "domain", "id": "..." }`; read `GET /domains/{id}` for the outcome. Domain `status` is `verified` when DKIM TXT and SPF TXT both match, `pending` when one does, `failed` when neither does. `503 dns_lookup_failed` if the resolver is unreachable.
`name` required, max 50 characters. `permission`: `full_access` (default) or `sending_access`. `domain_id` is allowed only with `sending_access`. Response `201`:
`endpoint` must be a public `http(s)` URL. `events` must be non-empty, from: `email.sent`, `email.delivered`, `email.delivery_delayed`, `email.bounced`, `email.complained`, `email.failed`, `email.opened`, `email.clicked`. Response `201`:
The delivery log of one endpoint, newest first. Query: `limit` (1-500, default 50). Full access only. `status` is `pending` (will be retried at `next_attempt_at`), `delivered` or `failed`; `response_status` is the last HTTP status your endpoint returned, `error` the last transport error.
No API key. Project-scoped passwordless sign-in; full guide on [Magic links and OTP](../auth/). Errors here use `{ "error": "<code>", "message": "..." }`.
### POST /auth/magic-link, POST /auth/email-verification, POST /auth/password-reset
`redirect_to` must be on the project's `allowed_redirect_origins`. Response `200` (also when the address is unknown):
```json
{ "ok": true, "message": "If that address can receive mail, a link is on its way.", "expires_in": 900 }
```
### GET /auth/verify?token=
Consumes a link token (single use, 15 minutes). Browser: `303` to `redirect_to#access_token=...&token_type=Bearer&expires_in=3600&purpose=magic_link`. With `Accept: application/json`:
| PATCH | `/auth/admin/projects/{id}` | any of `app_name`, `from_address`, `jwt_audience`, `allowed_redirect_origins`, `subject_overrides` |
Project object: `id`, `slug`, `app_name`, `from_address`, `jwt_audience`, `allowed_redirect_origins`, `subject_overrides`, `created_at`, `updated_at`. `slug` is 2-64 characters of `a-z0-9-`. Rate limits: 5 requests per hour per email per project, 30 per hour per IP; `429 rate_limited` with `Retry-After`.
## Public endpoints
No authentication; these are the URLs embedded in your emails.
| Method | Path | Purpose |
|---|---|---|
| GET | `/healthz` | `{ "ok": true, "service": "scribase-mail" }`, `503` when the database is unreachable |
| GET | `/unsubscribe/{token}` | hosted unsubscribe page |
| POST | `/unsubscribe/{token}` | one-click unsubscribe (RFC 8058) and the page's form; adds the recipient to your suppression list |
| GET | `/track/open/{id}/{sig}.gif` | open-tracking pixel |
| GET | `/track/click/{id}?u=&s=` | click tracking, `307` to the original link |
`smtp.scribase.com`, ports `587` (STARTTLS) and `465` (TLS), `AUTH PLAIN`/`LOGIN` with username `scribase` and password = API key. `AUTH` is only accepted after TLS. The `From` address must be on one of your verified domains (or the key's domain restriction). On success the server answers `250 2.0.0 Ok <email_id>`; the same id works with `GET /emails/{id}`. Messages are DKIM-signed and queued like an API send and appear in `GET /emails` tagged `source=smtp`; the same plan limits, suppression list and content checks apply (a blocked message gets `550 5.7.1`). Setup for Supabase Auth is on [Use as Supabase's mail server](../supabase/).