Create or update a draft
const url = 'https://mail.work.optidata.cloud/api/mail/mailboxes/78/drafts/save';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"draft_id":"918","to":["john.roe@example.com"],"cc":[],"bcc":[],"subject":"Quarterly report","body":"<p>Hi John, the report is attached.</p>","type":"new","is_read_receipt_enabled":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://mail.work.optidata.cloud/api/mail/mailboxes/78/drafts/save \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "draft_id": "918", "to": [ "john.roe@example.com" ], "cc": [], "bcc": [], "subject": "Quarterly report", "body": "<p>Hi John, the report is attached.</p>", "type": "new", "is_read_receipt_enabled": false }'Save the current state of a composition. Omit draft_id to create a new
draft; send it to update the one you already have — this is the call an
autosave loop makes.
Set reply_server_message_id when the composition answers an existing
message, and type to say how (new, reply or forward). The returned
draft’s id is the draft_id you later hand to a send operation.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”Id of the mailbox. Every mailbox the caller may use is listed in their account.
Request Bodyrequired
Section titled “Request Bodyrequired”The state of a composition to save.
object
Id of the draft to update. Omit to create a new one.
Id of the message being answered, for a reply or a forward.
Recipient addresses.
HTML body.
Files carried by the draft.
object
Ask the recipient’s client for a read receipt.
Examples
{ "draft_id": "918", "to": [ "john.roe@example.com" ], "cc": [], "bcc": [], "subject": "Quarterly report", "body": "<p>Hi John, the report is attached.</p>", "type": "new", "is_read_receipt_enabled": false}Responses
Section titled “ Responses ”The saved draft.
object
A message being composed.
object
How an outgoing message came to be.
Where a draft stands. not_sent is still being written, sending has been
handed to the queue, sent has left, and failed could not be delivered.
The message this draft answers, when it answers one.
One participant of a message.
object
Display name, when one is known.
The role the address plays: f sender, t recipient, c carbon copy,
b blind copy, r reply-to.
One participant of a message.
object
Display name, when one is known.
The role the address plays: f sender, t recipient, c carbon copy,
b blind copy, r reply-to.
One participant of a message.
object
Display name, when one is known.
The role the address plays: f sender, t recipient, c carbon copy,
b blind copy, r reply-to.
One participant of a message.
object
Display name, when one is known.
The role the address plays: f sender, t recipient, c carbon copy,
b blind copy, r reply-to.
The files uploaded to the draft.
object
A mailbox the user has access to.
object
Cross-application user id the mailbox belongs to.
Example
{ "message": "Draft saved successfully.", "draft": { "id": 918, "type": "new", "status": "not_sent", "from": [ { "name": "Jane Doe", "email": "jane.doe@acme.example", "type": "f" } ], "to": [ { "name": "Jane Doe", "email": "jane.doe@acme.example", "type": "f" } ], "cc": [ { "name": "Jane Doe", "email": "jane.doe@acme.example", "type": "f" } ], "bcc": [ { "name": "Jane Doe", "email": "jane.doe@acme.example", "type": "f" } ] }, "mailbox": { "id": 78 }}Missing, malformed or expired authentication key.
Authentication failures use an error key rather than message.
object
Examples
No bearer token sent
{ "error": "JWT passport exception: Missing bearer token in request"}The caller may not act on this mailbox, user or resource.
Generic error envelope used by policy, binding and framework failures.
object
Human-readable description of the failure.
Examples
{ "message": "This action is unauthorized."}The request body or query string failed validation.
object
The first validation message.
Validation messages keyed by field name.
object
Examples
{ "message": "The conversations field is required.", "errors": { "conversation_ids": [ "The conversations field is required." ] }}Rate limit exceeded. Retry after the window resets.
Generic error envelope used by policy, binding and framework failures.
object
Human-readable description of the failure.
Examples
{ "message": "Too Many Attempts."}