Skip to content

DocsGenerator API Reference

Docsgenerator is a service that generate docx, xlsx, pdf from templates.

Authentication

Docsgenerator uses API key to allow access to the API.

Docsgenerator expects the API key to be included in all API requests to the server in a header that looks like the following:

X-API-KEY: {{X-API-KEY value}} 

You can find the API key in your Account page.

Create document

Method: POST

https://app.docsgenerator.com/api/v1/documents

Body

{
    "templateUid":"{{templateUid}}",
    "createPdf": true,
    "{{variableName}}": "{{value}}"
}

createPdf - In case you need not only generated Docx document with your data, but also a PDF version, set this to true. (Works only for DOCX templates now)

{{templateUid}} - uid of you uploaded template. Go to templates page to find it.

{{variableName}}: {{value}} - variables from you template, with values to replace. Pleasee see blog post with detailed tutorial creating template.

curl example

curl --location 'https://app.docsgenerator.com/api/v1/documents' \
--header 'X-API-KEY: 123' \
--header 'Content-Type: application/json' \
--data '{
"templateUid":"234",
    "createPdf": false,
    "name": "John Doe"
    }'

Response: 200

{
    "status": "COMPLETED",
    "created_at": "2023-03-30T16:39:18.813944",
    "document_uid": "234092834098"
}

Status "COMPLETED", indicates that document ready. Use {{document_uid}} to download it.

Download document

Method: GET

https://app.docsgenerator.com/api/v1/documents/{{document_uid}}/download

Response: 200

Output: Binary stream with docx or xlsx document.

curl example

curl --location 'https://app.docsgenerator.com/api/v1/documents/231/download' \
--header 'X-API-KEY: 123' -o output_file.docx

Download PDF document

Method: GET

https://app.docsgenerator.com/api/v1/documents/{{document_uid}}/download-pdf

Response: 200

Output: Binary stream with pdf document.

curl example

curl --location 'https://app.docsgenerator.com/api/v1/documents/231/download-pdf' \
--header 'X-API-KEY: 123' -o output_file.pdf