Save Draft / Template

Purpose

This API is used to compose and save an email as a draft or a template in a specified user account.

OAuth Scope

Use the scope

ZohoMail.messages.ALL (or) ZohoMail.messages.CREATE

to generate the Authtoken.

ALL - Grants full access to messages.

CREATE - Grants access to create messages.

Request URL

Method: POST

https://mail.zoho.com/api/accounts/{accountId}/messages

Path Parameters

  • accountId* long
    • This key is used to identify the account from which the email has to be sent. It is generated during account addition.
    • This parameter can be fetched from Get All User Accounts API.

Request Body (JSON object)

  • fromAddress* string
    • Provide the sender's email address (associated to the authenticated account).
    • Allowed values: Valid email address corresponding to the authenticated account for the From field.
  • toAddress* string
    • Provide the recipient's email address.
    • Allowed values: Valid recipient email address for the To field.
  • mode* string
    • Specifies whether the content should be saved as a draft or a template.
    • Allowed values:
      • draft
      • template
  • ccAddress string
    • Provide the recipient's email address for the Cc field.
    • Allowed values: Valid recipient email address for the Cc field.
  • bccAddress string
    • Provide the recipient's email address for the Bcc field.
    • Allowed values: Valid recipient email address for the Bcc field.
  • subject string
    • Provide the subject of the email.
  • content string
    • Provide the content of the email.
  • mailFormat string
    • Specify the format in which the mail needs to be sent. The value can be
      • html
      • plaintext
    • The default value is html.
  • askReceipt string
    • Specifies whether Read receipt from the recipient is requested or not.
    • Allowed values:
      • yes - Requesting a read receipt.
      • no - Not requesting a read receipt
  • encoding string
    • Specifies the encoding that is to be used in the email content.
    • Allowed values:
      • Big5
      • EUC-JP
      • EUC-KR
      • GB2312
      • ISO-2022-JP
      • ISO-8859-1
      • KOI8-R
      • Shift_JIS
      • US-ASCII
      • UTF-8
      • WINDOWS-1251
      • X-WINDOWS-ISO2022JP
    • The default value is UTF-8.
  • inReplyTo string
    • Provide the Message-ID present in the header of the email being replied to. 
      The Message-ID will be in the format: <19c55e0895e.21bfbbd111.675082323857038432@140.com>.
    • First, retrieve the messageId using the List Emails API. Then, use this value to obtain the email’s Message-ID from either the Get Email Header API or the Get Original Message API.
  • refHeader string
    • Provide the Message-IDs of all previous emails in the thread, space-separated in chronological order. 
      The Message-ID will be in the format <19c55e0895e.21bfbbd111.675082323857038432@140.com>.
    • First, retrieve the messageId using the List Emails API. Then, use this value to obtain the email’s Message-ID from either the Get Email Header API or the Get Original Message API.

Note:

  • inReplyTo and refHeader are optional parameters, applicable only in reply scenarios.
  • inReplyTo must be provided when saving a draft as a reply to a specific email.
  • refHeader must be provided additionally when the reply is part of an existing email thread, to maintain the complete thread history.

 

* - Mandatory parameter

Response Codes

Refer here for the response codes and their meaning.

Sample Request

Copiedcurl "https://mail.zoho.com/api/accounts/123456789/messages" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization:Zoho-oauthtoken *****" \
-d '{
        "mode": "draft",
        "subject": "Regd. Marketing Brochures",
        "fromAddress": "rebecca@zylker.com",
        "mailFormat": "html",
        "toAddress": "justinc@zylker.com",
        "content": "Hi Justin, please share the brochure content with the marketing team before proceeding with it. Thanks.",
        "inReplyTo": "<19c55e0895e.21bfbbd111.675082323857038432@zoho.com>",
        "refHeader": "<19c55e0895e.21bfbbd111.675082323857038431@zoho.com> <19c55e0895e.21bfbbd111.675082323857038432@zoho.com>"
    }'