Single and Multiple Document Generation Aren't the Same Endpoint With an Array Bolted On
Description and use
Developers mistakenly batch documents using the single PDF4me endpoint, causing errors. Switching to the dedicated Generate Documents (Multiple) endpoint with the correct payload and response handling enables processing multiple records in one call, returning a JSON array of files.
Problem
Developers assume batch document generation can be done by adding an array to the single-document endpoint, but the PDF4me API requires a distinct endpoint with different input and output requirements.
Outcome
Switching to the correct batch endpoint eliminates 404 errors, supports batch data formats, and provides a structured JSON response with per-file metadata, enabling automated handling of multiple documents.
Workflow
- 1. Identify the correct endpoint: POST /api/v2/GenerateDocumentMultiple
- 2. Prepare payload with templateFileType (Docx, HTML, PDF), templateFileName, templateFileData, documentDataType (Json or XML), and documentDataText as an array of records
- 3. Set outputType (PDF, Docx, or optional xlsx for Docx/PDF templates)
- 4. Send POST request with Authorization header
- 5. Parse JSON response: iterate over outputDocuments array, extract fileName and base64 streamFile (or fileContent/content/data)
- 6. Decode base64 and write each file to disk or further processing
Evidence
Generate Documents (Multiple) is a separate endpoint, with a narrower set of accepted inputs, one output format Single cannot touch at all, and a response envelope shaped nothing like the one Single returns.
Single lives at POST /api/v2/GenerateDocumentSingle. The batch version, despite its own docs page being titled "Generate Documents (Multiple)", lives at POST /api/v2/GenerateDocumentMultiple, singular Document, no trailing s.
- Record date: 2026-09-15T10:45:57.055Z