HTTP API reference (OpenAPI)
Mailsink describes every public HTTP route in an OpenAPI 3.1
document, generated from the same Zod contracts the server validates with: native ingestion
(/v1), the Resend and Brevo drop-ins, the Admin API, the Capture API (messages, events,
override, suppressions, webhooks, logs, demo data, stream) and the public routes. Use it to
browse the API, to generate a client in another language, or to check your own client.
The documentation website renders it as the
API reference, one page per operation.
1. Get the document
Section titled “1. Get the document”| Where | How |
|---|---|
| A running instance | GET <MAILSINK_PUBLIC_URL>/openapi.json, no credential needed |
| A release | the openapi.json asset of each GitHub release |
| A checkout | pnpm install && pnpm openapi [file] (default ./openapi.json) |
curl -s http://localhost:3000/openapi.json -o openapi.jsonThe instance answers with its own MAILSINK_PUBLIC_URL as servers[0], so tools call the
right host. pnpm openapi uses MAILSINK_PUBLIC_URL when set, else
http://localhost:3000. info.version is the Mailsink release.
The endpoint holds no data and answers Access-Control-Allow-Origin: *, so a viewer served
from another origin can load it directly.
2. Authenticate
Section titled “2. Authenticate”The document declares the credentials as security schemes; each operation lists the ones it accepts.
| Scheme | Header | Routes |
|---|---|---|
connectionKey |
Authorization: Bearer msk_… |
Ingestion (/v1, /emails, /v3); the Capture API too |
brevoApiKey |
api-key: msk_… |
Brevo drop-in (/v3/smtp/*) |
workspaceKey |
Authorization: Bearer mskw_… |
Capture API |
adminKey |
Authorization: Bearer <MAILSINK_ADMIN_KEY> |
Admin API |
adminKey + workspaceHeader |
Admin key and X-Mailsink-Workspace: <id or slug> |
Capture API, any workspace |
Keys are answered once, when a workspace or connection is created
(POST /admin/workspaces, POST /admin/workspaces/{id}/connections).
3. Browse it
Section titled “3. Browse it”Swagger UI, in Docker, pointed at a running instance:
docker run --rm -p 8080:8080 -e URL=http://localhost:3000/openapi.json swaggerapi/swagger-uiOpen http://localhost:8080, then « Authorize » with the key of the scheme you need. Any
other OpenAPI 3.1 tool works the same way, for example a static HTML page with Redocly:
npx @redocly/cli build-docs openapi.json -o mailsink-api.html4. Generate a client
Section titled “4. Generate a client”Any OpenAPI 3.1 generator can read the document. Operations have stable operationIds
(sendEmail, listMessages, getMessage…) and are grouped by tags (Native ingestion,
Admin, Capture: messages…).
# TypeScript typesnpx openapi-typescript openapi.json -o mailsink.d.ts
# A Python clientdocker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli generate \ -i /local/openapi.json -g python -o /local/mailsink-clientFor the Resend and Brevo routes, prefer the official SDKs pointed at Mailsink: those routes are documented for completeness and answer in the provider’s shapes.
5. What the document tells you
Section titled “5. What the document tells you”- Errors: native, Capture and Admin routes answer
{ error: { code, message, details? }, requestId }(ApiErrorBody); the Resend and Brevo routes answer in their provider shapes (ResendErrorBody,BrevoError). Each operation lists its error statuses with the codes behind them (401unauthorized,422validation_error,429rate_limited…). - Headers: every response carries
X-Request-Id(the id of its request log row). Ingestion responses carryX-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Resetwhile a rate limit applies,Retry-Afteron429, andIdempotent-Replayed: truewhen replayed for the sameIdempotency-Key. - Stream:
GET /capture/streamis Server-Sent Events (text/event-stream); thedata:of each frame is oneStreamEventJSON (components.schemas.StreamEvent). - Outgoing webhooks: the payloads Mailsink POSTs to your webhook endpoints, per format
(
unified,resend,brevo), are in the document’swebhookssection. - Not in the document: the MCP endpoint (
/mcp, see mcp.md) and the routes of the web UI behind its session cookie.