Integrating document generation over a REST API
6 May 2026 · 9 min read · Nextarp B.V.
Adding document generation to an application should be a few HTTP calls, not a project. Here is the shape of a clean integration and the patterns that keep it reliable in production.
Authenticate
Exchange credentials for a token, or use a scoped API key for service-to-service calls. Keep keys server-side; never ship them to a browser or mobile client.
Generate
The core call is simple: reference a template, pass a JSON object of data, and choose an output format and signing options. The response is the finished document - a signed PDF, a DOCX, or a job id for asynchronous work.
POST /api/document/generate
Authorization: Bearer <token>
{
"templateId": 42,
"format": "pdf",
"sign": { "level": "AdES" },
"data": { "customer": "Acme BV", "total": 1499.00 }
}
Synchronous vs asynchronous
Generate one document inline; for batches or heavy documents, submit a job and receive a signed webhook callback when it completes. Design your client for both from the start.
Reliability patterns
- Idempotency keys - so a retried request never produces a duplicate document.
- Explicit error handling - distinguish validation errors (fix the payload) from transient errors (retry with backoff).
- Timeouts and streaming - stream large responses rather than buffering them whole.
SDKs
Client libraries for C#, JavaScript and Python wrap auth, retries and (de)serialisation so your code stays focused on the data, not the plumbing.
Related articles
- Generating statements at volume: batch and async jobs · Developers
- Feeding documents from SQL, REST and CSV · Developers
- eIDAS explained: AdES, QES and QSeal for documents · Compliance
