REST API
Base URL: https://mailforbots.com/api/v1. Send your API key as Authorization: Bearer bm_... and JSON bodies with Content-Type: application/json. Responses are JSON; errors look like { "error": "message" } (see Errors). Path segments like :inbox take an id (inboxes also take the full address).
Each endpoint lists the API key scope it needs (see API keys and scopes); webmail sessions and admin keys have all scopes. Endpoints marked no restricted keys are off limits to keys restricted to some inboxes. Endpoints marked session need a signed-in webmail session (its access token, written $SESSION_TOKEN in the examples) rather than an API key.
To act in a team with a session, add the header X-Botmail-Team: <team id> (see Teams). API keys never need it.
Outside /api/v1 and without auth: GET https://mailforbots.com/health returns { "ok": true } and GET https://mailforbots.com/ready checks the database and storage. POST https://mailforbots.com/abuse/report is used by the abuse form:
curl -X POST "https://mailforbots.com/abuse/report" \
-H "Content-Type: application/json" \
-d '{ "reporter_email": "you@example.com", "botmail_address": "spammer@mailforbots.com", "description": "Phishing mail received on 2026-01-05, subject: ...", "evidence": "optional: message headers" }'reporter_email, botmail_address and description (10 to 10,000 characters) are required; evidence (up to 100,000 characters) is optional. Success is 201 { "id": "...", "received": true }; invalid fields return 400, and more than 10 reports an hour from one IP address return 429.
Account
GET /me
Who you are acting as: the account (a user or a team) and its role, your plan and its limits, the per-user rate limits, the shared mail domain, how you authenticated, and for API keys the scopes and inbox_ids restriction.
Response fields: account { id, kind, name, role }, actor_id, plan, limits, rate_limits, mail_domain, auth (key or session), scopes, inbox_ids.
curl "https://mailforbots.com/api/v1/me" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /scopes
The list of valid API key scopes.
curl "https://mailforbots.com/api/v1/scopes" \
-H "Authorization: Bearer $BOTMAIL_KEY"Inboxes
GET /inboxes
Scope: mail:read
List inboxes with unread counts.
curl "https://mailforbots.com/api/v1/inboxes" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /inboxesno restricted keys
Scope: inboxes:manage
Create an inbox.
Body (all optional): domain, username, display_name, ttl_minutes.
curl -X POST "https://mailforbots.com/api/v1/inboxes" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "username": "signup-bot", "display_name": "Signup bot", "ttl_minutes": 60 }'GET /inboxes/:inbox
Scope: mail:read
Get one inbox. :inbox is its id or full address.
curl "https://mailforbots.com/api/v1/inboxes/{inbox}" \
-H "Authorization: Bearer $BOTMAIL_KEY"PATCH /inboxes/:inbox
Scope: inboxes:manage
Update the display name or signature.
Body: display_name, signature (HTML).
curl -X PATCH "https://mailforbots.com/api/v1/inboxes/{inbox}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "display_name": "Support bot" }'DELETE /inboxes/:inbox
Scope: inboxes:manage
Delete the inbox and all its messages.
curl -X DELETE "https://mailforbots.com/api/v1/inboxes/{inbox}" \
-H "Authorization: Bearer $BOTMAIL_KEY"Messages
GET /inboxes/:inbox/messages
Scope: mail:read
List message summaries, newest first.
Query: limit (1 to 100), unread_only=true, direction=inbound|outbound, before (ISO date, for paging).
curl "https://mailforbots.com/api/v1/inboxes/{inbox}/messages" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /inboxes/:inbox/wait
Scope: mail:read
Long-poll until a matching unread inbound message exists, then return it and mark it read. Responds 408 on timeout.
Query: from_contains, subject_contains, to_contains, timeout_seconds (1 to 300, default 60).
curl "https://mailforbots.com/api/v1/inboxes/{inbox}/wait" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /messages/:id
Scope: mail:read
Full message with attachments and extracted codes and links. Marks it read.
Query: mark_read=false to leave it unread.
curl "https://mailforbots.com/api/v1/messages/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /messages/:id/raw
Scope: mail:read
The original RFC 822 source of a message (inbound as received, outbound as relayed) as text/plain, with every header. Sent as a download by default. Returns 404 for mail that arrived before originals were kept.
Query: download=false to show it inline instead of as an attachment.
curl "https://mailforbots.com/api/v1/messages/{id}/raw" \
-H "Authorization: Bearer $BOTMAIL_KEY"PATCH /messages/:id
Scope: mail:write
Mark a message read or unread.
Body: read (boolean).
curl -X PATCH "https://mailforbots.com/api/v1/messages/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "read": true }'DELETE /messages/:id
Scope: mail:write
Delete a message.
curl -X DELETE "https://mailforbots.com/api/v1/messages/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /messages/:id/reply
Scope: mail:send
Reply in the same thread.
Body: text, html, reply_all, quote, to, cc, bcc, attachments.
curl -X POST "https://mailforbots.com/api/v1/messages/{id}/reply" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "text": "Thanks, got it.", "quote": true }'POST /messages/:id/forward
Scope: mail:send
Forward a message with its attachments.
Body: to (required), cc, text.
curl -X POST "https://mailforbots.com/api/v1/messages/{id}/forward" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "to": ["boss@example.com"], "text": "FYI" }'GET /messages/:id/attachments/:index
Scope: mail:read
Short-lived download URL for an attachment, plus inline text for small text files.
curl "https://mailforbots.com/api/v1/messages/{id}/attachments/{index}" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /send
Scope: mail:send
Send an email from one of your inboxes.
Body: inbox, to, subject (required); cc, bcc, text, html, attachments (base64, up to 20, 20 MB total). Provide text and/or html.
curl -X POST "https://mailforbots.com/api/v1/send" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "inbox": "agent@mailforbots.com", "to": ["you@example.com"], "subject": "Hello", "text": "Sent by an agent." }'Conversations
GET /threads
Scope: mail:read
List conversations, newest first. Supports search operators in q.
Query: folder (inbox, starred, sent, snoozed, all, trash, spam), inbox, q, label, limit, before, before_thread.
curl "https://mailforbots.com/api/v1/threads" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /threads/:id
Scope: mail:read
All messages in a conversation, oldest first.
Query: mark_read=true to mark them read.
curl "https://mailforbots.com/api/v1/threads/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /threads/:id/labels
Scope: mail:read
Labels on a conversation.
curl "https://mailforbots.com/api/v1/threads/{id}/labels" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /threads/labels
Scope: mail:write
Add and remove labels on up to 500 conversations.
Body: thread_ids (required), add, remove.
curl -X POST "https://mailforbots.com/api/v1/threads/labels" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "thread_ids": ["THREAD_ID"], "add": ["Receipts"], "remove": [] }'POST /threads/actions
Scope: mail:write
Bulk action on up to 500 conversations: read, unread, star, unstar, archive, unarchive, trash, restore, spam, unspam, delete (only from trash or spam), snooze, unsnooze.
Body: thread_ids, action; until (ISO date) for snooze.
curl -X POST "https://mailforbots.com/api/v1/threads/actions" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "thread_ids": ["THREAD_ID"], "action": "archive" }'POST /threads/empty
Scope: mail:write
Permanently delete everything in Trash or Spam.
Body: folder (trash or spam).
curl -X POST "https://mailforbots.com/api/v1/threads/empty" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "folder": "trash" }'Drafts (human approval)
GET /drafts
Scope: mail:read
List drafts, including ones agents prepared.
Query: thread_id.
curl "https://mailforbots.com/api/v1/drafts" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /drafts
Scope: drafts:write
Create a draft. Drafts made with an API key are marked as prepared by an agent.
Body: inbox, mode (new, reply, replyAll, forward), original_message_id, to, cc, bcc, subject, text, html, attachments.
curl -X POST "https://mailforbots.com/api/v1/drafts" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "inbox": "agent@mailforbots.com", "to": ["customer@example.com"], "subject": "Your refund", "text": "Hi, your refund is on its way." }'GET /drafts/:id
Scope: mail:read
Get one draft.
curl "https://mailforbots.com/api/v1/drafts/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"PATCH /drafts/:id
Scope: drafts:write
Update a draft. Same body as create; attachments can keep existing files by { id }.
curl -X PATCH "https://mailforbots.com/api/v1/drafts/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "subject": "Updated subject" }'DELETE /drafts/:id
Scope: drafts:write
Discard a draft.
curl -X DELETE "https://mailforbots.com/api/v1/drafts/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /drafts/:id/send
Scope: mail:send
Send a draft.
curl -X POST "https://mailforbots.com/api/v1/drafts/{id}/send" \
-H "Authorization: Bearer $BOTMAIL_KEY"Labels
GET /labels
Scope: mail:read
List labels with conversation counts.
curl "https://mailforbots.com/api/v1/labels" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /labels
Scope: mail:write
Create a label.
Body: name, color (hex, optional).
curl -X POST "https://mailforbots.com/api/v1/labels" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Receipts", "color": "#1a73e8" }'PATCH /labels/:idno restricted keys
Scope: mail:write
Rename or recolor a label.
curl -X PATCH "https://mailforbots.com/api/v1/labels/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Invoices" }'DELETE /labels/:idno restricted keys
Scope: mail:write
Delete a label.
curl -X DELETE "https://mailforbots.com/api/v1/labels/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"Filters
GET /filtersno restricted keys
Scope: mail:read
List filters.
curl "https://mailforbots.com/api/v1/filters" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /filtersno restricted keys
Scope: mail:write
Create a filter applied to incoming mail.
Body: criteria (at least one of from, to, subject, has_words), actions (label_id, archive, mark_read, star, trash), optional inbox_id and apply_existing.
curl -X POST "https://mailforbots.com/api/v1/filters" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "criteria": { "from": "billing@vendor.com" }, "actions": { "label_id": "LABEL_ID", "archive": true } }'PATCH /filters/:idno restricted keys
Scope: mail:write
Update a filter. Same body as create.
curl -X PATCH "https://mailforbots.com/api/v1/filters/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "actions": { "star": true } }'DELETE /filters/:idno restricted keys
Scope: mail:write
Delete a filter.
curl -X DELETE "https://mailforbots.com/api/v1/filters/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"Contacts
GET /contactsno restricted keys
Scope: mail:read
List contacts, collected automatically from people you write to.
Query: q, limit (1 to 1000).
curl "https://mailforbots.com/api/v1/contacts" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /contactsno restricted keys
Scope: mail:write
Add or update a contact.
Body: email (required), name, notes.
curl -X POST "https://mailforbots.com/api/v1/contacts" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "email": "ada@example.com", "name": "Ada", "notes": "Vendor" }'PATCH /contacts/:idno restricted keys
Scope: mail:write
Edit a contact.
curl -X PATCH "https://mailforbots.com/api/v1/contacts/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Ada Lovelace" }'DELETE /contacts/:idno restricted keys
Scope: mail:write
Delete a contact.
curl -X DELETE "https://mailforbots.com/api/v1/contacts/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"Custom domains
GET /domainsno restricted keys
Scope: mail:read
List custom domains, their DNS records and verification state.
curl "https://mailforbots.com/api/v1/domains" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /domainsno restricted keys
Scope: inboxes:manage
Add a domain (Pro).
curl -X POST "https://mailforbots.com/api/v1/domains" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "domain": "example.com" }'POST /domains/:domain/verifyno restricted keys
Scope: inboxes:manage
Check the DNS records live and update the domain's status.
curl -X POST "https://mailforbots.com/api/v1/domains/{domain}/verify" \
-H "Authorization: Bearer $BOTMAIL_KEY"DELETE /domains/:domainno restricted keys
Scope: inboxes:manage
Remove a domain. It must have no inboxes.
curl -X DELETE "https://mailforbots.com/api/v1/domains/{domain}" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /suppressionsno restricted keys
Scope: mail:read
Recipients blocked after a hard bounce or complaint.
curl "https://mailforbots.com/api/v1/suppressions" \
-H "Authorization: Bearer $BOTMAIL_KEY"DELETE /suppressions/:addressno restricted keys
Scope: mail:send
Remove a bounce from the suppression list (complaints can't be cleared).
curl -X DELETE "https://mailforbots.com/api/v1/suppressions/{address}" \
-H "Authorization: Bearer $BOTMAIL_KEY"Webhooks
GET /webhooksno restricted keys
Scope: webhooks:manage
List webhooks (the secret is never shown again).
curl "https://mailforbots.com/api/v1/webhooks" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /webhooksno restricted keys
Scope: webhooks:manage
Create a webhook. The signing secret (whsec_...) is returned once, in this response.
Body: url (https, public address), events (non-empty: message.received, message.sent, message.bounced, message.delivered, message.delayed, message.failed, message.opened, message.clicked, thread.labeled, draft.created), inbox_id (optional id or address: only events of that inbox). Up to 20 webhooks per account.
curl -X POST "https://mailforbots.com/api/v1/webhooks" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/mailforbots", "events": ["message.received"], "inbox_id": "agent@mailforbots.com" }'GET /webhooks/:idno restricted keys
Scope: webhooks:manage
Get one webhook, including enabled, failure_count, disabled_reason, last_success_at and last_error.
curl "https://mailforbots.com/api/v1/webhooks/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"PATCH /webhooks/:idno restricted keys
Scope: webhooks:manage
Change url, events or inbox_id, or switch it on or off. Setting enabled to true resets the failure count.
Body (all optional): url, events, inbox_id (null for all inboxes), enabled.
curl -X PATCH "https://mailforbots.com/api/v1/webhooks/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY" \
-H "Content-Type: application/json" \
-d '{ "enabled": true }'DELETE /webhooks/:idno restricted keys
Scope: webhooks:manage
Delete a webhook and its delivery log.
curl -X DELETE "https://mailforbots.com/api/v1/webhooks/{id}" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /webhooks/:id/rotateno restricted keys
Scope: webhooks:manage
Generate a new signing secret and return it once. The old one stops working immediately.
curl -X POST "https://mailforbots.com/api/v1/webhooks/{id}/rotate" \
-H "Authorization: Bearer $BOTMAIL_KEY"POST /webhooks/:id/testno restricted keys
Scope: webhooks:manage
Send a ping event right away (one attempt, no retries) and return the delivery with the response status and body.
curl -X POST "https://mailforbots.com/api/v1/webhooks/{id}/test" \
-H "Authorization: Bearer $BOTMAIL_KEY"GET /webhooks/:id/deliveriesno restricted keys
Scope: webhooks:manage
Recent delivery attempts, newest first: event, status, attempts, next_attempt_at, response_status, response_body.
Query: limit (1 to 100, default 25).
curl "https://mailforbots.com/api/v1/webhooks/{id}/deliveries" \
-H "Authorization: Bearer $BOTMAIL_KEY"API keys and billing (signed-in sessions only)
GET /keyssession
List your API keys (prefix, scopes and inbox_ids only). In a team: admin or owner.
curl "https://mailforbots.com/api/v1/keys" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /keyssession
Create a key. The full key is returned once. Created while acting in a team (X-Botmail-Team), the key belongs to the team. In a team: admin or owner. Limited to 10 per hour.
Body: name (default "default"), scopes (non-empty; default ["admin"], full access), inbox_ids (non-empty array of ids or addresses; omit or null for all inboxes). See API keys and scopes.
curl -X POST "https://mailforbots.com/api/v1/keys" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "support agent", "scopes": ["mail:read", "mail:send"], "inbox_ids": ["support@mailforbots.com"] }'DELETE /keys/:idsession
Revoke a key. In a team: admin or owner.
curl -X DELETE "https://mailforbots.com/api/v1/keys/{id}" \
-H "Authorization: Bearer $SESSION_TOKEN"GET /billingsession
Plan and subscription status of the account (your own, or the team's). In a team: owner.
curl "https://mailforbots.com/api/v1/billing" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /billing/checkoutsession
Start a Pro checkout; returns a URL. Returns 409 if already subscribed. In a team: owner.
curl -X POST "https://mailforbots.com/api/v1/billing/checkout" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /billing/portalsession
Open the billing portal; returns a URL. In a team: owner.
curl -X POST "https://mailforbots.com/api/v1/billing/portal" \
-H "Authorization: Bearer $SESSION_TOKEN"Teams (signed-in sessions only)
GET /teamssession
Teams you belong to, with your role in each.
curl "https://mailforbots.com/api/v1/teams" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /teamssession
Create a team; you become its owner. At most 10 owned teams per user.
curl -X POST "https://mailforbots.com/api/v1/teams" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "Support" }'GET /teams/:idsession
One team (id, name, plan, your role). Non-members get 404.
curl "https://mailforbots.com/api/v1/teams/{id}" \
-H "Authorization: Bearer $SESSION_TOKEN"PATCH /teams/:idsession
Rename the team. Needs admin.
curl -X PATCH "https://mailforbots.com/api/v1/teams/{id}" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "Customer support" }'DELETE /teams/:idsession
Delete the team and everything it owns (inboxes, mail, keys, domains, webhooks). Needs owner. Cancel an active subscription first (409 otherwise).
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}" \
-H "Authorization: Bearer $SESSION_TOKEN"GET /teams/:id/memberssession
Members with email and role; you: true marks yourself.
curl "https://mailforbots.com/api/v1/teams/{id}/members" \
-H "Authorization: Bearer $SESSION_TOKEN"PATCH /teams/:id/members/:usersession
Change a member's role. Needs owner. The last owner can't step down (409).
Body: role (member, admin or owner).
curl -X PATCH "https://mailforbots.com/api/v1/teams/{id}/members/{user}" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "role": "admin" }'DELETE /teams/:id/members/:usersession
Remove a member, or leave the team when :user is your own id. Admins can remove members; removing an admin or owner needs an owner. The last owner can't leave (409).
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}/members/{user}" \
-H "Authorization: Bearer $SESSION_TOKEN"GET /teams/:id/invitessession
Pending invitations. Needs admin.
curl "https://mailforbots.com/api/v1/teams/{id}/invites" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /teams/:id/invitessession
Invite someone by email. Needs admin. They get a single-use link valid for 7 days; a new invite to the same address replaces the old one. You can't invite a higher role than your own.
Body: email, role (member by default, admin or owner). Limits: 50 pending invitations per team and an hourly cap per person.
curl -X POST "https://mailforbots.com/api/v1/teams/{id}/invites" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "email": "ada@example.com", "role": "member" }'DELETE /teams/:id/invites/:invitesession
Revoke a pending invitation. Needs admin.
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}/invites/{invite}" \
-H "Authorization: Bearer $SESSION_TOKEN"POST /invites/previewsession
Show the team, role and inviter behind an invitation token, before accepting.
curl -X POST "https://mailforbots.com/api/v1/invites/preview" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "token": "TOKEN_FROM_THE_LINK" }'POST /invites/acceptsession
Join the team with the invited role. Any signed-in account holding the link can accept it, once.
curl -X POST "https://mailforbots.com/api/v1/invites/accept" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "token": "TOKEN_FROM_THE_LINK" }'