NAV Navbar
javascript shell python

Sample Document

On Account creation, a sample template is created for you. This is the template we will refer to throughout documentation. The sample template can be removed from your account at any time.

Account

You can create an account using our registration form at the following URL: https://zocuments.com/register.

On Account creation, a unique API key will be generated for you. The API key is used to track API requests associated with your account for usage and billing.

API Key

Protecting API Keys

Keep this API key secure and do expose it publicly. Doing so can expose you to unintended use, and unexpected charges to your account.

Usage

API keys are passed in to identify the calling application. Example request endpoint:

https://zocuments.com/api/{API_VERSION}/{API_KEY}/{API_METHOD}/...

File Upload

From Dashboard

Templates can be uploaded from your account dashboard by clicking inside the file upload box. Additionally, you can drag and drop one or more .docx files onto the file upload box.

Programatically Through API

You can also issue a POST request to add a .docx file to your account.

var form = new FormData();
form.append("files", "~/my-template.docx");

var settings = {
    "url": "http://zocuments.com/api/v1/{api_key}/file-upload",
    "method": "POST",
    "mimeType": "multipart/form-data",
    "data": form
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Template Keys

Template keys can be retrieved for a specific template by making an API request.

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://zocuments.com/api/v1/{API_KEY}/template-keys?template_id={TEMPLATE_ID}",
  "method": "GET",
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
curl -X GET -H "Content-Type: application/json" https://zocuments.com/api/v1/{API_KEY}/template-keys?template_id={TEMPLATE_ID}

Example Response Data:
{"data":{"table_keys":{},"template_keys":["My_Custom_Text_Field"]}}
import urllib.request

request = urllib.request.urlopen("https://zocuments.com/api/v1/{API_KEY}/template-keys?template_id={TEMPLATE_ID}")
response_data = request.read()

Example Response Data:
{"data":{"table_keys":{},"template_keys":["My_Custom_Text_Field"]}}

Merge Data

From Dashboard

You can fill in data manually from the Dashboard by clicking on an uploaded template. Doing so will present the template fields to be filled in manually. Clicking the "Generate" button next to the template you clicked will proceed to create your document.

Programatically Through API

See code samples for example:

var data = [{
    "My_Custom_Text_Field": "Some Company"
}];

$.ajax({
    type: "POST",
    url: "/api/v1/{API_KEY}/render-template/{TEMPLATE_ID}",
    data: JSON.stringify(data),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data) {
        console.log(data);
    },
    failure: function(errMsg) {
        console.log(errMsg);
    }
});

Example Response Data:
{"data":"RxpVkc7qiyj3ZNO"} // process_id
curl -X POST -H "Content-Type: application/json" -d @data.json https://zocuments.com/api/v1/{API_KEY}/render-template/{TEMPLATE_ID}

Example Response Data:
{"data":"RxpVkc7qiyj3ZNO"} # process_id
import urllib.request
import json

body = [{'My_Custom_Text_Field':'Some Company'}]
myurl = " https://zocuments.com/api/v1/{API_KEY}/render-template/{TEMPLATE_ID}"
request = urllib.request.Request(myurl)
request.add_header('Content-Type', 'application/json; charset=utf-8')
jsondata = json.dumps(body)
jsondataasbytes = jsondata.encode('utf-8')   # needs to be bytes
request.add_header('Content-Length', len(jsondataasbytes))
response = urllib.request.urlopen(request, jsondataasbytes)

Example Response Data:
{"data":"RxpVkc7qiyj3ZNO"} # process_id

Merge Status

Current status of processes will display on the Dashboard page.

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://zocuments.com/api/v1/{API_KEY}/status/{PROCESS_ID}",
  "method": "GET",
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
curl -X GET -H "Content-Type: application/json" https://zocuments.com/api/v1/{API_KEY}/status/{PROCESS_ID}

Example Response Data:
{"data":{"percent_complete":100}}
import urllib.request

request = urllib.request.urlopen("https://zocuments.com/api/v1/{API_KEY}/status/{PROCESS_ID}")
response_data = request.read()

Example Response Data:
{"data":{"percent_complete":100}}

File Download

You can download completed templates from a running process at any point. Downloaded templates will not appear in subsequent downloads.

curl -X GET -H "Content-Type: application/json" https://zocuments.com/api/v1/{API_KEY}/download/{PROCESS_ID} --output My_Generated_Document.docx
import urllib.request

url = "https://zocuments.com/api/v1/{API_KEY}/download/{PROCESS_ID}"
file_name = "My_Generated_Document.docx"
urllib.request.urlretrieve(url, file_name)