Upload an Attachment
Purpose
The Upload an Attachment API allows you to attach a file or a link to a record in Zoho CRM. Include the attachment in the request with content type as multipart/form data.
Endpoints
- POST /{module_api_name}/{record_ID}/Attachments
Request Details
Request URL
{api-domain}/crm/{version}/{module_api_name}/{record_ID}/Attachments
Supported modules
Leads, Accounts, Contacts, Deals, Campaigns, Tasks, Cases, Events, Calls, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, Custom, Appointments, Services and Notes
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
ZohoCRM.modules.ALL
(or)
ZohoCRM.modules.{module_name}.{operation_type}
(and)
ZohoCRM.modules.attachments.{operation_type}
Possible module names
leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, appointments, services and notes
Possible operation types
ALL - Full access to attachments
WRITE - Edit attachment data
CREATE - Create attachment data
Input form-data
- filefile, mandatory
Choose the attachment you want to upload.
Parameters
- titlestring, optional
The title of the attachment link. By default, the meta-title of the page will be added as the title of the attachment link.
Note
In a single API call, you can add either a file or an attachment link, but not both simultaneously.
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v8/Leads/1000000231009/Attachments"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-F "file=@attachment1.txt" (to upload file)
(or)
-F "attachmentUrl=https://www.zohocorp.com" (to upload link)
Copiedphoto = invokeUrl
[
url: "https://pbs.twimg.com/text.txt"
type: GET
];
photo.setParamName("file");
response = invokeurl
[
url: "https://www.zohoapis.com/crm/v8/Leads/1000000231009/Attachments"
type: POST
files: text file
connection:"crm_oauth_connection"
];
Possible Errors
- INVALID_MODULEHTTP 400
The module name given seems to be invalid, or you have specified an unsupported module.
Resolution: Specify a valid supported module API name. - INVALID_REQUESTHTTP 400
- You have not added the Multipart Form Data in the request.
Resolution: Add the file or link to uploaded as Multipart Form Data. - You have added more than one file or link in the input.
Resolution: Add only one file or link in the input.
- You have not added the Multipart Form Data in the request.
- INVALID_DATAHTTP 400
Both attachment content and attachment link provided. Only one should be given at a time.
Resolution: Add either the file or the link as the input. - AUTHORIZATION_FAILEDHTTP 400
User does not have sufficient privilege to upload attachments
Resolution: The user does not have the permission to upload attachments. Contact your system administrator. - 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
Unauthorized
Resolution: Create a new access token with valid scope. Refer to the scope section at the beginning of this page for more details. - NO_PERMISSIONHTTP 403
Permission denied to upload attachment
Resolution: Contact your system administrator. - INVALID_URL_PATTERNHTTP 404
Please check if the URL trying to access is a correct one
Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section at the beginning of this page. - INTERNAL_ERRORHTTP 500
Internal Server Error
Resolution: Unexpected and unhandled exception in Server. Contact support team.
Sample Response
Copied{
"data": [
{
"code": "SUCCESS",
"details": {
"Modified_Time": "2021-05-03T18:03:00+05:30",
"Modified_By": {
"name": "Patricia Boyle",
"id": "4150868000000225013"
},
"Created_Time": "2021-05-03T18:03:00+05:30",
"id": "4150868000005277036",
"Created_By": {
"name": "Patricia Boyle",
"id": "4150868000000225013"
}
},
"message": "attachment uploaded successfully",
"status": "success"
}
]
}