Skip to main content

Mail API

Ration exposes mail only through /apis/v1/mail. The API provides allowlisted, user-scoped mailbox, message, attachment, flag, and folder operations while authenticating clients with Ration bearer tokens. Paths not listed on this page are not available through the public Mail API.

This reference is the public contract. Mail resource operations preserve the status and JSON resource returned by Ration's mail service; Ration does not wrap or rename those resource responses. Integrations should use the fields documented here and tolerate additional fields in a response.

Authentication and path mapping

Send the Ration access token:

Authorization: Bearer <ration_access_token>
Accept: application/json

Ration executes the request as the authenticated user. Use the Ration bearer header shown above; do not include provider-specific authentication headers.

For mail resource operations, use the /apis/v1/mail prefix. For example:

Mail resourceRation 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 combinations documented below are available. Requests to account administration, security, storage, filters, automatic replies, raw message source, or any path outside the caller's /users/me mailbox tree return 404 unless Ration provides a separate documented endpoint.

Ration-specific convenience endpoints

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>"
}

Response: the message result wrapped as {"message": {...}}. Ration returns 403 {"error":"tenant_id_required"} when the authenticated user has no tenant context.

Request parameters

NameInTypeRequiredDescription
mailboxBodyStringYesTarget mailbox identifier.
draftBodyBooleanNoSet true to save rather than send.
from, replyToBodyAddress objectNoSender or reply-to identity.
to, cc, bccBodyAddress arrayNoRecipient lists.
subjectBodyStringNoMessage subject.
text, htmlBodyStringNoPlain-text and HTML content.
attachments, filesBodyArrayNoInline attachment payloads or stored file identifiers.
referenceBodyObjectNoReply, reply-all, or forward source.
replacePreviousBodyObjectNoExisting draft to replace.

Response parameters — 200 OK

NameTypeDescription
messageObjectStored-message result. Ration wraps this endpoint's result in message when necessary.
message.idNumberNew message identifier, when returned.
message.mailboxStringMailbox identifier, when returned.
message.sizeNumberMessage size in bytes, when returned.

Submit a draft

POST /apis/v1/mail/draft/submit

{
"mailbox_id": "<drafts_mailbox_id>",
"message_id": "123"
}

This submits the selected draft for delivery. The response status and JSON body contain the submission result. Recipient addresses from the submitted draft are added to Ration’s autocomplete data.

Request parameters

NameInTypeRequiredDescription
mailbox_idBodyStringYesMailbox containing the draft.
message_idBodyStringYesDraft message identifier.

Response parameters — 200 OK

NameTypeDescription
Response bodyObjectSubmission result returned by the mail service. Do not rely on an id or message field being present.

Download an attachment

GET /apis/v1/mail/attachment

Query parameters:

ParameterRequiredDescription
mailbox_idYesMailbox containing the message.
message_idYesMessage identifier.
attachment_idYesAttachment identifier.
filenameYesFilename used in the download response.

Response: attachment bytes as a download, rather than a JSON envelope.

Response parameters — 200 OK

NameInTypeDescription
Content-DispositionHeaderStringDownload filename, based on filename.
Response bodyBodyBinaryAttachment content.

Mailbox operations

The following Ration Mail API operations are available through the mail prefix.

MethodRation pathMain request parametersSuccessful response
GET/mail/users/me/mailboxesPagination and mailbox-list query options.Mailbox list and cursors.
POST/mail/users/me/mailboxesMailbox path/name and optional mailbox configuration.Created mailbox.
GET, PUT, DELETE/mail/users/me/mailboxes/:mailboxRead or manage one mailbox.Mailbox or deletion result.
GET, POST, PUT/mail/users/me/mailboxes/:mailbox/messagesList, create, or update a set of messages.Message list or operation result.
GET, PUT, DELETE/mail/users/me/mailboxes/:mailbox/messages/:messageRead or manage one message.Message or deletion result.
POST/mail/users/me/mailboxes/:mailbox/messages/:message/submitSubmit a stored draft.Submission result.

List mailboxes

GET /apis/v1/mail/users/me/mailboxes

Request parameters

NameInTypeRequiredDescription
countersQueryBooleanNoInclude mailbox counters when available. Used by the Ration client.
Other query parametersQueryStringNoPassed through only for this allowlisted list route. Use documented response cursors rather than relying on undocumented filters.

Response parameters — 200 OK

NameTypeDescription
totalNumberTotal number of matching mailboxes.
nextCursor, previousCursorString or BooleanCursor for another page, or false when unavailable.
resultsArrayMailbox records.
results[].idStringMailbox identifier.
results[].pathStringMailbox path/name.
results[].specialUseStringSpecial-use role such as Inbox, Sent, Drafts, or Trash when configured.

Create a mailbox

POST /apis/v1/mail/users/me/mailboxes

Request parameters

NameInTypeRequiredDescription
pathBodyStringYesMailbox name or path.
retentionBodyNumberNoRetention setting, where enabled for the tenant.
subscribedBodyBooleanNoWhether the mailbox is subscribed by default.
hiddenBodyBooleanNoReserved for Ration system mailboxes. A value of true or the string "true" is rejected.

Response parameters — 200 or 201

NameTypeDescription
idStringNew mailbox identifier.
pathStringCreated mailbox path.
nameStringDisplay name.
specialUseStringSystem role when one is assigned.

