Merge Document

Purpose

This API will allow you to generate documents and merge them.

Quick Reference

PropertyValue
PropertyValue
MethodPOST
Request URLhttps://{zohoapis_domain}/writer/api/v1/documents/{document_id}/merge
ScopesZohoWriter.documentEditor.ALL, ZohoWriter.merge.ALL, ZohoPC.files.ALL, WorkDrive.files.ALL
Rate LimitSee Writer API throttle limits

Parameters

Path Parameters

ParameterData TypeDescription
document_idStringSpecify a unique id for the writer document.

Body Parameters

ParameterData TypeDescription
Mandatory Parameters
output_settings{
"format": "pdf | pdfform | docx",
"password": "****",
"restricted_access":
{
"password": "****",
"permissions": ["document.copy", "document.print", "document.edit", "document.fill"]
}
}

format - Specify the format in which you would like to download the merged document.
Supported formats are pdf, pdfform, docx, html, zfdoc and zip (only html).


password(optional) - Specify a password if you would like to protect the merged document. Maximum characters allowed: Upto 100 characters


restricted_access(optional) 

- password: Specify the password to enable or override the restricted permissions. Maximum characters allowed: Upto 100 characters 

- permissions: Specify the actions that needs to be restricted in merged document.
Note: If this param is passed, then both password and permissions fields are mandatory.

Merge Data — pass data using any one of the below formats
merge_dataJSONObjectPass a String value through 'data' key as JSON Array.
merge_data_csv_contentFileProvide the required csv content in your API request body.
merge_data_json_contentFileProvide the required json content in your API request body.
merge_data_csv_urlurlProvide the required csv url in your API request body.
merge_data_json_urlurlProvide the required json url in your API request body.
record_idStringInstead of using merge_data, you can pass the record_id and we will fetch the data internally.
Note: This is applicable only for Zoho CRM, Creator and Bigin templates.
Maximum length allowed: 25
Optional Parameters
response_typeStringSpecify the response_type value as "link" to download the document using a link.
filenameStringSpecify a name ( without extension) for the merged document that needs to be downloaded.
For example: "filename = test" (extension will be automatically added based on the provided 'output_format')
sign_service_nameStringThis param needs to be configured when you would like to upload the merged document with signer fields to a third party sign service.
Possible values: adobesign and docusign
Note: This param can be used only when the 'output_format' param value is configured as pdf.
test_modeBoolean (true/false)Using this param, you can test the Merge APIs without consuming any credit points. The output file will contain a watermark as it is used only for testing purpose.
Test mode limit: 50 merges/day for an org.

permissions

Permission Key NameDescription
document.copyCopy content from the merged document
document.printPrint the merged document
document.editEdit the merged document
document.fillTo fill form fields in the merged document

Notes

  • To merge documents with more than one record, you can use our Bulk Merge API.
  • The download URL generated in the output response will expire after two days.
  • In Deluge scripts, the maximum execution timeout is 40 seconds. If a merge operation exceeds this limit, the DRE workflow may fail. Since document generation is a resource-intensive process, the time taken for a merge can vary based on the template complexity, such as the presence of a large number of images, complex table structures, shapes, extensive merge conditions, etc.,
  • For possible errors, refer to error codes.

Curl - Sample Request

Copiedcurl -X POST "https://www.zohoapis.com/writer/api/v1/documents/{document_id}/merge" \
  -H "Authorization: Zoho-oauthtoken <ACCESS_TOKEN>" \
  -F "output_settings={\"format\":\"pdf\"}" \
  -F "merge_data={\"data\":[{\"name\":\"Amelia\",\"email\":\"amelia@zylker.com\"}]}"

Deluge Snippet

Copieddata = Map();
data.put("InvoiceNo","12345"); 
data.put("InvoiceDate","27 May 2022"); 
data.put("InvoiceAmount","$100");
param = Map();
param.put("merge_data",{"data":data});
param.put("output_settings",{"format":pdf});
param.put("response_type","link");
info param;
email = "amelia@zylker.com";
response = invokeurl
[
	url: "https://www.zohoapis.com/writer/api/v1/documents/olce2ef*****e46ed8331f25aaece75dd/merge"
	type:POST
	parameters:param
	connection:"<connection_name>"
];
info response;

The document will be downloaded in the form of bytes.

If the 'response_type' parameter is passed, the response will be as the following:

Sample Response

Copied{ 
   URL : https://writer.zoho.com/writer/api/v1/documents/ponazfea04477109f4681a831e7177d96bc40/merge/download/gas3hfnkju456mndhjku987b
 }