Save a draft
/api/v1/mailbox/messages/draftSaves (or, with replace_id, replaces) a draft in Drafts. Same fields as a send, JSON or multipart. Autosave by sending replace_id each time: the old copy is removed and the new id returned.
Errors
| Status | When |
|---|---|
401 |
No token, or the session expired or was signed out. Sign in again with POST /mailbox-auth/login. |
403 |
The account has a temporary password: until POST /security/password succeeds, every other call answers this with error_code: password_change_required. |
422 |
A field is invalid, or keep_attachments needs replace_id. |
Request body
toarray<string>Recipient addresses. At least one recipient across
to,ccandbcc.ccarray<string>Copy recipients: everyone sees them.
bccarray<string>Blind copies: delivered, but no recipient sees them.
subjectstringThe subject line.
body_textstringThe plain-text body. Send this,
body_html, or both.body_htmlstringThe HTML body.
in_reply_tostringThe Message-ID being answered, to thread the reply.
in_reply_to_idstringThat message's id here (
INBOX:4821), so it is flagged answered.referencesstringThe References header of the message being answered.
fromstringA shared mailbox to send as; must be one this mailbox may send from (see capabilities).
forward_attachments_fromstringForwarding: the message id whose attachments to include.
attachment_indexesarray<integer>Forwarding: which of its attachments (from its
attachments).attachmentsarray<string>Files, multipart only: up to 20, 25 MB in total.
replace_idstringThe draft this one replaces.
keep_attachmentsbooleanKeep the replaced draft's attachments (needs
replace_id).
Request
/api/v1/mailbox/messages/draftcurl -X POST 'https://courier.mailyte.com/api/v1/mailbox/messages/draft' \
-H 'Authorization: Bearer MAILBOX_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_html": "<p>Hi Tunde,</p>",
"replace_id": "Drafts:30"
}'const response = await fetch('https://courier.mailyte.com/api/v1/mailbox/messages/draft', {
method: 'POST',
headers: {
Authorization: 'Bearer MAILBOX_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_html": "<p>Hi Tunde,</p>",
"replace_id": "Drafts:30"
}),
});
const { data } = await response.json();import requests
response = requests.post(
"https://courier.mailyte.com/api/v1/mailbox/messages/draft",
headers={"Authorization": "Bearer MAILBOX_TOKEN"},
json={
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_html": "<p>Hi Tunde,</p>",
"replace_id": "Drafts:30"
},
)
data = response.json()["data"]<?php
$response = Http::withToken('MAILBOX_TOKEN')
->post('https://courier.mailyte.com/api/v1/mailbox/messages/draft', [
'to' => [
'tunde@example.com',
],
'subject' => 'The Q3 figures',
'body_html' => '<p>Hi Tunde,</p>',
'replace_id' => 'Drafts:30',
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://courier.mailyte.com/api/v1/mailbox/messages/draft")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer MAILBOX_TOKEN"
request["Content-Type"] = "application/json"
request.body = {
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_html": "<p>Hi Tunde,</p>",
"replace_id": "Drafts:30"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Successful Response
dataobjectidstringfolderstringattachmentsarray<object>indexintegerPosition in the message; pass it to the attachment download.
namestringtypestringMIME type, e.g.
application/pdf.sizeintegerBytes.
is_inlinebooleanAn image shown inside the body (a
cid:reference) rather than a file.content_idstring or nullThe
cid:the body refers to, for inline images.
application/json{
"type": "success",
"msg": "Draft saved",
"data": {
"id": "Drafts:31",
"folder": "Drafts",
"attachments": []
}
}Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | No token, or the session expired or was signed out. Sign in again with `POST /mailbox-auth/login`. |
403 | The account has a temporary password: until `POST /security/password` succeeds, every other call answers this with `error_code: password_change_required`. |
422 | A field is invalid, or `keep_attachments needs replace_id`. |
Every status, with what causes it and what to do, is on the error reference.