Generate Document Single
Generate → Generate Document Single
The Generate Document Single API generates one document from a template and data. You send the template (templateFileType, templateFileName, templateFileData Base64), documentDataType (text, JSON, XML), outputType (html, PDF, Word, Excel), documentDataText or documentDataFile, optional fileMetaData and metaDataJson, and async. The API returns the generated document (binary or polling URL). Use the tester below to try it; more details are in the sections that follow.
Try the Generate Document Single API
Endpoint: POST /api/v2/GenerateDocumentSingle · Required: api-key, templateFileType, templateFileName, templateFileData, documentDataType, outputType, documentDataText
Use the form below to send your API key, template file (Base64), data type, output type, and data (JSON/XML text or file). The response is the generated document. No code required—fill the fields and click Send request.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Generate Document Single?
This endpoint generates a single document from a template (Word, HTML, or PDF) and data (JSON or XML). You provide the template file (Base64), templateFileType and templateFileName, documentDataType (text, JSON, XML), outputType (html, PDF, Word, Excel), and data via documentDataText or documentDataFile. The API merges the data into the template and returns the generated document. Use optional fileMetaData and metaDataJson for extra metadata.
Key features
- Template types – Word, HTML, or PDF templates (Base64).
- Data – documentDataType: text, JSON, or XML; data in documentDataText or documentDataFile (Base64).
- Output – outputType: html, PDF, Word, or Excel.
- Async – Use async for large templates or data.
Use when you need one document per call (invoices, letters, reports). For many documents from one template use Generate Documents Multiple.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| templateFileType | string | Yes | html, Word, PDF, HTML, or DOCX. |
| templateFileName | string | Yes | Template file name with extension (e.g. invoice_template.html). |
| templateFileData | base64 | Yes | Template file content (Base64). |
| documentDataType | string | Yes | text, JSON, or XML. |
| outputType | string | Yes | html, PDF, Word, Excel, or HTML. |
| documentDataText | string | Yes | JSON/XML data as text (if documentDataFile not provided). |
| documentDataFile | base64 | No | Data file (Base64), alternative to documentDataText. |
| fileMetaData, metaDataJson | string | No | Additional metadata. |
| async | boolean | No | Enable asynchronous processing. |
When to use Generate Document Single
- Invoices and letters – Generate one document per template (invoice, contract, letter) with merged data.
- Reports – Produce a single report from a template and JSON/XML data.
- Certificates – Generate one certificate or document per call.
For request/response schemas and code samples, see Generate Document Single in the PDF4me API docs.
Prerequisites
Before using this endpoint, make sure you have:
- A valid PDF4me API key (Get your API Key)
- A template file (Word, HTML, or PDF) in Base64 format
- Data in JSON or XML format
Response Format
The API returns the generated document as binary data for synchronous processing (200 OK) or provides a polling URL for asynchronous processing (202 Accepted).