Compile Resource | DynamicDocs API | ADVICEment

Introduction

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

.../templates/{templateToken}/compile?...

The templateToken are required path parameters and can be found in the settings page of your template.

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 Advicement 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 and the various option to receive the document.

Doc Delivery Type - Example

.../templates/98765/compile?doc-delivery-type={docDeliveryType}&...

The docDeliveryType is a string parameter and can take the following values:

  • url
  • webhook (currently not available and under development)
urlExpiration - Example

.../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.

Compilation Parameters

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

Latex Compiler - Example

.../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 - Example

.../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 - Example

.../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.

Ignore Errors - Example

.../templates/98765/compile?ignore_errors={ignoreErrors}&...

The ignoreErrors is a boolean parameter indicates whether the document can be complied with errors. If the paramter is set to true the pdf will be produced with error messages. If the parameter is set to false and there are errors, the document will not be produced.

Doc File Name - Example

.../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.

PDF File Name JSON Key - Example

.../templates/98765/compile?doc-file-name-json-key={docFileNameJsonKey}&...

The docFileNameJsonKey is a string parameter which identifies the location of a string in the JSON payload to use and name the pdf document after compilation. For example it can be the following value: client.clientID.

Technical Note - Naming the Document

The document will be named according to the docFileNameJsonKey parameter. If this parameter is not present or the string in the data.json cannot be located, then the document will be named according to the docFileName parameter. If this parameter is not present, then the document name will keep the name of the compiled tex file.

Security Parameters

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

Encrypt PDF - Example - Under Development

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

The encryptType parameter can take the following values:

  • na
  • rc4 (currently not available and under development)
Technical Note - Using Query Parameters

In reality the query parameters can be used while integrating with the Advicement API. In production, instead of passing the settings through the query, we recommend changing the settings in your template and keeping your URL request short.

Request and Response Example

In this section we will show you an example of a request to the Advicement API.

URL Request - Example

.../templates/98765/compile?url-expiration=3600&debug-mode=true&num-compilations=1

Key Value
url-expiration 3600
debug-mode true
num-compilations 1
{ "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 } }
{ "progressUrl": "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=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3QtMSJGMEQCIDLygbd8q1Uv8Wxainse9NDxbmSYR76uCMPfPq3DhRS3AiA2UG4fpCHYGmst7ulQc%2BuQ29aZnvgcQB9uXT%2BxknXObirLAQgdEAEaDDcxMTY3NjUxMzc2NCIMTFXrgrPKZ36y%2FcMDKqgBnVLzlhB8%2B7a1ha8hnm%2BLGuC%2B5NzYw38gNtAv8sU4niAXSM1qF95pes4u870xmqawY8qIp25a1NPDPkvo3TqqrQJ5cajqK4bBVVaT7WHoI1AB%2BEzJhuxdS8%2FZnEqvBtuDB%2BYKAEIe3aquwCN1szorL3mNDESYB5ewL0pyp3EylXDEx04PYBmVcrQdCkYO3MCM%2Bl7pcqyFGz8cfQl3wQBs1jCQySfmMD3D2ZTssqLNarj06XIPO5YCB8FGc2nJfpkFf5Ex6mskSeG9Kz7hNjr746yDkbcgSpLcXcR4bsP3FgWQ9Rb%2FJgvgzE9Z276GZgID3IWNV%2Bg5YqZkYGNjX359ynqgZl3QJAgTnFJwfOKQz4%2BLjUjdBMkQVy5t32WCTh7OUefLbMNVvNIa%2FudHigie6BW4l1pHy5VMGsfRiDiZzhTy" }
{ "startedAt": "Sat Dec 26 2020 20:15:01 GMT+0000 (Coordinated Universal Time)", "name": "inputFile.pdf", "status": "The inputFile.pdf report has been successfully generated.", "url": "https://advicement-dev-api-calls.s3.eu-west-1.amazonaws.com/12345/98765/f5c5cb80-efe9-4632-bf67-2541a77e32a7/output/inputFile.pdf?AWSAccessKeyId=ASIA2LMZZZXSNR3S2AO4&Expires=1609014608&Signature=dhA1hQKKDoUEvlgAXmkknXwrRQw%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEGUaCWV1LXdlc3QtMSJHMEUCIBkDsaCXuFywQmvpENmBcARqJvFeArI0jG%2BmlJsjMMr3AiEAgjMCuR7beMa1nO4xisAPsUEETuCePQkkYTvlef2SmWwq2AEIHRABGgw3MTE2NzY1MTM3NjQiDANl9xGIY4izmyIElCq1Ad3zJAq1rDs0iMn2kkbOgY%2FJYvqykwh2PG0OWZCYSnDEZT5XInxQtgZbeYuMz5rZMGx1Sidk54cz2I%2FdMwtaG20%2BTsCGkxGRum3kEZZnTzr9%2BMDV0oP349rzYSY8NSnW7%2FhVV7vDIZLRZ7VKATWZZoSGmSG9ocvdzAPwlHY9zERDmPwNazEePQFfUQ5kxEzW%2FHKpGa4fq%2F20KuR91IiHsoqVTMcPtXFLbBx1gcmKmdjFRfpysQwwyrOe%2FwU64AEsrnVmOQZljhV9FNbBDUc5OJ%2Byg%2FqHCkcLj%2BuYFtEVSR6Ac7Ly3VFgoj908cJ%2FK3449zXQlmUzzsyeo49gEVbO%2FtxVyHYkhk%2B0fg0U1I4%2BycYxUXXrV30y6M6Yx8Pm9d%2FOs1zo091dFWiL74%2FwNv0YdboDhW%2B3%2FI0XR5eab3DEf2Q5z2p2PKt076Avj39b0M7t463%2BfTu9%2BzzNm4ydUAsE%2FGIXEFxxdbe9u0Lbg1cyFQvlrN%2Fv%2FrhvE3sn4jsFxWhV5jsY1IytdeXwiiAeCZRuzPVRXAjkvFQBB3ZTHSJP%2FA%3D%3D" }

Code Samples

In this section we will show you the response from the Advicement API from the request performed in the previous section.