Bulk Merge
Purpose
This API allows to merge documents in bulk.
HTTP Request URL
https://{zohoapis_domain}/writer/api/v1/templates/{{template_id}}/bulkmerge
Path Parameters
Parameter | Data Type | Description |
Mandatory Parameters | ||
template_id | String | Specify a unique id for the writer document. |
Body Parameters
Parameter | Data Type | Description |
Mandatory Parameters | ||
output_settings | { "filename":"NDA <<test>>", "format": "zdoc/pdf/docx", "password": <field_id>, "merge_to": "separatedoc/singledoc" } | 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.
merge_to -> Specify in which type you would like to merge the document. Supported merge types are separatedocand 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. |
You can provide the data in any one of the below formats | ||
merge_data | JSONObject | Pass a String value through 'data' key as JSON Array. |
merge_data_csv_content | File | Provide the required csv content in your API request body. |
merge_data_json_content | File | Provide the required json content in your API request body. |
merge_data_csv_url | url | Provide the required csv url in your API request body. |
merge_data_json_url | url | Provide the required json url in your API request body. |
Optional Parameters | ||
sign_service_name | String | 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. |
Note: To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.documentEditor.ALL, ZohoWriter.merge.ALL, WorkDrive.files.ALL
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"
}