Render a template
curl --request POST \
--url https://api.pdfbase.dev/v1/templates/{id}/render \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {},
"output": "<string>",
"format": "<string>",
"margin": {},
"landscape": true,
"header": {},
"footer": {},
"compress": "<string>",
"debug": true,
"metadata": {},
"timeout": 123
}
'import requests
url = "https://api.pdfbase.dev/v1/templates/{id}/render"
payload = {
"data": {},
"output": "<string>",
"format": "<string>",
"margin": {},
"landscape": True,
"header": {},
"footer": {},
"compress": "<string>",
"debug": True,
"metadata": {},
"timeout": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {},
output: '<string>',
format: '<string>',
margin: {},
landscape: true,
header: {},
footer: {},
compress: '<string>',
debug: true,
metadata: {},
timeout: 123
})
};
fetch('https://api.pdfbase.dev/v1/templates/{id}/render', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pdfbase.dev/v1/templates/{id}/render",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
],
'output' => '<string>',
'format' => '<string>',
'margin' => [
],
'landscape' => true,
'header' => [
],
'footer' => [
],
'compress' => '<string>',
'debug' => true,
'metadata' => [
],
'timeout' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdfbase.dev/v1/templates/{id}/render"
payload := strings.NewReader("{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdfbase.dev/v1/templates/{id}/render")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdfbase.dev/v1/templates/{id}/render")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}"
response = http.request(request)
puts response.read_body{
"template": {}
}Templates
Render a template
Generate a PDF by merging a stored template with data.
POST
/
v1
/
templates
/
{id}
/
render
Render a template
curl --request POST \
--url https://api.pdfbase.dev/v1/templates/{id}/render \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {},
"output": "<string>",
"format": "<string>",
"margin": {},
"landscape": true,
"header": {},
"footer": {},
"compress": "<string>",
"debug": true,
"metadata": {},
"timeout": 123
}
'import requests
url = "https://api.pdfbase.dev/v1/templates/{id}/render"
payload = {
"data": {},
"output": "<string>",
"format": "<string>",
"margin": {},
"landscape": True,
"header": {},
"footer": {},
"compress": "<string>",
"debug": True,
"metadata": {},
"timeout": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {},
output: '<string>',
format: '<string>',
margin: {},
landscape: true,
header: {},
footer: {},
compress: '<string>',
debug: true,
metadata: {},
timeout: 123
})
};
fetch('https://api.pdfbase.dev/v1/templates/{id}/render', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pdfbase.dev/v1/templates/{id}/render",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
],
'output' => '<string>',
'format' => '<string>',
'margin' => [
],
'landscape' => true,
'header' => [
],
'footer' => [
],
'compress' => '<string>',
'debug' => true,
'metadata' => [
],
'timeout' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdfbase.dev/v1/templates/{id}/render"
payload := strings.NewReader("{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdfbase.dev/v1/templates/{id}/render")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdfbase.dev/v1/templates/{id}/render")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"output\": \"<string>\",\n \"format\": \"<string>\",\n \"margin\": {},\n \"landscape\": true,\n \"header\": {},\n \"footer\": {},\n \"compress\": \"<string>\",\n \"debug\": true,\n \"metadata\": {},\n \"timeout\": 123\n}"
response = http.request(request)
puts response.read_body{
"template": {}
}Phase
Phase 1 (Launch)Path parameters
string
required
Template ID, e.g.,
tpl_abc123.Request
object
required
Data to merge into the template. Validated against the template’s schema. Returns
422 if the data doesn’t match.string
default:"url"
url or base64. Same behavior as POST /v1/pdfs.string
Override the template’s default page format.
string | object
Override the template’s default margins.
boolean
Override the template’s default orientation.
object
Override the template’s default header.
object
Override the template’s default footer.
string
Override the template’s default compression.
boolean
default:"false"
Include debug info in the response.
object
Arbitrary metadata attached to the generated PDF.
integer
default:"30000"
Max render time in milliseconds.
Response
Same shape asPOST /v1/pdfs response, with an additional template field:
{
"id": "pdf_rendered1",
"object": "pdf",
"status": "completed",
"url": "https://files.pdfbase.dev/pdf_rendered1.pdf?token=sig_abc",
"pages": 2,
"bytes": 89000,
"format": "a4",
"template": {
"id": "tpl_abc123",
"name": "invoice",
"version": 3
},
"metadata": {
"order_id": "42"
},
"created_at": "2026-05-19T10:35:00Z",
"expires_at": "2026-05-20T10:35:00Z",
"render_time_ms": 890
}
object
Reference to the template used, including the exact
version that was rendered. Useful for debugging when templates change.Schema validation errors
If the data doesn’t match the template’s schema:{
"error": {
"type": "invalid_request",
"code": "schema_validation_failed",
"message": "Data does not match template schema.",
"param": "data",
"details": [
{ "field": "due_date", "error": "Expected type 'date', got 'number'." },
{ "field": "items", "error": "Required field missing." }
]
}
}
Example
curl -X POST https://api.pdfbase.dev/v1/templates/tpl_abc123/render \
-H "Authorization: Bearer pk_live_xxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-42-invoice" \
-d '{
"data": {
"number": "INV-042",
"customer": "Acme Corp",
"items": [
{ "name": "Widget Pro", "qty": 10, "price": "$50.00" },
{ "name": "Gadget Ultra", "qty": 5, "price": "$75.00" }
],
"due_date": "2026-06-19",
"total": "$875.00"
},
"compress": "high",
"metadata": { "order_id": "42" },
"output": "url"
}'
const pdf = await pdfbase.templates.render('tpl_abc123', {
data: {
number: 'INV-042',
customer: 'Acme Corp',
items: [
{ name: 'Widget Pro', qty: 10, price: '$50.00' },
{ name: 'Gadget Ultra', qty: 5, price: '$75.00' },
],
due_date: '2026-06-19',
total: '$875.00',
},
compress: 'high',
metadata: { order_id: '42' },
output: 'url',
})