Hi All,
Welcome back to another week of Kaizen!
Emails are a core channel for customer communication in any CRM system. In Zoho CRM, emails can be associated with records across multiple modules.
In this post, we will focus on email associations with the records of the Deals Module.
Deal Prediction Mechanism
When an email is received for a Contact:
- If the contact has only one open deal, the email is linked to that deal.
- If the contact has multiple open deals, the email is linked to the most recently modified deal, provided the deal is not closed-lost.
- If there are no valid open deals, the email is not linked to any deal.
While deal prediction simplifies email association, certain scenarios require manual control over how emails are linked to deals.
In such cases you might want to:
- Correct an incorrect association.
- Attach an email to a deal that the prediction could not infer.
Zoho CRM provides two focused APIs for this:
- Link Deal to Emails API.
- Unlink Deal from Emails API.
These APIs do not create emails — they simply manage associations.
Link Deal to Emails API
Endpoints
POST /Contacts/{contacts_record_ID}/Emails/actions/link_record
POST /Contacts/{contacts_record_ID}/Emails/{message_ID}/actions/link_record
Sample request for linking a single email
Request URL
POST
https://www.zohoapis.com/crm/v8/Contacts/5843104000005878180/Emails/b9c24f3b403f8c3b197f2b8ab967c104d597ab1b968e3b8a59437278f4f26f77/actions/link_record
Input JSON
{ "Emails": [ { "linked_record": { "module": { "api_name": "Deals", "id": "5843104000000003735" }, "name": "Travel Insurance", "id": "5843104000004382122" }, "owner": { "name": "Patricia Boyle", "id": "5843104000000424672" } } ] } |
You can also link a single email by mentioning message id in the request body in the endpoint POST /Contacts/{contacts_record_ID}/Emails/actions/link_record
Request URL
POST
https://www.zohoapis.com/crm/v8/Contacts/5843104000005878180/Emails/actions/link_record
Input JSON
{ "Emails": [ { "message_id": "b9c24f3b403f8c3b197f2b8ab967c104d597ab1b968e3b8a59437278f4f26f77", "linked_record": { "module": { "api_name": "Deals", "id": "5843104000000003735" }, "name": "Travel Insurance", "id": "5843104000004382122" }, "owner": { "name": "Patricia Boyle", "id": "5843104000000424672" } } ] } |
Response
{ "Emails": [ { "code": "SUCCESS", "details": { "message_id": "b9c24f3b403f8c3b197f2b8ab967c104d597ab1b968e3b8a59437278f4f26f77" }, "message": "email has been linked with the deal successfully", "status": "success" } ] } |
Sample request for linking multiple emails
Input JSON
{ "Emails": [ { "owner": { "name": "Patricia Boyle", "id": "5843104000000424672" }, "message_id": "8937fb892cc6f15b95bc22ecb91b6f85e9f60916ef9314d484543df546f09ad1", "linked_record": { "module": { "api_name": "Deals", "id": "5843104000000003735" }, "name": "Travel Insurance", "id": "5843104000004382122" } }, { "owner": { "name": "Patricia Boyle", "id": "5843104000000424672" }, "message_id": "6622e532084a2c329b44f4d7c58a93bb2f616d21e1e73cc1e9cc71d24ef6b5f5", "linked_record": { "module": { "api_name": "Deals", "id": "5843104000000003735" }, "name": "Travel Insurance", "id": "5843104000004382122" } } ] } |
Response
{ "Emails": [ { "code": "SUCCESS", "details": { "message_id": "8937fb892cc6f15b95bc22ecb91b6f85e9f60916ef9314d484543df546f09ad1" }, "message": "email has been linked with the deal successfully", "status": "success" }, { "code": "SUCCESS", "details": { "message_id": "6622e532084a2c329b44f4d7c58a93bb2f616d21e1e73cc1e9cc71d24ef6b5f5" }, "message": "email has been linked with the deal successfully", "status": "success" } ] } |
Keys
- owner (JSON object, mandatory): Specify the details of the user whose email you want to link. It consists of the following keys
- name: Specify the name of the user whose email you want to link.
- id: Specify the ID of the user whose email you want to link.
- message_id (string, mandatory when message_id is not mentioned in the endpoint): Specify the unique message ID of the email to which the deal will be linked. You can obtain message ID of a record through Get Emails of a Record API. [/crm/[version}/Contacts/{contacts_record_ID}/Emails]
- linked_record(JSON object, mandatory): Specify the details of the Deals record to be linked to the email. It consists of the following mandatory keys
- module(JSON object, mandatory): Specify the details of the Deals module. It consists of the following keys
- api_name: Specify the API name of the Deals module.
- id: Specify the ID of the Deals module.
- name: Specify the name of the Deals record that the email must be linked to. Refer to the field: Deal_Name in the Get Records API for the Deals record. [/crm/[version}/Deals/{deals_record_ID}] in the Get Records API.
- id: Specify the ID of the Deals record that the email must be linked to.
Notes
- An email can be linked to only one deal at a time.
- You can link multiple emails in a single request by providing multiple Emails objects in the request body.
- This API works only with existing email records.
Unlink Deal from Emails API
If an email is linked to the wrong deal through deal prediction or the Link Deal to Emails API, you can use the
Unlink Deal from Emails API.
Endpoints
DELETE /Contacts/{contacts_records_ID}/Emails/actions/link_record?owner_id={owner_ID}&message_ids={message_ID1},{message_ID2},..
DELETE /Contacts/{contacts_records_ID}/Emails/{message_id}/actions/link_record?owner_id={owner_ID}
Sample request for unlinking multiple emails
Request URL
DELETE
https://www.zohoapis.com/crm/v8/Contacts/5843104000000425349/Emails/actions/link_record?owner_id=5843104000000424672&message_ids=8937fb892cc6f15b95bc22ecb91b6f85e9f60916ef9314d484543df546f09ad1,6622e532084a2c329b44f4d7c58a93bb2f616d21e1e73cc1e9cc71d24ef6b5f5
Response
{ "Emails": [ { "code": "SUCCESS", "details": { "message_id": "8937fb892cc6f15b95bc22ecb91b6f85e9f60916ef9314d484543df546f09ad1" }, "message": "email has been unlinked from the deal successfully", "status": "success" }, { "code": "SUCCESS", "details": { "message_id": "6622e532084a2c329b44f4d7c58a93bb2f616d21e1e73cc1e9cc71d24ef6b5f5" }, "message": "email has been unlinked from the deal successfully", "status": "success" } ] } |
Mandatory Parameters
- owner_ID Specify the unique ID of a user whose email you want to unlink.
- message_ids Specify the unique message IDs of the emails which you want to unlink. You can obtain message IDs of a record through Get Emails of a Record API.
Example use case
- Prediction linked an email to deal A.
- Your business logic determines that the email belongs to deal B.
- Call the Unlink API.
- Call the Link API with the correct deal.
Key behavior
- Unlinking does not delete the email.
- Email remains visible under the Contact.
- Only the Deal association is removed.
Link Deal to Emails API v/s Associate Email with a Record API
At first glance, these two APIs may look similar because both are about emails and their record associations. However, they serve different purposes.
The Associate Email with a Record API is used to create and store an email in Zoho CRM and associate it with a record. You must provide the complete email details such as From, To, CC, Subject, Content, attachments, and the original message id. In short, this API is used when the email does not yet exist in Zoho CRM and needs to be logged as a new email record and associated with a records in modules like Leads, Contacts, Deals etc.
On the other hand, the Link Deal to Emails API does not create an email. Instead, it works only with emails that already exist in CRM. It allows you to associate or re-associate a Contact's emails with a Deal. It is primarily used to control which deal an existing email should be linked to.
- Use Associate Email API when you want to log a new email into CRM and associate it to a record.
- Use Link/Unlink Deal APIs when you want to manage the Deal association of an existing email.
Key differences
Aspect | Associate Email API | Link Deal APIs |
Creates Email Record | Yes | No |
Requires email content | Yes | No |
Works on existing emails | No | Yes |
Purpose | Log emails into CRM and associated to a record | Manage associations between deal and contact's emails. |
Zoho CRM’s Deal Prediction Mechanism is designed to reduce manual effort, but APIs give developers the flexibility to handle complex business workflows.
- Deal Prediction handles the common association scenarios.
- Link and Unlink APIs provide manual control over Email-Deal associations.
- Associate Email with a Record API brings external emails into Zoho CRM.
Used together, these features ensure emails are always associated under the right Deal.
We hope that you find this post on Email-Deal Associations useful.
If you have any feedback, please let us know in the comments, or reach out to us via
support@zohocrm.com.