API Reference

Full reference for every Mailto.Bot REST endpoint. All requests require a Bearer token unless noted otherwise.

Last updated: April 10, 2026

Authentication

Include your API token in every request: Authorization: Bearer YOUR_API_TOKEN. Create tokens in Dashboard → Tokens.

Mailboxes

A mailbox is a real email address under your workspace. Messages are stored for 24 hours.

POST/api/mailboxes

Creates a new mailbox. On the Free plan the name is auto-generated. Pro accounts may supply a custom name slug.

Request body (JSON)

NameTypeDescription
namestringCustom mailbox slug (Pro only). Omit to auto-generate.

Response 201

NameTypeDescription
id*stringUnique mailbox ID.
name*stringMailbox slug used in API paths.
address*stringFull email address.
messageCount*numberCurrent message count in Redis.
createdAt*stringISO 8601 creation timestamp.
Errors: 400 invalid JSON · 401 unauthenticated · 403 custom name requires Pro · 409 name taken · 422 invalid name · 429 rate limited
cURL
curl -X POST https://mailto.bot/api/mailboxes \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
GET/api/mailboxes

Returns all mailboxes for the authenticated workspace, ordered by creation date (newest first), with live message counts from Redis.

Response 200 — array of

NameTypeDescription
id*stringMailbox ID.
name*stringSlug used in API paths.
address*stringFull email address.
messageCount*numberMessages currently in inbox.
createdAt*stringISO 8601 timestamp.
Errors: 401 unauthenticated · 429 rate limited
cURL
curl https://mailto.bot/api/mailboxes \
  -H "Authorization: Bearer YOUR_API_TOKEN"
DELETE/api/mailboxes/:name

Permanently deletes a mailbox and purges all its messages from Redis. This action is irreversible.

Path parameters

NameTypeDescription
name*stringMailbox slug.

Returns 204 No Content on success.

Errors: 401 unauthenticated · 404 not found · 429 rate limited
cURL
curl -X DELETE https://mailto.bot/api/mailboxes/abc123 \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Messages

Messages are stored in Redis with a 24-hour TTL. Large attachments are offloaded to Cloud Storage and served via signed URLs.

Attachment Handling

Inbound emails with attachments are automatically parsed. The attachments array is always present on every message object (empty array when there are none).

Receiving attachments

Each attachment object contains:

FieldTypeDescription
filenamestringOriginal file name.
contentTypestringMIME type, e.g. "application/pdf".
sizenumberFile size in bytes.
signedUrlstring|nullSigned GCS URL (files >1 MiB), valid 1 hour. null for smaller inline files.

Inbound limit: 25 MiB per email.

Sending attachments

Include an attachments array in the send-message body. Each entry:

FieldTypeDescription
filenamestringFile name shown to the recipient.
contentTypestringMIME type, e.g. "image/png".
datastringBase64-encoded file bytes.

Send limit: 10 MiB total payload (all attachments combined).

Subaddress routing (tag field)

Every mailbox supports the standard +tag subaddress format. Sending to support+ticket42@acme.mailto.bot delivers to the support mailbox and sets message.tag = "ticket42". Use tags to route by ticket ID, user ID, or any other label — no extra mailboxes needed.

Receive
// Attachment object on a received message
{
  "filename": "invoice-2026-04.pdf",
  "contentType": "application/pdf",
  "size": 512000,
  // signedUrl is present for files >1 MiB (GCS-offloaded), valid 1 hour
  "signedUrl": "https://storage.googleapis.com/mailtobot-attachments/..."
}

// Small files (<1 MiB) are stored inline in Redis —
// signedUrl will be null for those.
POST/api/mailboxes/:name/messages

Sends a message from the specified mailbox to one or more recipients. All to and cc addresses must belong to your workspace.

Path parameters

NameTypeDescription
name*stringSender mailbox slug.

Request body (JSON)

NameTypeDescription
to*string[]Recipient email addresses (workspace mailboxes).
subject*stringMessage subject line.
textstringPlain-text body.
htmlstringHTML body.
fromstringSender display name (defaults to mailbox address).
ccstring[]CC recipients (workspace mailboxes only).

Response 201

NameTypeDescription
messageId*stringUnique ID of the created message.
deliveredTo*string[]Addresses that received the message.
Errors: 400 bad request · 401 unauthenticated · 404 mailbox not found · 413 attachment too large · 422 validation failed
cURL
curl -X POST \
  https://mailto.bot/api/mailboxes/abc123/messages \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["inbox@mailto.bot"],
    "subject": "Hello",
    "text": "Your message here."
  }'
GET/api/mailboxes/:name/messages

Lists messages in a mailbox. Returns newest-first with cursor-based pagination.

Query parameters

NameTypeDescription
limitnumberMax results per page. Default 20, max 100.
afterstringPagination cursor from a previous response's nextCursor.
sincestringISO 8601 timestamp — return only messages after this time.

Response 200

