Email API
JSON reference for connecting your agents and applications to Ace Email.
This reference defines the API integration contract. The endpoints described are not enabled yet; the examples illustrate the intended requests and responses.
Getting started
Use your full email address and normal mailbox password to obtain a token. Then send it in the Authorization header. Access is limited to that account’s resources.
curl --request POST 'https://ace.email/api/v1/auth/login' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{"email":"usuario@ace.email","password":"TU_CONTRASEÑA","device_name":"my-agent"}'
curl 'https://ace.email/api/v1/messages?folder=unread&per_page=30' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Accept: application/json'
Authentication
Tokens will be valid for 365 days. API logout will revoke the current token. Changing the password through admads or deleting the account will revoke its tokens. This API does not grant administration access.
Authorization: Bearer YOUR_TOKENAccept: application/jsonContent-Type: application/jsonNo matching operations.
Access
POST/auth/loginObtain a token with mailbox credentials
{
"email": "usuario@ace.email",
"password": "TU_CONTRASEÑA",
"device_name": "my-agent"
}
{
"data": {
"access_token": "example_token_not_a_credential",
"token_type": "Bearer",
"expires_in": 31536000
}
}
POST/auth/logoutRevoke the current token
{
"data": {
"revoked": true
}
}
GET/meRetrieve the authenticated account
{
"data": {
"email": "usuario@ace.email",
"name": "Example User"
}
}
Folders and messages
GET/foldersList folders and views with counts
{
"data": [
{
"id": "inbox",
"name": "Inbox",
"is_virtual": false,
"total": 143,
"unread": 12
},
{
"id": "unread",
"name": "Unread",
"is_virtual": true,
"total": 12,
"unread": 12
}
]
}
GET/messagesList and search message metadata
Query parameters
folder=inboxq=invoiceunread=truestarred=falsehas_attachments=truelabel_id=10page=1per_page=30{
"data": [
{
"id": 123,
"folder": "inbox",
"subject": "Example message",
"from": [
{
"address": "contact@example.net",
"name": "Example Contact"
}
],
"to": [
{
"address": "usuario@ace.email"
}
],
"date": "2026-11-24T12:00:00Z",
"is_read": false,
"is_starred": false,
"has_attachments": true,
"version": 1
}
],
"meta": {
"page": 1,
"per_page": 30,
"total": 143,
"last_page": 5
}
}
GET/messages/{id}Read text, HTML and attachment metadata
{
"data": {
"id": 123,
"folder": "inbox",
"subject": "Example message",
"from": [
{
"address": "contact@example.net",
"name": "Example Contact"
}
],
"to": [
{
"address": "usuario@ace.email"
}
],
"date": "2026-11-24T12:00:00Z",
"is_read": false,
"is_starred": false,
"has_attachments": true,
"version": 1,
"body_text": "Example message body.",
"body_html": "<p>Example message body.</p>",
"cc": [],
"bcc": [],
"reply_to": [],
"attachments": [
{
"id": 456,
"name": "example.txt",
"content_type": "text/plain",
"size": 4
}
]
}
}
GET/messages/{id}/attachments/{attachment_id}Get a complete Base64 attachment
{
"data": {
"id": 456,
"name": "example.txt",
"content_type": "text/plain",
"size": 4,
"encoding": "base64",
"content": "SG9sYQ=="
}
}
GET/messages/{id}/originalGet the EML original as JSON with Base64
{
"data": {
"id": 123,
"content_type": "message/rfc822",
"encoding": "base64",
"content": "RnJvbTogY29udGFjdEBleGFtcGxlLm5ldA0KVG86IHVzdWFyaW9AYWNlLmVtYWlsDQpTdWJqZWN0OiBFeGFtcGxlDQoNCkhlbGxvDQo="
}
}
Actions
read, unread, star and unstar change flags. archive, inbox, spam and trash move messages; inbox can restore from Trash. snooze requires snoozed_until in ISO 8601. labels accepts your own label_ids. Permanent deletion is not defined.
POST/messages/{id}/actionsApply an action to one message
{
"action": "read",
"version": 1
}
{
"data": {
"id": 123,
"is_read": true,
"version": 2
}
}
POST/messages/actionsRun a batch with individual results
{
"action": "archive",
"messages": [
{
"id": 123,
"version": 1
},
{
"id": 124,
"version": 2
}
]
}
{
"data": [
{
"id": 123,
"success": true,
"version": 2
},
{
"id": 124,
"success": false,
"error": {
"code": "not_found",
"message": "Message unavailable."
}
}
]
}
Drafts and delivery
POST/draftsCreate a draft with recipients and attachments
{
"to": [
{
"address": "contact@example.net"
}
],
"cc": [],
"bcc": [],
"subject": "Example subject",
"body_text": "Hello.",
"body_html": "<p>Hello.</p>",
"attachments": [
{
"name": "example.txt",
"content_type": "text/plain",
"size": 4,
"encoding": "base64",
"content": "SG9sYQ=="
}
]
}
{
"data": {
"id": 789,
"status": "draft",
"version": 1
}
}
PATCH/drafts/{id}Update draft fields
{
"version": 1,
"subject": "Updated subject",
"body_text": "Updated body."
}
{
"data": {
"id": 789,
"status": "draft",
"version": 2
}
}
POST/drafts/{id}/sendRequest delivery with Idempotency-Key
Idempotency-Key: send-example-789{
"version": 2
}
{
"data": {
"id": 789,
"status": "queued",
"version": 3
}
}
POST/messages/{id}/replyCreate a reply draft without sending it
{
"body_text": "Thank you.",
"reply_all": false
}
{
"data": {
"id": 790,
"status": "draft",
"in_reply_to": "<example@example.net>",
"version": 1
}
}
POST/messages/{id}/forwardCreate a forward draft without sending it
{
"to": [
{
"address": "colleague@example.net"
}
],
"body_text": "For your review.",
"include_attachments": true
}
{
"data": {
"id": 791,
"status": "draft",
"version": 1
}
}
Exports
Exports will run in the background using the requested folder and filters. Poll every 5 seconds until status=completed and retrieve result using the owner’s token. The result will be one JSON with messages, Base64 attachments and errors for omissions. It expires after 24 hours; messages over 30 MB and security-blocked content appear in the report.
POST/exportsRequest one JSON with all messages
{
"folder": "unread",
"q": "invoice",
"has_attachments": true
}
{
"data": {
"id": "exp_example_123",
"status": "pending"
}
}
GET/exports/{id}Check progress and expiry
{
"data": {
"id": "exp_example_123",
"status": "completed",
"total": 143,
"exported": 142,
"skipped": 1,
"expires_at": "2026-11-25T12:00:00Z"
}
}
GET/exports/{id}/resultGet the full JSON using the owner’s token
{
"schema_version": "1.0",
"folder": "inbox",
"total": 1,
"exported": 1,
"skipped": 0,
"messages": [
{
"id": 123,
"folder": "inbox",
"subject": "Example message",
"from": [
{
"address": "contact@example.net",
"name": "Example Contact"
}
],
"to": [
{
"address": "usuario@ace.email"
}
],
"date": "2026-11-24T12:00:00Z",
"is_read": false,
"is_starred": false,
"has_attachments": true,
"version": 1,
"body_text": "Example message body.",
"body_html": "<p>Example message body.</p>",
"attachments": [
{
"id": 456,
"name": "example.txt",
"content_type": "text/plain",
"size": 4,
"encoding": "base64",
"content": "SG9sYQ=="
}
]
}
],
"errors": []
}
Reading, actions and sending
- Reading messages and attachments will not mark them as read. Use the read action to change that flag.
- Use IDs returned by the API, not IMAP UIDs. version detects concurrent changes with a 409 error.
- Sending requires Idempotency-Key. The same key and content return the original operation; different content produces a 409. Uncertain delivery has status uncertain and is not automatically retried.
Contract limits
30 messages per page by default, up to 100. Batches up to 100 IDs. Messages up to 30 MB, attachments up to 20 MB, at most 20 attachments and 50 recipients per delivery. Base64 increases JSON size. Downloads will respect security checks.
Per token per minute: 60 reads, 30 writes, 10 sends. Login: 5 attempts per account/IP, capped at 20 per IP. A 429 will include Retry-After.
Errors and retries
Errors always use JSON, with a stable code and request ID. Connection failures will be distinguished from incorrect passwords. Batches will return one result per message, including partial failures.
invalid_credentials / invalid_tokenforbiddennot_foundconflictexport_expired / message_unavailablepayload_too_largevalidation_errorsecurity_check_failedrate_limitedmail_server_unavailable{
"error": {
"code": "validation_error",
"message": "Invalid request.",
"details": {
"email": [
"A valid email address is required."
]
},
"request_id": "req_example_123"
}
}