AgentMail API via curl. Use this skill to create email inboxes for AI agents, send/receive/reply to emails, manage threads, drafts, webhooks, domains, and pods.
If requests fail, run zero doctor check-connector --env-name AGENTMAIL_TOKEN or zero doctor check-connector --url https://api.agentmail.to/v0/inboxes --method POST
An AI agent handles inbound support emails automatically.
POST /v0/inboxes with username: "support"message.received: POST /v0/webhooks with inbox_ids scoped to the support inboxsupport@agentmail.to, the webhook fires with the message payloadGET /v0/inboxes/{inbox-id}/threads/{thread-id}POST /v0/inboxes/{inbox-id}/messages/{message-id}/replyPATCH /v0/inboxes/{inbox-id}/messages/{message-id} with add_labels: ["replied"], remove_labels: ["unreplied"]GET /v0/inboxes/{inbox-id}/threads?labels=unreplied to find conversations that still need attentionAn AI agent sends personalized cold emails and manages follow-up sequences.
POST /v0/inboxes with client_id: "campaign-q1" for idempotencyPOST /v0/inboxes/{inbox-id}/messages/send with personalized subject/bodyPOST /v0/inboxes/{inbox-id}/drafts with send_at set to 3 days latermessage.received to detect repliesDELETE /v0/inboxes/{inbox-id}/drafts/{draft-id}GET /v0/metrics?event_types=message.bounced&event_types=message.complained to detect reputation issues earlyAn AI agent receives documents via email, processes them, and sends results back.
POST /v0/inboxes with username: "doc-processor"message.receivedGET /v0/inboxes/{inbox-id}/messages/{message-id}/attachments/{attachment-id} → returns a temporary download_urlPOST /v0/inboxes/{inbox-id}/messages/{message-id}/reply including processed output in the body or a new attachmentMultiple AI agents each have their own inbox, organized by team.
POST /v0/pods with name: "Research Team"pod_id: POST /v0/inboxes for each agent (e.g. researcher-1, researcher-2, summarizer)POST /v0/webhooks with inbox_ids scoped per agent@agentmail.to addresses for inter-agent communicationGET /v0/inboxes filtered by podAn AI agent drafts emails for human review before sending.
POST /v0/inboxes/{inbox-id}/draftsGET /v0/inboxes/{inbox-id}/drafts/{draft-id}POST /v0/inboxes/{inbox-id}/drafts/{draft-id}/sendPATCH /v0/inboxes/{inbox-id}/drafts/{draft-id} with revised contentDELETE /v0/inboxes/{inbox-id}/drafts/{draft-id}Create disposable inboxes for short-lived tasks, then clean up.
client_id tied to the task ID: POST /v0/inboxes with client_id: "task-abc123"DELETE /v0/inboxes/{inbox-id} — all associated threads and messages are cleaned upTrack email delivery health across all agent inboxes.
GET /v0/metrics?start_timestamp=...&end_timestamp=...GET /v0/metrics?event_types=message.bounced&event_types=message.rejectedGET /v0/inboxes/{inbox-id}/messages?labels=bouncedmessage.bounced and message.complained to get real-time alerts on deliverability issuesAn AI agent triages inbound emails and routes them appropriately.
POST /v0/inboxes with username: "hello"message.receivedPATCH /v0/inboxes/{inbox-id}/messages/{message-id} with add_labels: ["sales-lead"]POST /v0/inboxes/{inbox-id}/messages/{message-id}/replyGET /v0/inboxes/{inbox-id}/messages?labels=needs-reviewcurl -s -X POST "https://api.agentmail.to/v0/inboxes" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"username": "my-agent", "display_name": "My Agent"}' | jq .
Create with idempotent client_id (safe to retry without creating duplicates):
curl -s -X POST "https://api.agentmail.to/v0/inboxes" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"username": "my-agent", "display_name": "My Agent", "client_id": "my-agent-inbox"}' | jq .
curl -s "https://api.agentmail.to/v0/inboxes" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
With pagination:
curl -s "https://api.agentmail.to/v0/inboxes?limit=10" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s -X PATCH "https://api.agentmail.to/v0/inboxes/{inbox-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"display_name": "New Name"}' | jq .
curl -s -X DELETE "https://api.agentmail.to/v0/inboxes/{inbox-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"subject": "Hello from my agent",
"text": "Plain text body",
"html": "<p>HTML body</p>"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/send" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"],
"subject": "Hello",
"text": "Plain text body",
"html": "<p>HTML body</p>"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/send" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"subject": "Hello",
"text": "Plain text body",
"labels": ["outreach", "onboarding"]
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/send" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"subject": "Report attached",
"text": "Please find the report attached.",
"attachments": [
{
"filename": "report.txt",
"content_type": "text/plain",
"content": "<base64-encoded-content>"
}
]
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/send" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
To base64 encode a file:
base64 -w 0 /path/to/file.pdf
Write to /tmp/agentmail_request.json:
{
"text": "Thanks for your message!",
"html": "<p>Thanks for your message!</p>"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/{message-id}/reply" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Write to /tmp/agentmail_request.json:
{
"reply_all": true,
"text": "Thanks everyone!",
"html": "<p>Thanks everyone!</p>"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/{message-id}/reply" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
With filters:
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages?labels=unreplied&limit=10" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/{message-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Write to /tmp/agentmail_request.json:
{
"add_labels": ["replied"],
"remove_labels": ["unreplied"]
}
Then run:
curl -s -X PATCH "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/{message-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/messages/{message-id}/attachments/{attachment-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Returns a download_url (temporary pre-signed URL) and expires_at. Download the file:
curl -s -o attachment.bin "{download-url}"
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/threads" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
With filters:
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/threads?labels=unreplied&after=2025-01-01T00:00:00Z&limit=10" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Returns thread with all messages ordered by timestamp ascending:
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/threads/{thread-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/threads/{thread-id}/attachments/{attachment-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s -X DELETE "https://api.agentmail.to/v0/inboxes/{inbox-id}/threads/{thread-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"subject": "Draft email",
"text": "This is a draft.",
"html": "<p>This is a draft.</p>"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Write to /tmp/agentmail_request.json:
{
"to": ["recipient@example.com"],
"subject": "Scheduled email",
"text": "This will be sent later.",
"send_at": "2025-12-01T10:00:00Z"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts/{draft-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Write to /tmp/agentmail_request.json:
{
"subject": "Updated subject",
"text": "Updated body"
}
Then run:
curl -s -X PATCH "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts/{draft-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s -X POST "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts/{draft-id}/send" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{}' | jq .
curl -s -X DELETE "https://api.agentmail.to/v0/inboxes/{inbox-id}/drafts/{draft-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
Write to /tmp/agentmail_request.json:
{
"url": "https://your-server.com/webhooks",
"event_types": ["message.received", "message.sent", "message.delivered"],
"client_id": "my-webhook"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/webhooks" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
Supported event types: message.received, message.sent, message.delivered, message.bounced, message.complained, message.rejected, domain.verified
Write to /tmp/agentmail_request.json:
{
"url": "https://your-server.com/webhooks",
"event_types": ["message.received"],
"inbox_ids": ["{inbox-id-1}", "{inbox-id-2}"],
"client_id": "inbox-webhook"
}
Then run:
curl -s -X POST "https://api.agentmail.to/v0/webhooks" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s "https://api.agentmail.to/v0/webhooks" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/webhooks/{webhook-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Write to /tmp/agentmail_request.json:
{
"add_inbox_ids": ["{new-inbox-id}"],
"remove_inbox_ids": ["{old-inbox-id}"]
}
Then run:
curl -s -X PATCH "https://api.agentmail.to/v0/webhooks/{webhook-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d @/tmp/agentmail_request.json' | jq .
curl -s -X DELETE "https://api.agentmail.to/v0/webhooks/{webhook-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
curl -s -X POST "https://api.agentmail.to/v0/domains" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"domain": "yourdomain.com", "feedback_enabled": true}' | jq .
Returns DNS records (TXT, CNAME, MX) that must be added to your DNS provider.
curl -s "https://api.agentmail.to/v0/domains" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/domains/{domain-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Trigger DNS verification after adding records:
curl -s -X POST "https://api.agentmail.to/v0/domains/{domain-id}/verify" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
Domain status values: NOT_STARTED, PENDING, INVALID, FAILED, VERIFYING, VERIFIED
curl -s -X DELETE "https://api.agentmail.to/v0/domains/{domain-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
Pods are organizational groups for inboxes.
curl -s -X POST "https://api.agentmail.to/v0/pods" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"name": "Support Team", "client_id": "support-pod"}' | jq .
curl -s "https://api.agentmail.to/v0/pods" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s "https://api.agentmail.to/v0/pods/{pod-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s -X DELETE "https://api.agentmail.to/v0/pods/{pod-id}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
curl -s "https://api.agentmail.to/v0/metrics?start_timestamp=2025-01-01T00:00:00Z&end_timestamp=2025-12-31T23:59:59Z" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Filter by event type:
curl -s "https://api.agentmail.to/v0/metrics?start_timestamp=2025-01-01T00:00:00Z&end_timestamp=2025-12-31T23:59:59Z&event_types=message.sent&event_types=message.bounced" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
Supported event types: message.sent, message.delivered, message.bounced, message.delayed, message.rejected, message.complained, message.received
curl -s "https://api.agentmail.to/v0/api-keys" --header "Authorization: Bearer $AGENTMAIL_TOKEN" | jq .
curl -s -X POST "https://api.agentmail.to/v0/api-keys" --header "Authorization: Bearer $AGENTMAIL_TOKEN" --header "Content-Type: application/json" -d '{"name": "production-key"}' | jq .
The api_key value is only returned once at creation time. Save it immediately.
curl -s -X DELETE "https://api.agentmail.to/v0/api-keys/{api-key}" --header "Authorization: Bearer $AGENTMAIL_TOKEN"
When a webhook fires, AgentMail sends a POST request with this JSON payload:
{
"type": "event",
"event_type": "message.received",
"event_id": "unique-event-id",
"message": {
"inbox_id": "...",
"thread_id": "...",
"message_id": "...",
"from": "sender@example.com",
"to": ["your-inbox@agentmail.to"],
"subject": "Hello",
"text": "Message body",
"html": "<p>Message body</p>",
"attachments": []
},
"thread": {
"thread_id": "...",
"subject": "Hello",
"message_count": 1
}
}
Your endpoint should return HTTP 200 immediately and process the payload asynchronously.
| Parameter | Type | Description |
|---|---|---|
to |
string[] | Recipients |
cc |
string[] | CC recipients |
bcc |
string[] | BCC recipients |
reply_to |
string[] | Reply-to addresses |
subject |
string | Email subject |
text |
string | Plain text body |
html |
string | HTML body |
labels |
string[] | Custom labels |
attachments |
object[] | Attachments (with filename, content_type, content as base64 or url) |
headers |
object | Custom email headers |
| Status | Description |
|---|---|
200 |
Success |
202 |
Accepted (async delete for inboxes, threads) |
204 |
No Content (delete success for webhooks, pods, API keys) |
400 |
Invalid parameters |
403 |
Forbidden (sending not allowed) |
404 |
Resource not found |
client_id to prevent duplicates on retriesunreplied/replied to manage conversation state@agentmail.topip install agentmail