NameTypeDescription
messages*Message[]Array of message objects (see GET /:id for shape).
nextCursor*string | nullCursor for the next page; null if no more results.
total*numberTotal messages currently in inbox.
Errors: 400 invalid query · 401 unauthenticated · 404 mailbox not found
cURL
curl "https://mailto.bot/api/mailboxes/abc123/messages?limit=20" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
GET/api/mailboxes/:name/messages/:id

Fetches a single message by ID. Attachment URLs are signed and valid for 1 hour.

Response 200 — message object

NameTypeDescription
id*stringMessage ID.
from*stringSender address.
to*string[]Recipient addresses.
subject*stringSubject line.
textstringPlain-text body.
htmlstringHTML body.
attachmentsobject[]Attachments with filename, contentType, size, url.
receivedAt*stringISO 8601 receipt timestamp.
Errors: 401 unauthenticated · 404 not found · 429 rate limited
cURL
curl https://mailto.bot/api/mailboxes/abc123/messages/msg_id \
  -H "Authorization: Bearer YOUR_API_TOKEN"
DELETE/api/mailboxes/:name/messages/:id

Deletes a message and removes any associated Cloud Storage attachments. Idempotent — returns 204 even if the message was already deleted.

Errors: 401 unauthenticated · 429 rate limited
cURL
curl -X DELETE \
  https://mailto.bot/api/mailboxes/abc123/messages/msg_id \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Webhooks

Register a URL and Mailto.Bot will POST each inbound message to it immediately. The secret returned at creation is shown only once.

For the full guide including payload format, retry behaviour, and ngrok testing, see the Webhooks Guide.

POST/api/mailboxes/:name/webhooks

Registers a new webhook for the mailbox. The secret is shown only once — store it immediately.

Request body (JSON)

NameTypeDescription
url*stringHTTPS (or HTTP for development) URL to POST events to.

Response 201

NameTypeDescription
id*stringWebhook ID.
mailboxId*stringParent mailbox ID.
url*stringRegistered URL.
active*booleanWhether the webhook is enabled.
secret*stringSigning secret — shown once only.
createdAt*stringISO 8601 timestamp.
Errors: 400 invalid URL · 401 unauthenticated · 404 mailbox not found
cURL
curl -X POST \
  https://mailto.bot/api/mailboxes/abc123/webhooks \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://your-server.com/webhook" }'
GET/api/mailboxes/:name/webhooks

Lists all webhooks for the mailbox. The secret field is omitted from list responses.

Errors: 401 unauthenticated · 404 mailbox not found
cURL
curl https://mailto.bot/api/mailboxes/abc123/webhooks \
  -H "Authorization: Bearer YOUR_API_TOKEN"
DELETE/api/mailboxes/:name/webhooks/:id

Deletes a webhook. No further events will be delivered to the registered URL.

Errors: 401 unauthenticated · 404 not found
cURL
curl -X DELETE \
  https://mailto.bot/api/mailboxes/abc123/webhooks/wh_id \
  -H "Authorization: Bearer YOUR_API_TOKEN"

API Tokens

Bearer tokens authenticate all API requests. The raw token value is shown only once at creation. Tokens are workspace-scoped.

GET/api/tokens

Lists all active tokens for the workspace.

Response 200 — array of

NameTypeDescription
id*stringToken ID.
name*stringHuman-readable label.
prefix*stringFirst 8 chars of the token (safe to display).
lastUsedAtstring|nullISO 8601 timestamp of last use.
createdAt*stringISO 8601 creation timestamp.
Errors: 401 unauthenticated
cURL
curl https://mailto.bot/api/tokens \
  -H "Authorization: Bearer YOUR_API_TOKEN"
POST/api/tokens

Creates a new API token. The full token value is returned only once — store it immediately.

Request body (JSON)

NameTypeDescription
name*stringHuman-readable label for the token.

Response 201

NameTypeDescription
id*stringToken ID.
name*stringLabel.
prefix*stringSafe display prefix.
token*stringFull token value — shown once only.
createdAt*stringISO 8601 timestamp.
Errors: 400 missing name · 401 unauthenticated · 500 encryption failure
cURL
curl -X POST https://mailto.bot/api/tokens \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "my-token" }'
DELETE/api/tokens/:id

Revokes an API token immediately. Any in-flight requests using the token will receive 401 errors.

Errors: 401 unauthenticated · 404 token not found
cURL
curl -X DELETE https://mailto.bot/api/tokens/tok_id \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Error Codes

All errors return JSON with an error field describing the problem.

StatusNameMeaning
400Bad RequestMalformed JSON, missing required field, or invalid parameter value.
401UnauthorizedMissing or invalid Bearer token. Check the Authorization header.
403ForbiddenAction not permitted for your plan or role (e.g. custom names require Pro).
404Not FoundThe resource (mailbox, message, token) does not exist or belongs to another workspace.
409ConflictResource already exists — e.g. custom mailbox name already taken.
413Payload Too LargeAttachment exceeds the per-recipient size limit.
422UnprocessableRequest body is valid JSON but fails business-logic validation.
429Too Many RequestsAPI rate limit exceeded. Slow down and retry with exponential back-off.
503Service UnavailableTransient infrastructure issue. Retry after a short delay.