Mail API

Ration exposes mail only through <code>/apis/v1/mail</code>: allowlisted, user-scoped mailbox, message, attachment, flag and folder operations, authenticated with Ration bearer tokens. Paths not listed here are not available.

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/json

03

Path mapping

For mail resource operations, add 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 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>"
}
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.

05

Save a draft: response

200 OK. The message result, wrapped as {"message": {...}}.

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.

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"
}
NameInTypeRequiredDescription
mailbox_idBodyStringYesMailbox containing the draft.
message_idBodyStringYesDraft message identifier.

07

Submit a draft: response

200 OK. The response status and JSON body contain the submission result.

NameTypeDescription
Response bodyObjectSubmission 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:

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

09

Download an attachment: response

200 OK. The attachment bytes as a download, not a JSON envelope.

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

10

Mailbox operations

These operations are available through the mail prefix. Paths are relative to /apis/v1.

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.

11

List mailboxes

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

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.

12

List mailboxes: response

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.

13

Create a mailbox

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

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.

14

Create a mailbox: response

200 or 201

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

15

Read or manage one mailbox

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

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.

16

Read or manage one mailbox: response

200 OK

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

17

List messages in a mailbox

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

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.

18

List messages: response

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.

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.

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: 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

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.

21

Read, update or delete one message: response

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

NameInTypeRequiredDescription
mailboxPathStringYesMailbox containing the draft.
messagePathNumberYesDraft message identifier.
Delivery fieldsBodyObjectNoOptional 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.

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).

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.

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.

25

Statuses and pagination

  • Successful reads and updates usually return 200, and creates return 201.
  • A downstream 400, 403, 404 or other non-2xx resource response comes back with its original status and JSON body.
  • Where a list response gives nextCursor or previousCursor, 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.

Next guideChat API →

Last reviewed 27 November 2026.

Still stuck?

Chat with our support team. Tell us what you were doing and what you saw, and a person will pick it up. You can also email support@ration.works.

Buying or moving to Ration?

For plans, migration or an on-premise deployment, talk to our sales team.