Bulk Merge
Purpose
This API allows to merge documents in bulk.
Quick Reference
| Property | Value |
|---|---|
| Method | POST |
| Request URL | https://{zohoapis_domain}/writer/api/v1/templates/{{template_id}}/bulkmerge |
| Scopes | ZohoWriter.documentEditor.ALL, ZohoWriter.merge.ALL, WorkDrive.files.ALL |
| Rate Limit | See Writer API throttle limits |
Parameters
Path Parameters
| Parameter | Data Type | Mandatory/Optional | Description |
|---|---|---|---|
| template_id | String | Mandatory | Specify a unique id for the writer document. |
Body Parameters
| Parameter | Data Type | Mandatory/Optional | Description |
|---|---|---|---|
| output_settings | { "filename" :"NDA < "format" : "zdoc/pdf/docx", "password" : "merge_to" : "separatedoc/singledoc", " restricted_access" : { " password ": "", " permissions ": ["document.copy", "document.print", "document.edit", "document.fill"] } } | Mandatory | Using this param, you will be able to specify the following; format -> Specify the format in which you would like to download the merged document. Supported formats are zdoc,pdf and docx. The below key values are optional; filename -> Specify 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) password -> Specify a password if you would like to protect the merged document. This key is supported only with docx and pdf files. Maximum characters allowed: Upto 100 characters merge_to -> Specify in which type you would like to merge the document. Supported merge types are separatedoc and singledoc. separatedoc - If you would like to merge each record as a separate document. singledoc - If you would like to merge all the records as a single document. By default, all the records will be merged as a single document. restricted_access - 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 | JSONObject | Mandatory | Pass a String value through 'data' key as JSON Array. |
| merge_data_csv_content | File | Mandatory | Provide the required csv content in your API request body. |
| merge_data_json_content | File | Mandatory | Provide the required json content in your API request body. |
| merge_data_csv_url | url | Mandatory | Provide the required csv url in your API request body. |
| merge_data_json_url | url | Mandatory | Provide the required json url in your API request body. |
| sign_service_name | String | Optional | Specify the third party sign service name with respect to which the merged document needs to be generated. Possible values are adobesign and docusign. By default, it will be zohosign. |
Curl Snippet
Copiedcurl --location --request POST "https://www.zohoapis.com/writer/api/v1/templates/ponazfea04477109f4681a831e7177d96bc40/bulkmerge" \
--header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
--form 'output_settings="{'\''format'\'':'\''docx'\'', '\''password'\'':'\''***'\'','\''merge_to'\'':'\''separatedoc'\'','\''filename'\'':'\''NDA<<test>>'\''}"'
--form "merge_data={\"data\":[{\"name\":\"Amelia\",\"email\":\"amelia@zylker.com\"}, {\"name\":\"John\",\"email\":\"john@zylker.com\"}]}"Sample Response
Copied{
"merge_report_data_url": "https://writer.zoho.com/writer/api/v1/merge/job/0tq5n465132106580437abe99b6f56f2b0c85/data",
"merge_report_url": "https://writer.zoho.com/writer/v1/mailmerge/job/0tq5n465132106580437abe99b6f56f2b0c85",
"records": [
{
"data": {
"name": "Amelia",
"email": "amelia@zylker.com"
},
"download_link": {url},
"status": "inprogress"
},
{
"data": {
"name": "John",
"email": "john@zylker.com"
},
"download_link": {url},
"status": "inprogress"
}
}
],
"status": "inprogress"
}
// If the 'merge_report_data_url' is invoked, you will receive the following response;
1. If 'merge_to' = "separatedoc"
{
"records": [
{
"data": {
"name": "Amelia",
"email": "amelia@zylker.com"
},
"download_link": {url},
"status": “completed”
},
{
"data": {
"name": "John",
"email": "john@zylker.com"
},
"download_link": {url},
"status": “completed”
}
],
"status": “completed”
}
2. If 'merge_to' = "singledoc"
{
"records": [
{
"download_link": “{url}“,
"data": [
{
“name": “Amelia”,
“email”: “amelia@zylker.com”
},
{
“name": “John”,
“email”: “john@zylker.com”
}
],
"status": "inprogress"
}
],
"status": "inprogress"
}Deluge Snippet
Copieddatamap.put("InvoiceNo","12345");
datamap.put("InvoiceDate","27 May 2022");
datamap.put("InvoiceAmount","$100");
outputsettings = Map();
outputsettings.put("filename","bulkMerge");
outputsettings.put("format","pdf");
outputsettings.put("password","1234");
outputsettings.put("merge_to","separatedoc");
param = Map();
param.put("merge_data",{"data":datamap});
param.put("output_settings",outputsettings);
info param;
response = invokeurl
[
url :"https://www.zohoapis.com/writer/api/v1/templates/olce2ef696f1810ee46ed8331f25aaece75dd/bulkmerge"
type :POST
parameters:param
connection:"<connection_name>"
];
info response;Sample Response
Copied{
"merge_report_data_url": "https://writer.zoho.com/writer/api/v1/merge/job/<jobId>/data",
"merge_report_url": "https://writer.zoho.com/writer/v1/mailmerge/job/<jobId>",
"records": [
{
"download_link": “{url}”,
"data": {
"InvoiceNo": "12345",
"InvoiceDate": "27 May 2022",
"InvoiceAmount": "$100",
"id": "0e002287-7c45-4188-af9f-65*****”
}
"status": "inprogress"
}
],
"status": "inprogress"
}