# 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](https://mailforbots.com/docs/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](https://mailforbots.com/docs/keys)); 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](https://mailforbots.com/docs/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](https://mailforbots.com/abuse):

curl POST /abuse/report

```
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 GET /me

```
curl "https://mailforbots.com/api/v1/me" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### GET `/scopes`

The list of valid API key scopes.

curl GET /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 GET /inboxes

```
curl "https://mailforbots.com/api/v1/inboxes" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/inboxes`no restricted keys

Scope: `inboxes:manage`

Create an inbox.

Body (all optional): domain, username, display_name, ttl_minutes.

curl POST /inboxes

```
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 GET /inboxes/:inbox

```
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 PATCH /inboxes/:inbox

```
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 DELETE /inboxes/:inbox

```
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 GET /inboxes/:inbox/messages

```
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 GET /inboxes/:inbox/wait

```
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 GET /messages/:id

```
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 GET /messages/:id/raw

```
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 PATCH /messages/:id

```
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 DELETE /messages/:id

```
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 POST /messages/:id/reply

```
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 POST /messages/:id/forward

```
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 GET /messages/:id/attachments/:index

```
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 POST /send

```
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 GET /threads

```
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 GET /threads/:id

```
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 GET /threads/:id/labels

```
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 POST /threads/labels

```
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 POST /threads/actions

```
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 POST /threads/empty

```
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 GET /drafts

```
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 POST /drafts

```
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 GET /drafts/:id

```
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 PATCH /drafts/: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 DELETE /drafts/:id

```
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 POST /drafts/:id/send

```
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 GET /labels

```
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 POST /labels

```
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/:id`no restricted keys

Scope: `mail:write`

Rename or recolor a label.

curl PATCH /labels/:id

```
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/:id`no restricted keys

Scope: `mail:write`

Delete a label.

curl DELETE /labels/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/labels/{id}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

## Filters

### GET `/filters`no restricted keys

Scope: `mail:read`

List filters.

curl GET /filters

```
curl "https://mailforbots.com/api/v1/filters" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/filters`no 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 POST /filters

```
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/:id`no restricted keys

Scope: `mail:write`

Update a filter. Same body as create.

curl PATCH /filters/:id

```
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/:id`no restricted keys

Scope: `mail:write`

Delete a filter.

curl DELETE /filters/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/filters/{id}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

## Contacts

### GET `/contacts`no restricted keys

Scope: `mail:read`

List contacts, collected automatically from people you write to.

Query: q, limit (1 to 1000).

curl GET /contacts

```
curl "https://mailforbots.com/api/v1/contacts" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/contacts`no restricted keys

Scope: `mail:write`

Add or update a contact.

Body: email (required), name, notes.

curl POST /contacts

```
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/:id`no restricted keys

Scope: `mail:write`

Edit a contact.

curl PATCH /contacts/:id

```
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/:id`no restricted keys

Scope: `mail:write`

Delete a contact.

curl DELETE /contacts/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/contacts/{id}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

## Custom domains

### GET `/domains`no restricted keys

Scope: `mail:read`

List custom domains, their DNS records and verification state.

curl GET /domains

```
curl "https://mailforbots.com/api/v1/domains" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/domains`no restricted keys

Scope: `inboxes:manage`

Add a domain (Pro).

curl POST /domains

```
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/verify`no restricted keys

Scope: `inboxes:manage`

Check the DNS records live and update the domain's status.

curl POST /domains/:domain/verify

```
curl -X POST "https://mailforbots.com/api/v1/domains/{domain}/verify" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### DELETE `/domains/:domain`no restricted keys

Scope: `inboxes:manage`

Remove a domain. It must have no inboxes.

curl DELETE /domains/:domain

```
curl -X DELETE "https://mailforbots.com/api/v1/domains/{domain}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### GET `/suppressions`no restricted keys

Scope: `mail:read`

Recipients blocked after a hard bounce or complaint.

curl GET /suppressions

```
curl "https://mailforbots.com/api/v1/suppressions" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### DELETE `/suppressions/:address`no restricted keys

Scope: `mail:send`

Remove a bounce from the suppression list (complaints can't be cleared).

curl DELETE /suppressions/:address

```
curl -X DELETE "https://mailforbots.com/api/v1/suppressions/{address}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

## Webhooks

### GET `/webhooks`no restricted keys

Scope: `webhooks:manage`

List webhooks (the secret is never shown again).

curl GET /webhooks

```
curl "https://mailforbots.com/api/v1/webhooks" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/webhooks`no 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 POST /webhooks

```
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/:id`no restricted keys

Scope: `webhooks:manage`

