Use case
Mail-merge letters into PDFs
The same letter, a few hundred times, each with a different name and address — and it must not look like a mail merge. Doing it by hand is an afternoon; doing it in code is a layout engine you did not want to write.
What you send
This is the template's own sample data — the document on the left was drawn from exactly this.
{
"data": {
"date": "1 August 2026",
"sender": {
"name": "Northgate Studio",
"title": "Managing Director",
"address": "14 Bridge Street, Leeds LS1 4DA"
},
"recipient": {
"name": "Ms Priya Raman",
"first_name": "Priya",
"address": "9 Queen Square\nBristol BS1 4ND"
},
"body": "Thank you for your enquiry. I am glad to confirm that we can take the work on from the first week of September, and I have attached a short outline of how we would approach it.\n\nDo let me know if you would like to talk any of it through before then."
}
}POST it to your document's endpoint with your API key. The reply is JSON carrying a signed pdf_url — a link rather than the bytes, because a base64 document breaks receivers sitting behind a default body limit.
curl -X POST https://www.doc2api.co/api/v1/documents/<ID>/render \
-H "X-Api-Key: d2a_live_…" \
-H "Content-Type: application/json" \
-d @payload.json
# → { "pdf_url": "https://…", "pdf_bytes": 17185, "sha256": "…",
# "pdf_url_expires_at": "…" }What the template already does
- Letterhead, sender and recipient address blocks, a dateline and a signature
- Body paragraphs that reflow around whatever length your text is
- Elements that vanish when their value is missing, so an absent reference leaves no hole
And what you can add in the designer
Not in the starting template — a few clicks once it is open.
- A running footer with page numbers, for anything over a page
- Your logo and brand colour
- Rich text in the body, so bold and links survive from your own editor
For a run of hundreds, upload the letter instead
A designed document renders one PDF per request, so a mailing is one call per recipient. If you are sending hundreds at a time, the batch endpoint is the better path and it works on uploaded PDFs: print your letter to PDF once, upload it as a template, and POST an array of rows or a CSV to get one document per row in a single request.
Already have a PDF you have to use?
Designing from a template is one of the three things Doc2api does. If you were handed a form you cannot redraw — a claim form, a government return, a contract in someone else's house style — upload it instead and we read its fields into a JSON schema. Or paste your own HTML into the designer and we render that.
Open it and see for yourself
The template opens in the editor, filled with the sample data above, with a live endpoint and an API key. No account, nothing to cancel — and the first 100 test fills each month are free.