Save a draft

POST/api/v1/mailbox/messages/draft
Requires amailbox token— it acts as one mailbox holder, not as the organization.

Saves (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, cc and bcc.

  • ccarray<string>

    Copy recipients: everyone sees them.

  • bccarray<string>

    Blind copies: delivered, but no recipient sees them.

  • subjectstring

    The subject line.

  • body_textstring

    The plain-text body. Send this, body_html, or both.

  • body_htmlstring

    The HTML body.

  • in_reply_tostring

    The Message-ID being answered, to thread the reply.

  • in_reply_to_idstring

    That message's id here (INBOX:4821), so it is flagged answered.

  • referencesstring

    The References header of the message being answered.

  • fromstring

    A shared mailbox to send as; must be one this mailbox may send from (see capabilities).

  • forward_attachments_fromstring

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

    The draft this one replaces.

  • keep_attachmentsboolean

    Keep the replaced draft's attachments (needs replace_id).

Request

POST/api/v1/mailbox/messages/draft
curl -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"
  }'

Response

Successful Response

  • dataobject
    • idstring
    • folderstring
    • attachmentsarray<object>
      • indexinteger

        Position in the message; pass it to the attachment download.

      • namestring
      • typestring

        MIME type, e.g. application/pdf.

      • sizeinteger

        Bytes.

      • is_inlineboolean

        An image shown inside the body (a cid: reference) rather than a file.

      • content_idstring or null

        The cid: the body refers to, for inline images.

200application/json
{
  "type": "success",
  "msg": "Draft saved",
  "data": {
    "id": "Drafts:31",
    "folder": "Drafts",
    "attachments": []
  }
}

Returned inside the standard envelope.

Errors

StatusWhen
401No token, or the session expired or was signed out. Sign in again with `POST /mailbox-auth/login`.
403The account has a temporary password: until `POST /security/password` succeeds, every other call answers this with `error_code: password_change_required`.
422A field is invalid, or `keep_attachments needs replace_id`.

Every status, with what causes it and what to do, is on the error reference.