curl -X POST https://api.pocketutils.com/v1/url-to-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"pageFormat": "a4",
"orientation": "portrait",
"theme": "light"
}'
const res = await fetch("https://api.pocketutils.com/v1/url-to-pdf", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com",
pageFormat: "a4",
orientation: "portrait",
}),
});
const { filename } = await res.json();
const pdfUrl = `https://api.pocketutils.com/api/uploads/${filename}`;
import requests
res = requests.post(
"https://api.pocketutils.com/v1/url-to-pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"url": "https://example.com", "pageFormat": "a4", "orientation": "portrait"},
)
filename = res.json()["filename"]
pdf_url = f"https://api.pocketutils.com/api/uploads/{filename}"
{
"success": true,
"filename": "example_com_2026-07-21_9f3a2b1c.pdf",
"sizeBytes": 512044,
"durationMs": 356
}
Page Rendering
URL to PDF
Convert a live URL into a print-ready PDF document.
POST
/
v1
/
url-to-pdf
curl -X POST https://api.pocketutils.com/v1/url-to-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"pageFormat": "a4",
"orientation": "portrait",
"theme": "light"
}'
const res = await fetch("https://api.pocketutils.com/v1/url-to-pdf", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com",
pageFormat: "a4",
orientation: "portrait",
}),
});
const { filename } = await res.json();
const pdfUrl = `https://api.pocketutils.com/api/uploads/${filename}`;
import requests
res = requests.post(
"https://api.pocketutils.com/v1/url-to-pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"url": "https://example.com", "pageFormat": "a4", "orientation": "portrait"},
)
filename = res.json()["filename"]
pdf_url = f"https://api.pocketutils.com/api/uploads/{filename}"
{
"success": true,
"filename": "example_com_2026-07-21_9f3a2b1c.pdf",
"sizeBytes": 512044,
"durationMs": 356
}
Renders a URL with headless Chromium and prints it to a paginated PDF: navigates, waits for the network to settle, scrolls to trigger lazy-loaded content, waits for images and fonts to finish, then prints. The finished file is written to temporary storage and its filename returned.
See the full error reference for the platform-level codes (
2 credits per call
Body parameters
string
required
The page to convert.
https:// is assumed if the scheme is omitted.string
default:"desktop"
Layout viewport before printing:
desktop or mobile.string
default:"a4"
Paper size:
letter, legal, a0, a1, a2, a3, a4, a5, or a6.string
default:"portrait"
portrait or landscape.string
default:"light"
Emulated
prefers-color-scheme while rendering: light or dark.Response
boolean
required
string
required
Name of the generated PDF. Download it from
/api/uploads/<filename> on the same host — the file is temporary and removed after roughly 5 minutes.integer
required
Size of the generated PDF.
integer
required
Total server-side time for the conversion.
Response headers
In addition to the standard headers, this endpoint sends:string
HIT if served from the short-lived result cache without re-rendering, otherwise MISS.string
Per-stage breakdown (
queue, page, nav, net, scroll, settle, render, total, all in ms).Errors
| Status | Cause |
|---|---|
400 | url missing, or deviceType / pageFormat / orientation / theme not one of the allowed values |
400 | The domain could not be resolved, or the target blocked the request (e.g. a private/internal address) |
408 | The page took too long to render |
401, 402, 429) that apply to every endpoint.
curl -X POST https://api.pocketutils.com/v1/url-to-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"pageFormat": "a4",
"orientation": "portrait",
"theme": "light"
}'
const res = await fetch("https://api.pocketutils.com/v1/url-to-pdf", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com",
pageFormat: "a4",
orientation: "portrait",
}),
});
const { filename } = await res.json();
const pdfUrl = `https://api.pocketutils.com/api/uploads/${filename}`;
import requests
res = requests.post(
"https://api.pocketutils.com/v1/url-to-pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"url": "https://example.com", "pageFormat": "a4", "orientation": "portrait"},
)
filename = res.json()["filename"]
pdf_url = f"https://api.pocketutils.com/api/uploads/{filename}"
{
"success": true,
"filename": "example_com_2026-07-21_9f3a2b1c.pdf",
"sizeBytes": 512044,
"durationMs": 356
}
Was this page helpful?