Create Email Drafts
Purpose
To create email drafts. in Zoho CRM. The drafts are saved in the Email related list of the corresponding record, with a limit of 100 email drafts per API call.
Endpoints
- POST /{module_API_name}/{record_ID}/__email_drafts
Request Details
Request URL
{api-domain}/crm/{version}/{module_API_name}/{record_ID}/__email_drafts
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Supported modules
Leads, Contacts, Deals, Accounts, Sales Orders, Purchase Orders, Invoices, Quotes, Cases, and Custom modules.
Scope
ZohoCRM.Modules.ALL
(or)
ZohoCRM.Modules.{module_name}.{operation_type}
Possible Module Names
leads, accounts, contacts, deals, quotes, salesorders, purchaseorders, invoices, cases, and custom
Possible operation types
ALL - Full access to modules
CREATE - Create access for the module
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v8/Leads/2309216000000488477/__email_drafts"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@createdrafts.json"
Input JSON
- reply_toemail address, optional
The email address that you want the user to reply to after receiving the mail.
- fromemail address, mandatory
The email address from which the email will be sent.
- toJSON array, optional
An array of JSON objects specifying the recipient(s) of the email. Each object should include the recipient's name and email address. Add multiple JSON objects to create email drafts for multiple recipients.
- ccJSON array, optional
An array of JSON objects for CC recipients. Each object includes the recipient's name and email address. Add multiple JSON objects to include multiple CC recipients.
- bccJSON array, optional
An array of JSON objects for BCC recipients. Each object includes the recipient's name and email address. Add multiple JSON objects for multiple BCC recipients.
- rich_textBoolean, mandatory
Specify the email format. The possible options are :
true : rich text
false : plain text - subjectString, optional
The subject of the email.
- contentString, optional
The email content or body in plain text or rich text format.
- schedule_detailsJSON object, optional
Details for scheduling the email. Please note that created drafts will be available in the drafts section and not the scheduled section of the Email related list.
- timeDateTime, mandatory if schedule_details key is specified
The scheduled time for the draft. Please note that this time should be in the future.
- inventory_detailsJSON object, optional
Details related to inventory templates for the email. This key is valid only for inventory modules.
- inventory_templateString, mandatory if inventory_details key is specified
The unique ID of the inventory template you want to use in your email.
- paper_typeString, optional
The paper type for digital printing.
Possible values: A4, default, us_letter. The default value is A4. - view_typeString, optional
The way you want to view the template in.
Possible values:portrait,landscape. The default value is portrait.
- attachmentsJSON array, optional
An array of attachment details. You can upload the files using Files API.
- idString, mandatory if attachments key is specified
The unique ID of the attachment.
- file_nameString, mandatory
The file name of the attachment. Please note that this name will override the actual name of the attachment.
Sample Input
Copied{
"__email_drafts":[
{
"reply_to":"pat.boyle@zylker.com",
"from":"patricia.boyle@zylker.com",
"to":[
{
"user_name":"user1",
"email":"user1@zylker.com"
}
],
"cc":[
{
"user_name":"user2",
"email":"user2@zylker.com"
}
],
"bcc":[
{
"user_name":"user4",
"email":"user4email@zoho.com"
}
],
"subject":"Test Draft",
"content":"This is the email content.",
"rich_text":true,
"schedule_details":{
"time":"2023-11-30T18:40:00+05:30"
},
"attachments":[
{
"id":"0b9e5596cdd8cafe6a5c09f78f095bd6434c863110a6d1e094285c6ebf9dd0d5db4eff3bbccadddbf58afe55b1dd7c71",
"file_name":"attachment.txt"
}
]
}
]
}
Possible Errors
- INVALID_REQUEST_METHODHTTP 400
The request method is incorrect.
Resolution: Use the HTTP POST method to make this API call. Any other request method will result in this error. - INVALID_DATAHTTP 400
- You have specified an invalid record ID in the request URL.
Resolution: Specify a valid Record ID in the request URL. - You have specified an invalid attachment ID in the request body.
Resolution: Specify a valid attachment ID in the request body.
- You have specified an invalid record ID in the request URL.
- MANDATORY_NOT_FOUNDHTTP 400
You have not specified one or more of the mandatory keys in the input body.
Resolution: Specify all the mandatory keys. Refer to the Input JSON section to know more. - INVALID_MODULEHTTP 400
The module name given seems to be invalid.
Resolution: Specify a valid module API name in the request URL. - NOT_ALLOWEDHTTP 400
Schedule time should not be past time.
Resolution: Specify a future time for the schedule_details key value. - AUTHENTICATION_FAILUREHTTP 401
You have not authorized the API call with valid access token.
Resolution: Include a valid access token in the request header to authorize the API call. - OAUTH_SCOPE_MISMATCHHTTP 401
The access token you have used to make this API call does not have the required scope.
Resolution: Generate a new access token with the required scopes for this API. Refer to the Scope section at the beginning of this page for the list of required scopes. - INVALID_URL_PATTERNHTTP 404
The request URL is incorrect.
Resolution: Specify a valid request URL. Refer to the request URL section at the beginning of this page for more details. - INTERNAL_ERRORHTTP 500
Unexpected and unhandled exception in the server.
Resolution: Contact the support team at support@zohocrm.com.
Sample Response
Copied{
"__email_drafts": [
{
"code": "SUCCESS",
"details": {
"id": "4f8efdcbaf23fd33c939217d4e14222d2b151e840926b794ac5cfa907b76bc12"
},
"message": "Draft created Successfully",
"status": "success"
}
]
}