01
How responses work
- This page is the public contract.
- Mail resource operations keep the status and JSON resource that Ration’s mail service returns. Ration doesn’t wrap or rename them.
- Use the fields documented here, and tolerate extra fields in a response.
02
Authentication
Send the Ration access token. Ration runs the request as the authenticated user. Don’t include provider-specific authentication headers.
Authorization: Bearer <ration_access_token>
Accept: application/json03
Path mapping
For mail resource operations, add the /apis/v1/mail prefix. For example:
| Mail resource | Ration API path |
|---|---|
/users/me/mailboxes | /apis/v1/mail/users/me/mailboxes |
/users/me/mailboxes/:mailbox/messages | /apis/v1/mail/users/me/mailboxes/:mailbox/messages |
/users/me/mailboxes/:mailbox/messages/:message | /apis/v1/mail/users/me/mailboxes/:mailbox/messages/:message |
Only the method-and-path pairs on this page are available. Account administration, security, storage, filters, automatic replies, raw message source, and any path outside the caller’s /users/me mailbox tree return 404, unless Ration documents a separate endpoint for them.
04
Save a draft
POST /apis/v1/mail/draft. Creates a message in a mailbox and records the recipient addresses for Ration autocomplete. The request must contain mailbox plus a structured-message body.
{
"mailbox": "<drafts_mailbox_id>",
"draft": true,
"from": {"name": "Ada", "address": "ada@example.com"},
"to": [{"name": "Sam", "address": "sam@example.net"}],
"cc": [],
"bcc": [],
"subject": "Project update",
"text": "Hello Sam,\n\nHere is the update.",
"html": "<p>Hello Sam,</p><p>Here is the update.</p>"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Body | String | Yes | Target mailbox identifier. |
draft | Body | Boolean | No | Set true to save rather than send. |
from, replyTo | Body | Address object | No | Sender or reply-to identity. |
to, cc, bcc | Body | Address array | No | Recipient lists. |
subject | Body | String | No | Message subject. |
text, html | Body | String | No | Plain-text and HTML content. |
attachments, files | Body | Array | No | Inline attachment payloads or stored file identifiers. |
reference | Body | Object | No | Reply, reply-all or forward source. |
replacePrevious | Body | Object | No | Existing draft to replace. |
05
Save a draft: response
200 OK. The message result, wrapped as {"message": {...}}.
| Name | Type | Description |
|---|---|---|
message | Object | Stored-message result. Ration wraps this endpoint’s result in message when necessary. |
message.id | Number | New message identifier, when returned. |
message.mailbox | String | Mailbox identifier, when returned. |
message.size | Number | Message size in bytes, when returned. |
Ration returns 403 {"error":"tenant_id_required"} when the authenticated user has no tenant context.
06
Submit a draft
POST /apis/v1/mail/draft/submit. Submits the selected draft for delivery, and adds its recipient addresses to Ration’s autocomplete data.
{
"mailbox_id": "<drafts_mailbox_id>",
"message_id": "123"
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox_id | Body | String | Yes | Mailbox containing the draft. |
message_id | Body | String | Yes | Draft message identifier. |
07
Submit a draft: response
200 OK. The response status and JSON body contain the submission result.
| Name | Type | Description |
|---|---|---|
| Response body | Object | Submission result returned by the mail service. Do not rely on an id or message field being present. |
08
Download an attachment
GET /apis/v1/mail/attachment, with these query parameters:
| Parameter | Required | Description |
|---|---|---|
mailbox_id | Yes | Mailbox containing the message. |
message_id | Yes | Message identifier. |
attachment_id | Yes | Attachment identifier. |
filename | Yes | Filename used in the download response. |
09
Download an attachment: response
200 OK. The attachment bytes as a download, not a JSON envelope.
| Name | In | Type | Description |
|---|---|---|---|
Content-Disposition | Header | String | Download filename, based on filename. |
| Response body | Body | Binary | Attachment content. |
10
Mailbox operations
These operations are available through the mail prefix. Paths are relative to /apis/v1.
| Method | Ration path | Main request parameters | Successful response |
|---|---|---|---|
GET | /mail/users/me/mailboxes | Pagination and mailbox-list query options. | Mailbox list and cursors. |
POST | /mail/users/me/mailboxes | Mailbox path/name and optional mailbox configuration. | Created mailbox. |
GET, PUT, DELETE | /mail/users/me/mailboxes/:mailbox | Read or manage one mailbox. | Mailbox or deletion result. |
GET, POST, PUT | /mail/users/me/mailboxes/:mailbox/messages | List, create or update a set of messages. | Message list or operation result. |
GET, PUT, DELETE | /mail/users/me/mailboxes/:mailbox/messages/:message | Read or manage one message. | Message or deletion result. |
POST | /mail/users/me/mailboxes/:mailbox/messages/:message/submit | Submit a stored draft. | Submission result. |
11
List mailboxes
GET /apis/v1/mail/users/me/mailboxes
| Name | In | Type | Required | Description |
|---|---|---|---|---|
counters | Query | Boolean | No | Include mailbox counters when available. Used by the Ration client. |
| Other query parameters | Query | String | No | Passed through only for this allowlisted list route. Use documented response cursors rather than relying on undocumented filters. |
12
List mailboxes: response
200 OK
| Name | Type | Description |
|---|---|---|
total | Number | Total number of matching mailboxes. |
nextCursor, previousCursor | String or Boolean | Cursor for another page, or false when unavailable. |
results | Array | Mailbox records. |
results[].id | String | Mailbox identifier. |
results[].path | String | Mailbox path/name. |
results[].specialUse | String | Special-use role such as Inbox, Sent, Drafts or Trash, when configured. |
13
Create a mailbox
POST /apis/v1/mail/users/me/mailboxes
| Name | In | Type | Required | Description |
|---|---|---|---|---|
path | Body | String | Yes | Mailbox name or path. |
retention | Body | Number | No | Retention setting, where enabled for the tenant. |
subscribed | Body | Boolean | No | Whether the mailbox is subscribed by default. |
hidden | Body | Boolean | No | Reserved for Ration system mailboxes. A value of true or the string "true" is rejected. |
14
Create a mailbox: response
200 or 201
| Name | Type | Description |
|---|---|---|
id | String | New mailbox identifier. |
path | String | Created mailbox path. |
name | String | Display name. |
specialUse | String | System role, when one is assigned. |
15
Read or manage one mailbox
GET|PUT|DELETE /apis/v1/mail/users/me/mailboxes/:mailbox
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Path | String | Yes | Mailbox identifier. |
path | Body (PUT) | String | No | New mailbox path/name. |
retention, subscribed | Body (PUT) | Number, Boolean | No | Supported mailbox settings. |
hidden | Body (PUT) | Boolean | No | A value of true or the string "true" is rejected; this setting is reserved for Ration system mailboxes. |
16
Read or manage one mailbox: response
200 OK
| Name | Type | Description |
|---|---|---|
id | String | Mailbox identifier. |
path, name | String | Current mailbox path and display name. |
success | Boolean | Returned for operations that do not return a mailbox object. |
17
List messages in a mailbox
GET /apis/v1/mail/users/me/mailboxes/:mailbox/messages
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Path | String | Yes | Mailbox identifier. |
limit | Query | Number | No | Maximum messages to return. |
order | Query | String | No | Sort order. The Ration client sends its selected sort value. |
unseen | Query | Boolean | No | Limit results by read state, when supported. |
threadCounters | Query | Boolean | No | Request thread counters, where supported. |
cursor | Query | String | No | Pagination cursor returned as nextCursor or previousCursor. |
direction | Query | String | No | Cursor direction. The Ration client uses next when loading another page. |
18
List messages: response
200 OK
| Name | Type | Description |
|---|---|---|
total | Number | Total matching messages. |
nextCursor, previousCursor | String or Boolean | Pagination cursor, or false. |
results | Array | Message summary records. |
results[].id | Number | Message identifier within the mailbox. |
results[].mailbox | String | Parent mailbox identifier. |
results[].from, results[].to | Address object/array | Sender and recipient summary. |
results[].subject | String | Message subject. |
results[].date | ISO 8601 string | Message timestamp. |
results[].unseen, results[].flagged | Boolean | Read and flagged state. |
results[].attachments | Array | Attachment metadata, when present. |
19
Create or update mailbox messages
POST|PUT /apis/v1/mail/users/me/mailboxes/:mailbox/messages. Use POST to create a message. Use PUT to apply a supported action to the message IDs in message, for example to update seen or flagged state, or to move messages.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Path | String | Yes | Source or destination mailbox identifier. |
message | Body (PUT) | String or Number array | Yes for PUT | One or more message identifiers. |
seen | Body (PUT) | Boolean | No | Read state to apply. |
moveTo | Body (PUT) | String | No | Destination mailbox identifier. |
restoreToOrigin | Body (PUT) | Boolean | No | Restore the selected message(s) to their original mailbox, when supported. |
| Structured message fields | Body (POST) | Object | Yes | See Structured message fields. |
Response: 200 or 201. The body is the created-message or bulk-operation result returned by the mail service. The exact result depends on the operation.
20
Read, update or delete one message
GET|PUT|DELETE /apis/v1/mail/users/me/mailboxes/:mailbox/messages/:message
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Path | String | Yes | Mailbox identifier. |
message | Path | Number | Yes | Message identifier. |
| Message fields | Body (PUT) | Object | No | Update fields accepted for an individual message. For bulk seen-state and moving messages, use the collection PUT endpoint above. |
21
Read, update or delete one message: response
200 OK
| Name | Type | Description |
|---|---|---|
id | Number | Message identifier. |
mailbox | String | Message mailbox. |
text, html | String | Rendered body content, when available. |
headers | Array | Parsed message headers, when available. |
attachments | Array | Attachment metadata, when present. |
For DELETE, the response holds the deletion result rather than a message object.
22
Submit a mailbox draft
POST /apis/v1/mail/users/me/mailboxes/:mailbox/messages/:message/submit
| Name | In | Type | Required | Description |
|---|---|---|---|---|
mailbox | Path | String | Yes | Mailbox containing the draft. |
message | Path | Number | Yes | Draft message identifier. |
| Delivery fields | Body | Object | No | Optional delivery fields supported for the draft. |
Response: 200 OK. The body is the submission result returned by the mail service.
23
Structured message fields
Use these fields as needed when you create or save a structured message. The Ration composer uses the same fields.
| Field | Type | Purpose |
|---|---|---|
from, replyTo | Address object | { "name": "…", "address": "…" } sender/reply address. |
to, cc, bcc | Address array | Recipient lists. |
subject | String | Subject line. |
text, html | String | Plain-text and HTML bodies. |
draft, unseen, flagged | Boolean | Initial message state. |
attachments | Array | Inline attachment objects with filename, MIME type, base64 content, and optional content ID/disposition. |
files | String array | Previously stored attachment IDs. |
reference | Object | Reply, reply-all or forward source (mailbox, id, action, optional attachments). |
replacePrevious | Object | Replace an existing draft (mailbox, id). |
You can’t upload files for files through this API. For a draft or message created through the API, use inline attachments.
24
Errors
Ration generates these errors itself, so your integration can safely branch on them. Validation and missing-resource responses from the mail service are passed through unchanged.
| Status | Body | Meaning |
|---|---|---|
401 | Authentication error | The bearer token is missing, expired or invalid. |
403 | { "error": "tenant_id_required" } | The draft convenience endpoint requires a tenant-scoped user. |
404 | { "error": "mail_endpoint_not_available" } | The method/path pair is not part of the public Mail API. |
422 | { "error": "hidden_mailbox_not_allowed" } | A mailbox create/update attempted to set hidden to true. |
500 | { "error": "Proxy failed" } or { "error": "Internal server error" } | Ration could not complete the proxy or a convenience operation. Retry only when appropriate for your client. |
25
Statuses and pagination
- Successful reads and updates usually return
200, and creates return201. - A downstream
400,403,404or other non-2xx resource response comes back with its original status and JSON body. - Where a list response gives
nextCursororpreviousCursor, page with those cursors, not offsets. - Don’t assume IDs are interchangeable between mailboxes, messages, attachments and outbound queue entries.
Scope mail clients carefully. The mail proxy acts as the bearer-token user. Never put a Ration access token in browser-visible source, mobile logs, screenshots, or a third-party client you don’t control.
Last reviewed 27 November 2026.