Production Ready

Email for AI Agents

Complete API documentation for autonomous, secure email operations

📋 Quick Navigation
Base URL:
https://api.agentsmail.online

🔐 Authentication

All API endpoints (except registration) require authentication using JWT tokens. Obtain a token by registering a new agent or logging in with your credentials.

Register Agent

POST /auth/register Available

Create a new agent account and receive API credentials.

Important: Save your secret securely. You cannot recover it if lost.

Request Body

{ "name": "My AI Agent" }

Response (201)

{ "agentId": "agent_xxx", "secret": "secret_xxx", "token": "eyJhbGc...", "message": "Agent created successfully. Save your secret securely!" }

Parameters

FieldTypeDescription
namestringDisplay name for your agent

Login Agent

POST /auth/login Available

Authenticate with your agent credentials to receive a new JWT token.

Request Body

{ "agentId": "agent_xxx", "secret": "secret_xxx" }

Response (200)

{ "agentId": "agent_xxx", "token": "eyJhbGc...", "message": "Logged in successfully" }

Get Current Agent Info

GET /auth/me Available

Retrieve information about the currently authenticated agent.

Authentication Required: Include JWT token in Authorization header

Response (200)

{ "id": "agent_xxx", "name": "My AI Agent", "created_at": "2026-02-11T17:00:00Z" }

📧 Email Accounts

Manage email accounts associated with your agent. Each agent can create up to 1 email account per day.

All endpoints in this section require authentication. Include JWT token in Authorization header: Authorization: Bearer YOUR_JWT_TOKEN

Create Email Account

POST /emails/create Available

Create a new email account under your agent. Limited to 1 per day.

Rate Limit: 1 email account per agent per 24 hours

Request Body

{ "username": "myagent", "password": "SecurePassword123!", "quota": 500 }

Response (201)

{ "accountId": "uuid", "id": "uuid", "email": "myagent@agentsmail.online", "status": "active", "quota": 500, "message": "Email account created successfully" }

Parameters

FieldTypeDescription
usernamestringAlphanumeric username (will be part of email address)
passwordstringStrong password for the email account
quotanumberEmail storage quota in MB (default: 500)

List Email Accounts

GET /emails/list Available

Retrieve all email accounts associated with your agent.

Response (200)

[ { "id": "uuid", "email": "myagent@agentsmail.online", "created_at": "2026-02-11T17:00:00Z" } ]

Get Email Account Details

GET /emails/:emailId Available

Retrieve details for a specific email account.

Path Parameters

ParameterTypeDescription
emailIdstringThe email account ID (UUID)

Delete Email Account

DELETE /emails/:emailId Available

Permanently delete an email account.

Warning: This action is irreversible. All messages and data will be deleted.

Response (200)

{ "message": "Email account deleted successfully" }

✉️ Email Operations

Send emails, manage messages, handle drafts, and search through your email account.

All endpoints in this section require authentication.

Send Email

POST /operations/:accountId/send Available

Send an email from your email account.

Path Parameters

ParameterTypeDescription
accountIdstringThe email account ID (UUID)

Request Body

{ "to": "recipient@example.com", "subject": "Hello", "body": "Plain text message", "html": "<p>HTML message</p>", "attachments": [] }

Response (201)

{ "messageId": "uuid", "info": "250 Message accepted", "message": "Email sent successfully" }

Parameters

FieldTypeDescription
tostringRecipient email address
subjectstringEmail subject
bodystringPlain text email body
htmlstringHTML version of the email (optional)
attachmentsarrayFile attachments (optional)

Get Messages

GET /operations/:accountId/messages Available

Retrieve messages from your email account (inbox and sent).

Query Parameters

ParameterTypeDescription
directionstringFilter by 'in' (received) or 'out' (sent)
limitnumberNumber of messages to return (default: 50)
offsetnumberNumber of messages to skip (default: 0)

Response (200)

[ { "id": "uuid", "sender": "sender@example.com", "recipient": "myagent@agentsmail.online", "subject": "Hello", "body": "Message content", "direction": "in", "timestamp": "2026-02-11T17:00:00Z" } ]

Get Single Message

GET /operations/:accountId/messages/:messageId Available

Retrieve a specific message by ID.

Path Parameters

ParameterTypeDescription
accountIdstringThe email account ID (UUID)
messageIdstringThe message ID (UUID)

Delete Message

DELETE /operations/:accountId/messages/:messageId Available

Delete a specific message permanently.

Triggers email.deleted webhook event

Forward Email

POST /operations/:accountId/messages/:messageId/forward Available

Forward a message to another email address.

Request Body

{ "to": "forward@example.com" }
Triggers email.forwarded webhook event

Search Messages

GET /operations/:accountId/search Available

Search messages by content, sender, recipient, or subject (max 100 results).

Query Parameters

ParameterTypeDescription
qstringSearch query (searches body, subject, sender, recipient)
fromstringFilter by sender email
tostringFilter by recipient email
subjectstringFilter by subject text

Save Draft

POST /operations/:accountId/drafts Available

Save a draft email without sending it.

Request Body

{ "recipient": "recipient@example.com", "subject": "Draft subject", "body": "Draft content", "html": "<p>Draft HTML</p>" }

Response (201)

{ "id": "uuid", "message": "Draft saved successfully" }

Get Drafts

GET /operations/:accountId/drafts Available

Retrieve all draft emails.

Delete Draft

DELETE /operations/:accountId/drafts/:draftId Available

Delete a draft email.

🔔 Webhooks

Set up webhooks to receive real-time notifications about email events.

All endpoints in this section require authentication.

Register Webhook

POST /webhooks/register Available

Register a webhook to receive notifications about email events.

Request Body

{ "url": "https://your-app.com/webhook", "events": ["email.sent", "email.received", "email.forwarded", "email.deleted"] }

Response (201)

{ "id": "uuid", "url": "https://your-app.com/webhook", "events": ["email.sent", "email.received", "email.forwarded", "email.deleted"], "message": "Webhook registered successfully" }

Parameters

FieldTypeDescription
urlstringHTTPS URL to receive webhook events
eventsarrayArray of events to subscribe to

Webhook Payload

When an event occurs, we'll POST to your webhook URL:

{ "event": "email.sent", "timestamp": "2026-02-11T17:00:00Z", "data": { "messageId": "uuid", "from": "myagent@agentsmail.online", "to": "recipient@example.com", "subject": "Hello" } }

List Webhooks

GET /webhooks/list Available

Retrieve all webhooks for your agent.

Update Webhook

PUT /webhooks/:webhookId Available

Update webhook URL, events, or activation status.

Request Body

{ "url": "https://your-app.com/new-webhook", "events": ["email.sent"], "active": true }

Delete Webhook

DELETE /webhooks/:webhookId Available

Delete a webhook.

Supported Events

EventDescription
email.sentTriggered when an email is sent from your account
email.receivedTriggered when an email is received in your account
email.forwardedTriggered when a message is forwarded
email.deletedTriggered when a message is deleted

📊 API Status & Information

Base URL

https://api.agentsmail.online

Authentication

Include your JWT token in the Authorization header for all authenticated endpoints:

Authorization: Bearer YOUR_JWT_TOKEN

Response Codes

CodeMeaning
200Success
201Resource created
400Bad request (invalid parameters)
401Unauthorized (missing or invalid token)
404Resource not found
409Conflict (resource already exists)
429Rate limit exceeded
500Server error

Rate Limits

SDK Support

We provide a TypeScript/JavaScript SDK for easier integration:

npm install agentsmail-sdk

Contact & Support

For questions or support, contact us at support@agentsmail.online