PDF & Word Document Generation API

Every business application eventually needs to produce documents: an invoice after a sale, a quote before one, a signed contract to close it. Building that document layer by hand is painful. You end up wrestling with PDF libraries, font rendering, page breaks and pixel alignment instead of shipping your product. A PDF generation API removes that burden: you keep your design in a familiar Word template, send your data as JSON, and receive a clean, print-ready PDF in return.

This page explains how the DocX document generation API works, shows a copy-paste example, and walks through the most common use cases. You can start for free with 20 documents per month, no credit card required.

The need: documents without the headache

Most teams that need to generate PDF from a template start by trying to do it in code. They quickly hit the same walls:

  • Design is hard in code: positioning logos, tables and totals in a PDF library takes hours and breaks on every change.
  • Non-technical people own the design: your accountant or sales team wants to tweak the wording of an invoice, not file a ticket with a developer.
  • Consistency matters: a quote, an invoice and a contract should all look like they come from the same company.
  • Volume grows: what works for ten documents a month has to keep working for ten thousand.

The cleanest answer is to separate the design (a Word template anyone can edit) from the data (JSON your application already has). The API merges the two.

How it works: Word template + JSON data → PDF

The model is deliberately simple. There are three moving parts:

  1. A Word template (.docx): you design your document in Microsoft Word, Pages or any editor that exports .docx. Wherever a value should appear, you drop a placeholder tag (for example a client name, a line item or a total).
  2. Your JSON data: your application sends the actual values — client details, amounts, dates, a list of products — as a JSON object.
  3. The generated PDF: DocX merges your data into the template and returns a polished PDF, ready to email, store or have signed.

Upload your template once

You upload your Word template a single time and receive a template_id. From then on you reference that ID on every call — no need to resend the file. Update the template in Word, re-upload, and every future document uses the new design.

Call the endpoint

Document generation happens through a single endpoint on the DocX service at https://docx.layerone.fr:

POST /render-document

One important detail: this endpoint expects form-encoded data, not a JSON body. You send three fields — template_id, json_data (your JSON, passed as a string) and output_filename — using the application/x-www-form-urlencoded content type. Authentication uses the X-API-Key header.

A curl example you can copy

Here is a complete, working call. Note the use of --data-urlencode so the values are sent as form fields, and that the JSON data travels as a string inside the json_data field:

curl -X POST https://docx.layerone.fr/render-document \
  -H "X-API-Key: your_api_key" \
  --data-urlencode "template_id=tpl_invoice_2026" \
  --data-urlencode 'json_data={"client":"Acme Corp","invoice_number":"INV-001","total":"1500.00","currency":"EUR"}' \
  --data-urlencode "output_filename=invoice-INV-001.pdf" \
  -o invoice-INV-001.pdf

The response is the finished PDF, saved here as invoice-INV-001.pdf. Every field defined in your template — the client name, the invoice number, the total — is filled in from the JSON you sent. The same pattern works whether you call it from a shell script, your backend, or an automation tool.

Common use cases

Because the design lives in a Word template, the create documents API fits almost any business document. The most frequent ones:

  • Invoices: generate a compliant, branded invoice the moment a payment is confirmed, then store or email it automatically.
  • Quotes and estimates: produce a professional quote from your CRM data in seconds, ready to send or have signed.
  • Contracts and agreements: merge client and deal data into a contract template, then pass the resulting PDF straight to an electronic signature flow.
  • Reports and certificates: turn structured data into clean, repeatable reports, attestations or delivery notes.

Anywhere you currently copy-paste data into a Word file and export to PDF by hand, this API can do it programmatically.

Benefits

  • Design stays in Word: anyone on your team can update the layout without touching code.
  • One simple endpoint: a single POST /render-document call covers every document type.
  • High-quality, consistent output: every PDF comes out clean and on-brand, every time.
  • Free to start: 20 documents per month at no cost, with no credit card required.
  • Integrates everywhere: call it from your own code or from the no-code tools you already use.

Use it from your favourite stack

Beyond raw HTTP, DocX is available through an npm package for JavaScript and Node.js projects, an MCP document server for AI agents, and ready-made connectors for Zapier, Make, n8n, Pipedream, Bubble and Adalo. A Postman collection is available too, so you can test every call before writing a line of code.

Why a template-based API beats coding it yourself

You could generate PDFs directly with a code library, but it rarely pays off. Layout logic ends up scattered across your codebase, every wording change becomes a deployment, and your documents drift apart as different developers touch them. A Word to PDF API flips that around: the layout lives in one .docx file that your business team owns, and your code only ever sends data. The result is fewer moving parts, faster changes, and documents that stay consistent no matter who edits them.

It also scales without rework. Because each call is a single, stateless HTTP request, you can generate one document or thousands the same way — from a background job, a webhook, or a button in your app. There is no rendering engine to host, no fonts to install, and no PDF library to keep up to date on your side.

Common questions

Can I generate Word documents, not just PDF?

Yes. The same template-and-data approach produces both. You design once in Word and choose your output, which makes it easy to keep an editable version alongside the final PDF.

What happens when I update a template?

Re-upload the .docx and every future call that references the same template_id picks up the new design automatically. Your code never changes — only the template does.

Is the free tier really free?

Yes. You get 20 documents per month with no credit card. It is meant for building and testing a real integration end to end, not a crippled demo.

Get started for free

Creating documents takes minutes. Sign up, grab your API key, upload your first Word template, and send your first render-document call. The free tier — 20 documents per month, no credit card — is enough to build and test a complete integration.

Get your free API key See all APIs

Frequently asked questions

Is the PDF generation API free?

Yes, to start. The free tier includes 20 documents per month with no credit card required, which is enough to build and test a complete integration end to end before moving to a paid plan.

How do I get an API key?

Create a free developer account on the developer console at dev.layerone.fr, where you generate your X-API-Key and upload your first Word template in a few clicks.

What data format does the render-document endpoint expect?

The POST /render-document endpoint expects form-encoded data (application/x-www-form-urlencoded), not a JSON body. You send three fields — template_id, json_data (your JSON passed as a string) and output_filename.

Can I use it without writing code?

Yes. Beyond raw HTTP, DocX ships with ready-made connectors for no-code automation tools such as Zapier, Make and n8n, plus an npm package and an MCP server for AI agents, so you can generate documents without writing code.

Related links