Skip to Content
Create PDF from Template

Create PDF from Template

Send a POST request to this endpoint to render one of your templates into a PDF document.

ℹ️

You will need to authenticate to use this API. See authentication.

ℹ️

This endpoint consumes 1 credit per PDF, up to 20 pages. A PDF longer than 20 pages is refused and costs nothing.

Request

POST https://api.ojo.so/v1/pdf/template

Request Body

ParameterTypeDescription
templateIdstringThe ID of the template to use
modifyobject(Optional) An object containing variables to modify in the template

Pages are A4 by default. A CSS @page rule in the template sets the size and margins, as described in Create PDF from HTML. A template variable works there too, so one template can serve both sizes:

@page { size: {{pageSize}}; }
curl --request POST \ --url https://api.ojo.so/v1/pdf/template \ --header 'Authorization: Bearer <API Key>' \ --header 'Content-Type: application/json' \ --data '{"templateId": "<Template ID>", "modify": {"customer": "Acme Inc.", "pageSize": "letter"}}'

Response

Everything went as planned and your PDF is generated.

{ "id": "pdf-id.pdf", "pdfUrl": "<content domain>/path/to/document.pdf", "pages": 1, "createdAt": "2026-09-28T12:34:56Z" }

pdfUrl has no scheme. Prefix it with https:// to fetch the file.