Overview

The compile resource is used to create the documents via the DynamicDocs API. Use the compile API call to send the dynamic data and receive back a protected URL link to download the document.

End Point, Method and Path Parameters

The compile resource has only one end point and it uses the POST method.

End Point Structure - POST

https://api.advicement.io/v1/templates/{templateToken}/compile?...

The templateToken corresponds to the id of the public template you are using or its the template token founds in your template's settings. It is a required path parameter which identifies the correct template files to be used to compile your PDF document.

Quick Links - Authentication Guide

Please see our authentication guide to see how to authenticate your API calls.

Query String Parameters

The query parameters follow the ? in the end point and follow the template settings closely. If the query parameters are omitted the template settings will be used, while in a case where the query parameter is present, it will take precedence.

Technical Note - Settings versus Query Parameters

Note that the query parameters in the request take precendece over the settings in the DynamicDocs API. In other words, if the setting indicates the parameter to be set to true, but in the request the parameter is set to false, the API would overwrite the settings and produce the document as if the parameter is false.

Response Parameters

The response settings deal with what happens to the document once it has been created.

Time for URL Expiration - Query Parameter

.../templates/98765/compile?doc-url-expires-in={docUrlExpiresIn}&...

The docUrlExpiresIn is a numerical parameter which takes integers and describes after how many seconds the provided URL is available to download the document. The default value is 3600 (1 hour).

Compilation Parameters

The compilation parameters set the options on how the document is compiled with latex and provide various options.

Latex Compiler - Query Parameter

.../templates/98765/compile?latex-compiler={latexCompiler}&...

The latexCompiler parameter can take the following values:

  • pdflatex
  • luatex (currently not available and under development)
Number of Latex Compilation - Query Parameter

.../templates/98765/compile?latex-runs={latexRuns}&...

The latexRuns is a numerical parameter and can take values of 1, 2 and 3. Note that compiling multiple times may incur additional costs.

Main File to Compile - Query Parameter

.../templates/98765/compile?main-file-name={mainFileName}&...

The mainFileName is a string parameter which identifies the main file to compile. For example it can be the following value: mainfile.tex.

Doc File Name - Query Parameter

.../templates/98765/compile?doc-file-name={docFileName}&...

The docFileName is a string parameter which determines the name of the file. Note that the extension of the file is not required. For example it can be the following value: invoiceMar2020.

Security Parameters

The pdf security settings deal with whether the pdf should be encrypted and the settings of the password.

Encrypt PDF - Query Parameter

.../templates/98765/compile?encrypt-type={encryptType}&...

The encryptType parameter can take the following values:

  • rc4-40
  • rc4-128
  • aes-128
  • aes-256

Currently, RC4 algorithm with 40 and 128 bit key sizes and Advanced Encryption Standard (AES) algorithm with 128 and 256 bit key size have been implemented. For more information on the algorithms visit RC4 and AES Wikipedia pages respectively.

Encrypt Viewer Password from String - Query Parameter

.../templates/98765/compile?encrypt-type=aes-128&encrypt-viewer-password={viewerPassword}&...

The viewerPassword is a string parameter which is used as the viewer password for PDF encryption.

A viewer password (or also known as user password) gives the user the ability to view the file. For more information on PDF encyption visit the PDF encryption and signatures Wikipedia page.

Encrypt Viewer Password from JSON - Query Parameter

.../templates/98765/compile?encrypt-type=aes-128&encrypt-viewer-password-json-key={viewerPasswordKey}&...

The viewerPasswordKey is a string parameter which identifies the location of a string in the JSON payload to use as the viewer password for the encrypted PDF. For example it can be the following value: client.viewer.password.

Encrypt Owner Password from String - Query Parameter

.../templates/98765/compile?encrypt-type=aes-128&encrypt-owner-password={ownerPassword}&...

The ownerPassword is a string parameter which is used as the owner password for the encrypted PDF. For example it can be the following value: client.owner.password.

An owner password gives the user the ability to modify the file. For more information on PDF encyption visit the PDF encryption and signatures Wikipedia page.

Encrypt Owner Password from JSON - Query Parameter

.../templates/98765/compile?encrypt-type=aes-128&encrypt-owner-password-json-key={ownerPasswordKey}&...

The ownerPasswordKey is a string parameter which identifies the location of a string in the JSON payload to use as the owner password for the encrypted PDF. For example it can be the following value: client.owner.password.

Request and Response Examples

For compile request examples visit In this section we will show you an example of a compile request.

Request - Example

https://api.advicement.io/v1/templates/98765/compile?doc-url-expires-in=3600&latex-runs=1

Key Value
doc-url-expires-in 3600
latex-runs 1
Key Value
Adv-Security-Token {API Key}
{ "client": { "preferedName": "Igz", "name": "John", "surname": "Smith", "email": "info@gmail.com", "mobileNumber": " 27 82 123 4567", "dateOfBirth": "1990-12-01", "nationality": "South African", "address": "1 Rivonia Road, Sandton, 2193", "taxResidence": "South Africa", "taxNumber": "12345678", "prefferedCommunication": "Email", "age": 33, "weightKG": 78.65, "gender": "Male", "professional": true } }
{ "documentStatusUrl": "https://advicement-dev-api-calls.s3.eu-west-1.amazonaws.com/12345/98765/f5c5cb80-efe9-4632-bf67-2541a77e32a7/output/progress.json?AWSAccessKeyId=ASIA2LMZZZXSP23HL2MY&Expires=1609014601&Signature=iyS1DOdGIbaOo9eYeRofGOJ%2FXws%3D&x-amz-security-token=IQoJb3JpZ2lu..." }
{ "id": "47c2451a-8aa8-47eb-b5db-842dc770b53a", "startedAt": "Tue Mar 30 2021 19:03:57 GMT+0000 (Coordinated Universal Time)", "statusCode": 201, "statusDescription": "document created successfully", "calculationLogUrl": "https://advicement-prod-api-calls.s3.eu-west-1.amazonaws.com/test/blank-template/47c2451a-8aa8-47eb-b5db-842dc770b53a/output/log/calcLog.txt?AWSAccessKeyId=ASIA2LMZZZXS...", "latexLogUrl": "https://advicement-prod-api-calls.s3.eu-west-1.amazonaws.com/test/blank-template/47c2451a-8aa8-47eb-b5db-842dc770b53a/output/log/inputFile.log?AWSAccessKeyId=ASIA2LMZ...", "documentUrl": "https://advicement-prod-api-calls.s3.eu-west-1.amazonaws.com/test/blank-template/47c2451a-8aa8-47eb-b5db-842dc770b53a/output/inputFile.pdf?AWSAccessKeyId=ASIA2LMZZ..." }

For more request examples visit DynamicDocs Public Workspace on Postman API Network or fork the collection using the button below.