Read or manage one mailbox

GET|PUT|DELETE /apis/v1/mail/users/me/mailboxes/:mailbox

Request parameters

NameInTypeRequiredDescription
mailboxPathStringYesMailbox identifier.
pathBody (PUT)StringNoNew mailbox path/name.
retention, subscribedBody (PUT)Number, BooleanNoSupported mailbox settings.
hiddenBody (PUT)BooleanNoA value of true or the string "true" is rejected; this setting is reserved for Ration system mailboxes.

Response parameters — 200 OK

NameTypeDescription
idStringMailbox identifier.
path, nameStringCurrent mailbox path and display name.
successBooleanReturned for operations that do not return a mailbox object.

List messages in a mailbox

GET /apis/v1/mail/users/me/mailboxes/:mailbox/messages

Request parameters

NameInTypeRequiredDescription
mailboxPathStringYesMailbox identifier.
limitQueryNumberNoMaximum messages to return.
orderQueryStringNoSort order. The Ration client sends its selected sort value.
unseenQueryBooleanNoLimit results by read state when supported.
threadCountersQueryBooleanNoRequest thread counters where supported.
cursorQueryStringNoPagination cursor returned as nextCursor or previousCursor.
directionQueryStringNoCursor direction. The Ration client uses next when loading another page.

Response parameters — 200 OK

NameTypeDescription
totalNumberTotal matching messages.
nextCursor, previousCursorString or BooleanPagination cursor or false.
resultsArrayMessage summary records.
results[].idNumberMessage identifier within the mailbox.
results[].mailboxStringParent mailbox identifier.
results[].from, results[].toAddress object/arraySender and recipient summary.
results[].subjectStringMessage subject.
results[].dateISO 8601 stringMessage timestamp.
results[].unseen, results[].flaggedBooleanRead and flagged state.
results[].attachmentsArrayAttachment metadata, when present.

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 supplied in message—for example, update seen/flagged state or move messages.

Request parameters

NameInTypeRequiredDescription
mailboxPathStringYesSource or destination mailbox identifier.
messageBody (PUT)String or Number arrayYes for PUTOne or more message identifiers.
seenBody (PUT)BooleanNoRead state to apply.
moveToBody (PUT)StringNoDestination mailbox identifier.
restoreToOriginBody (PUT)BooleanNoRestore the selected message(s) to their original mailbox when supported.
Structured message fieldsBody (POST)ObjectYesSee Structured message fields.

Response parameters — 200 or 201

NameTypeDescription
Response bodyObjectCreated-message or bulk-operation result returned by the mail service. The exact result depends on the operation.

Read, update, or delete one message

GET|PUT|DELETE /apis/v1/mail/users/me/mailboxes/:mailbox/messages/:message

Request parameters

NameInTypeRequiredDescription
mailboxPathStringYesMailbox identifier.
messagePathNumberYesMessage identifier.
Message fieldsBody (PUT)ObjectNoUpdate fields accepted for an individual message. For bulk seen-state and moving messages, use the collection PUT endpoint above.

Response parameters — 200 OK

NameTypeDescription
idNumberMessage identifier.
mailboxStringMessage mailbox.
text, htmlStringRendered body content, when available.
headersArrayParsed message headers, when available.
attachmentsArrayAttachment metadata, when present.

For DELETE, the successful response contains the deletion result rather than a message object.

Submit a mailbox draft

POST /apis/v1/mail/users/me/mailboxes/:mailbox/messages/:message/submit

Request parameters

NameInTypeRequiredDescription
mailboxPathStringYesMailbox containing the draft.
messagePathNumberYesDraft message identifier.
Delivery fieldsBodyObjectNoOptional delivery fields supported for the draft.

Response parameters — 200 OK

NameTypeDescription
Response bodyObjectSubmission result returned by the mail service.

Structured message fields

When creating or saving a structured message, use the fields below as needed.

FieldTypePurpose
from, replyToAddress object{ "name": "…", "address": "…" } sender/reply address.
to, cc, bccAddress arrayRecipient lists.
subjectStringSubject line.
text, htmlStringPlain-text and HTML bodies.
draft, unseen, flaggedBooleanInitial message state.
attachmentsArrayInline attachment objects with filename, MIME type, base64 content, and optional content ID/disposition.
filesString arrayPreviously stored attachment IDs.
referenceObjectReply, reply-all, or forward source (mailbox, id, action, optional attachments).
replacePreviousObjectReplace an existing draft (mailbox, id).

The Ration composer creates structured messages with the fields above. File references in files are not publicly uploadable through this API; use inline attachments for an API-created draft or message.

Responses and errors

Ration-owned errors

Mail-service validation and missing-resource responses are forwarded unchanged. The errors below are generated by Ration itself and are safe for an integration to branch on.

StatusBodyMeaning
401Authentication errorThe 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.

Common successful statuses are 200 for reads/updates and 201 for creates. A downstream 400, 403, 404, or other non-2xx resource response is returned with its original status and JSON body.

Use cursors returned by list endpoints rather than offset-based pagination where the response provides nextCursor or previousCursor. Do not 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 place a Ration access token in browser-visible source, mobile logs, screenshots, or a third-party client that you do not control.