Developers
Generating documents
One request. The template, the data, your reference, and whatever you want back on the webhook.
POST https://api.tokoman.com/v1/documents| Field | Type | Notes |
|---|---|---|
| templateId | string, required | The template's id or slug |
| data | object | Checked against the template's schema |
| correlationId | string | Your own reference. Echoed everywhere, and findable later |
| metadata | object | Returned untouched on the webhook and the record |
| engine | phantom or chromium | Override the template's engine for this document |
| filename | string | What the file is called when downloaded |
| templateVersion | number | Pin a version. Defaults to the active one |
| wait | boolean, default true | Wait for the PDF. false answers at once with the queued record |
Responses
201 with status completed and the download link. If rendering takes longer than the request is willing to wait, 202 with status rendering and the id; fetch it, or wait for the webhook. A failed render answers 201 with status failed, an errorCode and a message you can show.
Fetching and downloading
GET /v1/documents/:id
GET /v1/documents/:id/download?ttlSeconds=900
GET /v1/documents?status=completed&templateId=invoice&limit=50Download links expire. A fetched record always carries a fresh one. The download endpoint mints a short-lived link on demand and records the download.
Regenerating
POST /v1/documents/:id/regenerateA new document from the same data and the same template version. The original is untouched.
Pages and billing
Pages are counted from the finished PDF, not estimated. Pages inside your plan's allowance are included; beyond it, each page is charged from your wallet at the plan's rate. A request that cannot be paid for is refused before anything is rendered, with the code PAYMENT_REQUIRED.