Get one webhook, including enabled, failure_count, disabled_reason, last_success_at and last_error.

curl GET /webhooks/:id

```
curl "https://mailforbots.com/api/v1/webhooks/{id}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### PATCH `/webhooks/:id`no 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 PATCH /webhooks/:id

```
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/:id`no restricted keys

Scope: `webhooks:manage`

Delete a webhook and its delivery log.

curl DELETE /webhooks/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/webhooks/{id}" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/webhooks/:id/rotate`no restricted keys

Scope: `webhooks:manage`

Generate a new signing secret and return it once. The old one stops working immediately.

curl POST /webhooks/:id/rotate

```
curl -X POST "https://mailforbots.com/api/v1/webhooks/{id}/rotate" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### POST `/webhooks/:id/test`no 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 POST /webhooks/:id/test

```
curl -X POST "https://mailforbots.com/api/v1/webhooks/{id}/test" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

### GET `/webhooks/:id/deliveries`no 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 GET /webhooks/:id/deliveries

```
curl "https://mailforbots.com/api/v1/webhooks/{id}/deliveries" \
  -H "Authorization: Bearer $BOTMAIL_KEY"
```

## API keys and billing (signed-in sessions only)

### GET `/keys`session

List your API keys (prefix, scopes and inbox_ids only). In a team: admin or owner.

curl GET /keys

```
curl "https://mailforbots.com/api/v1/keys" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/keys`session

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 POST /keys

```
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/:id`session

Revoke a key. In a team: admin or owner.

curl DELETE /keys/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/keys/{id}" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### GET `/billing`session

Plan and subscription status of the account (your own, or the team's). In a team: owner.

curl GET /billing

```
curl "https://mailforbots.com/api/v1/billing" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/billing/checkout`session

Start a Pro checkout; returns a URL. Returns 409 if already subscribed. In a team: owner.

curl POST /billing/checkout

```
curl -X POST "https://mailforbots.com/api/v1/billing/checkout" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/billing/portal`session

Open the billing portal; returns a URL. In a team: owner.

curl POST /billing/portal

```
curl -X POST "https://mailforbots.com/api/v1/billing/portal" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

## Teams (signed-in sessions only)

### GET `/teams`session

Teams you belong to, with your role in each.

curl GET /teams

```
curl "https://mailforbots.com/api/v1/teams" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/teams`session

Create a team; you become its owner. At most 10 owned teams per user.

curl POST /teams

```
curl -X POST "https://mailforbots.com/api/v1/teams" \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Support" }'
```

### GET `/teams/:id`session

One team (id, name, plan, your role). Non-members get 404.

curl GET /teams/:id

```
curl "https://mailforbots.com/api/v1/teams/{id}" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### PATCH `/teams/:id`session

Rename the team. Needs admin.

curl PATCH /teams/:id

```
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/:id`session

Delete the team and everything it owns (inboxes, mail, keys, domains, webhooks). Needs owner. Cancel an active subscription first (409 otherwise).

curl DELETE /teams/:id

```
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### GET `/teams/:id/members`session

Members with email and role; you: true marks yourself.

curl GET /teams/:id/members

```
curl "https://mailforbots.com/api/v1/teams/{id}/members" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### PATCH `/teams/:id/members/:user`session

Change a member's role. Needs owner. The last owner can't step down (409).

Body: role (member, admin or owner).

curl PATCH /teams/:id/members/:user

```
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/:user`session

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 DELETE /teams/:id/members/:user

```
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}/members/{user}" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### GET `/teams/:id/invites`session

Pending invitations. Needs admin.

curl GET /teams/:id/invites

```
curl "https://mailforbots.com/api/v1/teams/{id}/invites" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/teams/:id/invites`session

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 POST /teams/:id/invites

```
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/:invite`session

Revoke a pending invitation. Needs admin.

curl DELETE /teams/:id/invites/:invite

```
curl -X DELETE "https://mailforbots.com/api/v1/teams/{id}/invites/{invite}" \
  -H "Authorization: Bearer $SESSION_TOKEN"
```

### POST `/invites/preview`session

Show the team, role and inviter behind an invitation token, before accepting.

curl POST /invites/preview

```
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/accept`session

Join the team with the invited role. Any signed-in account holding the link can accept it, once.

curl POST /invites/accept

```
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" }'
```

## Guides

- [How to test password-reset emails in CI](https://mailforbots.com/blog/test-password-reset-emails-in-ci)
- [Disposable inboxes for testing sign-up and password-reset emails](https://mailforbots.com/email-testing-for-developers)
- [Playwright email tests: OTP and magic links with a per-worker inbox fixture](https://mailforbots.com/blog/playwright-email-verification-otp-tests)
