Rendering
Render a document
POST /v1/render creates one document. Give it a source and it returns a PDF or an image.
curl https://devilpdf.com/v1/render \
-H "Authorization: Bearer $DEVILPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "invoice",
"data": { "number": "INV-1001", "items": [{ "name": "Consulting", "quantity": 3, "unit_price": 150 }] },
"filename": "invoice-1001"
}'#Source
Pass exactly one of these. Sending none, or more than one, returns invalid_request.
| Field | Type | What it renders |
|---|---|---|
template | string | A saved template, by id. Your own (tpl_...) or a starter: invoice, quote, certificate. See templates. |
html | string | HTML you send in the request. Add css for a stylesheet. See HTML to PDF. |
url | string | A public web page. See URL to PDF. |
#Body parameters
| Field | Type | Default | Description |
|---|---|---|---|
data | object | {} | The JSON merged into the template. With html, sending data turns your HTML into an inline template. |
css | string | Extra CSS. Used with html. | |
format | string | "pdf" | pdf, png, jpeg or webp. jpg is accepted as jpeg. See images. |
output | string | "url" | url returns JSON with a download link. file returns the raw bytes. base64 returns JSON with the file in a base64 field. |
options | object | Page setup and capture options. See below. | |
pdf | object | Password, metadata and form fields. PDF only. See below. | |
filename | string | template name | Name of the file, without extension. The right extension is added for you. |
expires_in | number | plan maximum | Seconds the download link stays valid. Minimum 60. The maximum depends on your plan. |
destination | string | Set to "s3" to deliver the file to your own bucket. Paid plans. | |
metadata | object | Up to 20 of your own key/value pairs, returned on the document and in webhooks. Keys up to 60 characters, values up to 500. | |
async | boolean | false | Return immediately and render in the background. See async and batch. |
webhook_url | string | An https URL to notify when this document succeeds or fails, in addition to your webhook endpoints. |
#Options
options controls the page and how it is captured. Every field is optional. For a template, anything you set here overrides the template's own settings for this one render.
#Page setup
| Option | Type | Default | Description |
|---|---|---|---|
page_size | string | "A4" | A3, A4, A5, Letter, Legal or Tabloid. |
orientation | string | "portrait" | portrait or landscape. |
margin | string | "15mm 16mm 17mm" | One to four CSS lengths, like the CSS margin shorthand. Units: mm, cm, in, pt, px. |
font | string | "inter" | Body font: inter, source-serif, jetbrains-mono or system. Templates and kit documents only. |
heading_font | string | same as font | Font for headings. Same choices. |
accent | string | "#111827" | Accent colour as hex. Templates and kit documents only. |
page_numbers | boolean | false | Print "1 / 3" in the bottom right of every page. |
header_text | string | Short text at the top left of every page. Up to 200 characters. | |
footer_text | string | Short text at the bottom left of every page. Up to 200 characters. |
#Capture
| Option | Type | Applies to | Description |
|---|---|---|---|
kit | boolean | html | Include the print kit: fonts, table and layout classes. Off by default for raw HTML. |
javascript | boolean | html | Run scripts in your HTML before capture. Off by default. Templates never run scripts. Pages loaded by url always do. |
media | string | all | CSS media type: print or screen. Defaults to print for PDFs from templates and HTML, screen for URLs and images. |
wait_for | string | all | A CSS selector. Capture waits until an element matches. |
delay | number | all | Extra milliseconds to wait before capture. Maximum 10000. |
scale | number | Zoom factor from 0.1 to 2. | |
page_ranges | string | Pages to keep, for example "1-3, 5". |
Image-only options (width, height, device_scale, full_page, quality, transparent, selector) are covered in images.
#PDF options
pdf only applies when format is pdf. Using it with an image format returns invalid_request.
| Field | Type | Description |
|---|---|---|
password | string | Password needed to open the file. Encrypted with AES-256. |
owner_password | string | Password needed to change permissions. If you leave it out, the open password is used. |
permissions | object | What a reader may do without the owner password. See below. |
metadata | object | Document properties: title, author, subject, keywords (string or array), creator. |
form | boolean | Turn field placeholders into fillable form fields. See forms and signatures. |
Permissions take effect when you set a password.
| Permission | Default |
|---|---|
printing | allowed |
copying | allowed |
annotating | allowed |
filling_forms | allowed |
modifying | not allowed |
{
"template": "tpl_8sK2mQx7Lp0aVn3RtYc1",
"data": { "employee": "Dana Whitfield" },
"pdf": {
"password": "open-sesame",
"permissions": { "copying": false, "printing": false },
"metadata": { "title": "Offer letter", "author": "Northwind Studio" }
}
}#Response
With the default "output": "url", you get a document object.
{
"object": "document",
"id": "doc_nWWGc4ehhC44vpOsHFGn",
"status": "succeeded",
"format": "pdf",
"url": "https://devilpdf.com/f/doc_nWWGc4ehhC44vpOsHFGn/invoice-1001.pdf?exp=1773532800&sig=8fe4b5c6330ae0d9427ba7e78b54a66c",
"filename": "invoice-1001.pdf",
"pages": 1,
"bytes": 29384,
"duration_ms": 412,
"template": "invoice",
"source": "template",
"batch": null,
"metadata": null,
"error": null,
"expires_at": "2026-03-15T14:02:11.000Z",
"created_at": "2026-03-14T14:02:10.588Z",
"completed_at": "2026-03-14T14:02:11.000Z"
}| Field | Description |
|---|---|
id | Document id. Use it with GET /v1/documents/:id. |
status | queued, processing, succeeded or failed. |
url | Signed download link. null when nothing is stored ("output": "file"), or once the link has expired. For S3 delivery, the object's URL in your bucket. |
pages | Page count. null for images. |
bytes | File size. |
duration_ms | Time spent rendering and storing. |
source | template, html, url, or tool for PDF tools. |
error | null, or { "type", "message" } when the document failed. |
expires_at | When the download link stops working. null for S3 delivery. |
#Output modes
output | Response | Stored |
|---|---|---|
url | JSON document with url. | Yes, until expires_at. |
base64 | JSON document with url and a base64 field. | Yes, until expires_at. |
file | The file bytes, with the right Content-Type. The headers devilpdf-document-id and devilpdf-pages identify it. | No. |
#Timeouts
Templates and HTML have 30 seconds to render. URLs have 45. A render that runs out of time returns render_timeout and is not counted against your usage.
#Errors
A failed render never counts against your allowance. Common cases:
| Type | Status | Cause |
|---|---|---|
invalid_request | 400 | A field is missing or has the wrong type. The message says which. |
not_found | 404 | The template id does not exist on your account. |
template_error | 422 | The template has a syntax error. line and col point at it. |
render_error | 422 | The page could not be loaded or rendered. |
quota_exceeded | 429 | You have used this month's documents. |
See errors for the full list.