Skip to main content

Single Generation

Generate one document at a time — either from the UI or via the API.


From the UI

  1. Open any template from the Templates page.
  2. Go to the Single Generate tab.
  3. Fill in the token values using the form.
  4. Select your output format: PDF, DOCX, or Both.
  5. Click Generate — the document is ready in seconds.
  6. Click Download to save it.

Form Mode vs JSON Mode

The Generate tab has two input modes.

Form Mode

Presents each token as a labelled input field. Best for quick, manual generation.

  • Text tokens → text input
  • Date tokens → date picker
  • List tokens → a repeatable row editor
  • Image tokens → URL input

JSON Mode

Paste raw JSON directly into the input box. Best for:

  • Templates with complex nested arrays
  • Copying data from another system
  • Testing API payloads before automating
{
"client_name": "Acme Corp",
"invoice_number": "INV-001",
"due_date": "2024-03-01",
"line_items": [
{ "name": "Consulting", "qty": 10, "unit_price": 100, "total": 1000 },
{ "name": "Support", "qty": 5, "unit_price": 50, "total": 250 }
]
}

Via the API

Generate a Document

curl -X POST "https://api.docgenlab.com/api/v1/documents/" \
-H "X-API-Key: dgl_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"template_id": "your-template-uuid",
"input_json": {
"client_name": "Acme Corp",
"invoice_number": "INV-001",
"line_items": [
{ "name": "Consulting", "qty": 10, "unit_price": 100 }
]
},
"output_format": "pdf"
}'

Response:

{
"id": "doc-uuid-here",
"template_id": "your-template-uuid",
"status": "queued",
"created_at": "2024-01-15T10:30:00Z"
}

output_format accepts "pdf", "docx", or "both".

Poll for Status

curl "https://api.docgenlab.com/api/v1/documents/DOC_ID" \
-H "X-API-Key: dgl_your_key_here"

Possible status values: queuedrenderingready (or failed).

Download the File

curl "https://api.docgenlab.com/api/v1/documents/DOC_ID/download?format=pdf" \
-H "X-API-Key: dgl_your_key_here" \
-o output.pdf

Use ?format=docx for the DOCX file when you generated with "output_format": "both".


Idempotency

Pass an X-Idempotency-Key header to avoid creating duplicate documents if your request is retried:

curl -X POST "https://api.docgenlab.com/api/v1/documents/" \
-H "X-API-Key: dgl_your_key_here" \
-H "X-Idempotency-Key: invoice-INV-001-acme" \
-H "Content-Type: application/json" \
-d '{ "template_id": "...", "input_json": {...}, "output_format": "pdf" }'

Sending the same key again returns the existing document instead of generating a new one. See API Keys → Idempotency for details.


Generation History

Every generated document is saved to the History tab of the template. From there you can:

  • View the input data that was used
  • Re-download the output file
  • See the timestamp and status of each generation

Tips

  • Use JSON mode when your template has list tokens — the form editor for nested arrays can be tedious for large datasets.
  • If generation fails, check the error_message field on the document via GET /documents/{id}. Common causes are in the Troubleshooting guide.
  • For large batches (10+ documents with the same template), use Bulk Generation instead.