API Reference
Complete API reference for Agent Email mailboxes, messages, threads, labels, and webhooks.
Base URL
https://api.usetransactional.com/v1/agent-email
All requests require an Authorization: Bearer <api_key> header.
Mailboxes
Create Mailbox
POST /mailboxes
{
"name": "research-agent",
"domain": "agentmail.usetransactional.com"
}Response 201
{
"data": {
"id": "mbx_abc123",
"address": "research-agent@agentmail.usetransactional.com",
"name": "research-agent",
"domain": "agentmail.usetransactional.com",
"createdAt": "2025-01-10T12:00:00Z"
}
}List Mailboxes
GET /mailboxes?limit=25&offset=0
Get Mailbox
GET /mailboxes/:mailboxId
Delete Mailbox
DELETE /mailboxes/:mailboxId
Deleting a mailbox permanently removes all messages and webhooks associated with it.
Messages
Send Message
POST /messages/send
{
"from": "research-agent@agentmail.usetransactional.com",
"to": ["user@example.com"],
"cc": [],
"bcc": [],
"subject": "Research Complete",
"html": "<p>Findings attached.</p>",
"text": "Findings attached.",
"attachments": [
{
"filename": "report.pdf",
"content": "<base64>",
"contentType": "application/pdf"
}
],
"headers": {},
"tags": ["research"],
"scheduledAt": null
}Response 202
{
"data": {
"id": "msg_xyz789",
"status": "queued",
"from": "research-agent@agentmail.usetransactional.com",
"to": ["user@example.com"],
"subject": "Research Complete"
}
}Send Batch
POST /messages/send-batch
{
"from": "research-agent@agentmail.usetransactional.com",
"messages": [
{
"to": "alice@example.com",
"subject": "Your Report",
"html": "<p>Hi Alice...</p>"
}
]
}Reply
POST /messages/:messageId/reply
{
"html": "<p>Updated findings.</p>",
"text": "Updated findings.",
"attachments": []
}Reply All
POST /messages/:messageId/reply-all
Forward
POST /messages/:messageId/forward
{
"to": ["colleague@example.com"],
"html": "<p>FYI</p>"
}Cancel Scheduled Message
POST /messages/:messageId/cancel
Inbox
List Messages
GET /mailboxes/:mailboxId/inbox?limit=25&offset=0&unread=true&label=inbox&from=user@example.com&after=2025-01-01T00:00:00Z&before=2025-01-31T23:59:59Z&sort=received_at:desc
Response 200
{
"data": [
{
"id": "msg_abc123",
"from": "user@example.com",
"to": ["agent@agentmail.usetransactional.com"],
"subject": "Re: Research",
"textPreview": "Thanks for the update...",
"read": false,
"labels": ["inbox"],
"threadId": "thd_xyz789",
"attachmentCount": 0,
"receivedAt": "2025-01-10T14:30:00Z"
}
],
"meta": { "total": 142, "limit": 25, "offset": 0 }
}Get Message
GET /inbox/:messageId?markRead=true
Returns the full message including htmlBody, textBody, headers, and attachments.
Search Messages
GET /mailboxes/:mailboxId/inbox/search?query=quarterly+report&limit=10
Mark Read
POST /inbox/mark-read
{
"messageIds": ["msg_abc123", "msg_def456"]
}Mark Unread
POST /inbox/mark-unread
Archive
POST /inbox/archive
{
"messageIds": ["msg_abc123"]
}Unarchive
POST /inbox/unarchive
Delete Messages
DELETE /inbox
{
"messageIds": ["msg_abc123"]
}Threads
List Threads
GET /mailboxes/:mailboxId/threads?limit=20&sort=last_message_at:desc
Get Thread
GET /threads/:threadId
Returns the thread metadata and all messages in chronological order.
Labels
List Labels
GET /mailboxes/:mailboxId/labels
Create Label
POST /mailboxes/:mailboxId/labels
{
"name": "needs-review",
"color": "#3B82F6"
}Add Labels to Message
POST /inbox/:messageId/labels
{
"labels": ["important", "follow-up"]
}Remove Label from Message
DELETE /inbox/:messageId/labels/:labelName
Delete Label
DELETE /mailboxes/:mailboxId/labels/:labelName
Webhooks
Create Webhook
POST /mailboxes/:mailboxId/webhooks
{
"url": "https://yourapp.com/webhooks/agent-email",
"events": ["message.received", "message.bounced"],
"secret": "whsec_optional_custom_secret"
}List Webhooks
GET /mailboxes/:mailboxId/webhooks
Update Webhook
PATCH /webhooks/:webhookId
Delete Webhook
DELETE /webhooks/:webhookId
Test Webhook
POST /webhooks/:webhookId/test
Domains
Add Domain
POST /domains
{
"domain": "mail.yourdomain.com"
}Verify Domain
POST /domains/:domainId/verify
List Domains
GET /domains
Get Domain
GET /domains/:domainId
Delete Domain
DELETE /domains/:domainId
Error Responses
All errors follow the standard format:
{
"error": {
"code": "MAILBOX_NOT_FOUND",
"message": "Mailbox mbx_abc123 does not exist."
}
}| Code | Status | Description |
|---|---|---|
MAILBOX_NOT_FOUND | 404 | Mailbox does not exist |
MESSAGE_NOT_FOUND | 404 | Message does not exist |
DOMAIN_NOT_VERIFIED | 400 | Domain has not been verified |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
ATTACHMENT_TOO_LARGE | 400 | Attachments exceed 25 MB |
INVALID_RECIPIENT | 400 | Recipient address is invalid |
On This Page
- Base URL
- Mailboxes
- Create Mailbox
- List Mailboxes
- Get Mailbox
- Delete Mailbox
- Messages
- Send Message
- Send Batch
- Reply
- Reply All
- Forward
- Cancel Scheduled Message
- Inbox
- List Messages
- Get Message
- Search Messages
- Mark Read
- Mark Unread
- Archive
- Unarchive
- Delete Messages
- Threads
- List Threads
- Get Thread
- Labels
- List Labels
- Create Label
- Add Labels to Message
- Remove Label from Message
- Delete Label
- Webhooks
- Create Webhook
- List Webhooks
- Update Webhook
- Delete Webhook
- Test Webhook
- Domains
- Add Domain
- Verify Domain
- List Domains
- Get Domain
- Delete Domain
- Error Responses