← Back to blog

Documint REST API: How to Generate PDFs from JSON (with Examples)

Josh Mamroud · September 22, 2026

REST API request with JSON data generating an agreement PDF from a Documint template

The Documint REST API lets your application create PDFs from a template with one HTTP request. You send the data as JSON, Documint merges it into a template you designed visually, and the response includes a URL to the finished document.

It's built for teams who want documents inside their own product or backend, without maintaining an HTML-to-PDF pipeline. Developers own the data and the request. The people who own the document own the template.

How does API document generation work?

Your appAn event, such as a signed-up customer
JSON payloadFields, objects and lists
Documint templateLayout, rules and loops
PDF URLDownload, store or send
Your app sends data; Documint returns a PDF built from your template.

The keys in your JSON match the fields in your template. Display rules and Repeat/Loop rows run inside the template, so your payload stays simple data with no layout logic.

Should you use the API or build PDFs yourself?

Build it in-house

Best when PDFs are core to your product

  • Full control over rendering
  • No external service to depend on
  • Layout lives in code, so design changes need a developer
  • You handle page breaks, long tables and fonts
Recommended

Documint API

Best when the business owns the documents

  • Templates built in a drag-and-drop designer
  • Repeating rows, display rules and calculations in the template
  • Wording and design change without a deploy
  • Each plan includes a set number of merges

How do you generate a document with the Documint API?

  1. 1

    Design the template and its fields

    Create a template in Documint. Choose a custom data source, open Manage fields and define the fields your app will send. You can add them one by one or paste a JSON schema. Drag the fields onto the page. See the Fields Editor guide.

  2. 2

    Add logic in the template

    For lists, such as line items, select the row, click Edit Logic and repeat it on the list field with Repeat/Loop. For optional sections, add a display rule.

  3. 3

    Create an API key

    Go to Settings > API keys, click New API key, name it and copy it. Store it as a secret in your app's environment, never in client-side code.

  4. 4

    Get the template ID

    Each request needs the template's ID. List your templates and their IDs with GET https://api.documint.me/1/templates.

  5. 5

    Send the merge request

    POST your JSON to /1/templates/{template_id}/content with the api_key header. Examples are below.

  6. 6

    Store the PDF

    Read url from the response and download the file to your own storage, or send it on. The link is temporary.

What does the API request look like?

The full reference is in the Documint REST API documentation. Here is a merge request for an invoice template with line items:

1curl -X POST "https://api.documint.me/1/templates/YOUR_TEMPLATE_ID/content" \
2 -H "api_key: $DOCUMINT_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "invoice_number": "INV-2026-0142",
6 "customer": { "name": "Acme Co.", "email": "billing@acme.example" },
7 "items": [
8 { "description": "Onboarding", "qty": 1, "price": 500 },
9 { "description": "Monthly plan", "qty": 3, "price": 149 }
10 ],
11 "is_enterprise": false
12 }'

The same request from Node.js:

1const response = await fetch(
2 `https://api.documint.me/1/templates/${templateId}/content`,
3 {
4 method: 'POST',
5 headers: {
6 api_key: process.env.DOCUMINT_API_KEY,
7 'Content-Type': 'application/json',
8 },
9 body: JSON.stringify(invoiceData),
10 },
11)
12const document = await response.json()
13console.log(document.url) // link to the generated PDF

A successful request returns JSON like this:

1{
2 "url": "https://.../documents/invoice-5760e8a9.pdf",
3 "name": "invoice-5760e8a9",
4 "fileExtension": "pdf",
5 "timestamp": 1606340440318,
6 "templateName": "Invoice",
7 "templateId": "5f861bf738f0eb0017f70ba1"
8}

How do JSON keys map to the template?

Each top-level key fills a field. Objects become nested fields, and arrays drive repeating rows:

JSON payload

Invoice

1Invoice number
2Bill to
3Line items table
4Line total
5Enterprise terms
Hover or tap a field to see where it lands in the invoice.

Best practices for production

  • Validate before you send. Check required fields and types in your app, so a missing value doesn't produce an incomplete document.
  • Run generation in the background. For batches, such as monthly invoices, call the API from a job queue instead of a web request.
  • Store files yourself. Download the PDF from url and keep it in your own storage, with access controls that fit the data.
  • Check your merge allowance. Documents from active templates count toward your plan; see pricing.
  • Test on an inactive template. Documents from an inactive template include Documint branding and don't count toward your usage.
  • Keep template edits with one owner. Anyone can change wording safely, but field names must still match your payload.

What can you build with the API?

Let your users download invoices, reports or certificates from inside your app, generated from their data on request.

Prefer no code? The same templates work with Zapier and Make. The REST API integration page has an overview of all the options.

Frequently asked questions

How do I authenticate with the Documint API?

Create a key under Settings > API keys in Documint and send it in an api_key request header. Keep the key on your server, never in front-end code.

What does the API return?

A JSON object with a url to the generated PDF, plus its name, file extension, timestamp, template name and template ID. Download the file from url and store it, because the link is temporary.

Can non-developers change the document without breaking the integration?

Yes. Text, styling and layout can change freely in the designer. Only field names need to stay the same, because they're what your JSON keys map to.

Can the API handle line items and nested data?

Yes. Send arrays and objects in your JSON. Use Repeat/Loop rows for arrays, including nested lists, and dot paths like customer.name for objects.

Generate your first PDF from the API

Design a template, create an API key and send one request. Your first document takes minutes.

Make Document Generation: How to Create PDFs in Make.com with Documint

Next Blog →

Make scenario creating an invoice PDF with a Documint template