API Reference
Complete API reference for all FUNBREW PDF API endpoints.
Examples use https://pdf.funbrew.cloud (the SaaS edition). For the Open edition (self-hosted), replace it with the URL of your own server.
SDK
Official client libraries available on GitHub.
| Language | GitHub | Install |
|---|---|---|
| PHP | FUNBREW/funbrew-pdf-php | composer require funbrew/pdf-phpInstalled via GitHub (see the README) |
| Node.js | FUNBREW/pdf-node | npm install @funbrew/pdf |
| Python | FUNBREW/pdf-python | pip install funbrew-pdf |
| CLI | @funbrew/pdf-clinpm | npm install -g @funbrew/pdf-cli |
PHP
$pdf = new Funbrew\Pdf\FunbrewPdf('sk-your-api-key');
$result = $pdf->fromHtml('<h1>Hello</h1>');
echo $result['data']['download_url'];Node.js
const { FunbrewPdf } = require('@funbrew/pdf');
const pdf = new FunbrewPdf('sk-your-api-key');
const result = await pdf.fromHtml('<h1>Hello</h1>');
console.log(result.data.download_url);Python
from funbrew_pdf import FunbrewPdf
pdf = FunbrewPdf("sk-your-api-key")
result = pdf.from_html("<h1>Hello</h1>")
print(result["data"]["download_url"])CLI
npm install -g @funbrew/pdf-cli fbpdf config set-key sk-your-api-key fbpdf html "<h1>Hello</h1>" -o hello.pdf
Authentication
All API requests require an API key. Include it as a Bearer Token in the request header.
Authorization: Bearer sk-your-api-key
X-API-Key You can also authenticate via the X-API-Key header or the ?api_key=... query parameter.
API keys can be issued from the dashboard. The key is shown only once at creation — store it securely.
Client / Project Grouping
Each API key can carry a "Client" (client_label) and tags. Useful for agencies, contractors, and SaaS resellers running multiple customers or projects through one account — generated PDFs, API logs, and usage can all be filtered and aggregated per client.
When to use client_label vs tags
client_label | tags | |
|---|---|---|
| Count | Exactly one | Multiple allowed |
| Role | Primary axis for billing and aggregation | Sub-classification (environment, use case, etc.) |
| Example | Acme Inc | production, invoice-pdf |
| CSV export | Included as the client_label column (invoice evidence) | Not exported today — dashboard-only |
Rule of thumb: "unit you want to split invoices by" goes in client_label; everything else is a tag.
Use cases
- Reseller agencies: issue a dedicated key per client, filter PDF lists and API logs by client, and export CSV per client for invoice allocation.
- Multi-tenant SaaS: bundle keys per tenant, then add environment tags (production / staging / dev) for finer slicing.
- Contracted development: one key per project, so post-delivery support can pull only the relevant logs.
How to use
- Dashboard → API Keys → click "New key", or "Rename" on an existing key.
- Fill in the "Client" field (e.g. Acme Inc) and optionally add "Tags (environment, use case, etc.)" (e.g. production, invoice-pdf).
- On the PDF list and API log pages, filter by "Client". CSV exports include a client_label column.
"Client" is up to 100 chars, each tag up to 50 chars. Grouping is purely a management label — it does not affect API behavior or billing.
PDF Engine Selection
FUNBREW PDF offers two rendering engines. Which one is used when engine is omitted depends on your plan and your default engine setting (see the note below).
| Value | Renderer | Speed | CSS Support |
|---|---|---|---|
"quality" | Gotenberg (Chromium) | Normal (1-3s) | CSS3 / Flexbox / Grid |
"fast" | wkhtmltopdf | Fast (0.5-2s) | CSS2.1 + partial CSS3 |
// Generate with the Chromium (quality) engine
{
"html": "<div style='display:flex'>...</div>",
"options": { "engine": "quality" }
}When engine is not specified, the default engine set in the dashboard is used if you have set one. Otherwise, Pro and Business use quality (Chromium) and Free uses fast (wkhtmltopdf). On Free, specifying engine="quality" does not fall back to fast — it returns 403 ("The chromium (quality) engine requires a paid plan. …"). If your default engine is still set to quality while on Free (for example, after setting it on a paid plan and then downgrading), you get the same 403 even when engine is not specified — specify engine=fast or change the default engine to fast on the account page. In test mode (test: true), quality is used when engine is omitted, regardless of plan or default engine setting. Use engine=fast for high-throughput batch generation.
Image formats: JPEG, PNG and GIF work on both engines. WebP and AVIF render only on the quality (Chromium) engine — they are not supported by the fast (wkhtmltopdf) engine.
Rate Limiting
API requests are subject to a per-minute limit based on your plan (counted per company in a 60-second window).
| Plan | Limit |
|---|---|
| Free | 10 req/min |
| Pro | 120 req/min |
| Business | 300 req/min |
Response Headers
On plans with a limit, responses include X-RateLimit-Limit and X-RateLimit-Remaining. X-RateLimit-Reset is only included on the 429 returned when the per-minute limit is exceeded. On custom contracts without a per-minute limit, only X-RateLimit-Limit: unlimited is included.
| Header | Description |
|---|---|
X-RateLimit-Limit | Per-minute request limit |
X-RateLimit-Remaining | Remaining requests |
X-RateLimit-Reset | Limit reset time (UNIX timestamp) |
When Exceeded
When the per-minute limit is exceeded, a 429 Too Many Requests response is returned. Wait for the number of seconds in the Retry-After header (and the retry_after field) before retrying. A 429 is also returned for the monthly generation limit and the storage limit, but those have no Retry-After header (see Errors for how to tell them apart).
{
"success": false,
"error": "rate_limited",
"message": "Rate limit exceeded. Please wait and try again.",
"retry_after": 42
}HTML → PDF
/api/pdf/generate-from-htmlGenerate a PDF from HTML content.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
html | string | Yes | HTML content (max 5MB) |
options.page-size | string | A3, A4, A5, Letter, Legal | |
options.orientation | string | Page orientation. "Portrait" (default) or "Landscape" | |
options.engine | string | PDF engine. "quality" (Chromium) or "fast" (wkhtmltopdf). If omitted, decided by your plan and default engine setting (see PDF Engine Selection) | |
options.margin-* | number | top/right/bottom/left (mm, 0-50) | |
filename | string | Display filename for download | |
expiration_hours | integer | Expiry in hours (0-168, 0=no expiry). If omitted: the default expiry from your saved dashboard download settings (if 1 or more), or 24 if you have not saved one | |
max_downloads | integer | Max downloads (0-100, 0=unlimited). If omitted: the default from your saved dashboard download settings, or 0 (unlimited) if you have not saved them | |
test | boolean | true for test mode: not counted toward the monthly limit and not listed in the dashboard. The PDF gets a TEST watermark and the response includes test_mode: true | |
watermark | string | Watermark text | |
password | string | Password required to open the PDF (max 128 chars, AES-256). Never stored or returned. Not available for URL or batch generation | |
email.to | string | Email recipient for PDF attachment | |
email.subject | string | Email subject | |
email.body | string | Email body |
Request Example
curl -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-html \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello</h1>", "options": {"page-size": "A4"}}'Response
{
"success": true,
"data": {
"filename": "uuid.pdf",
"original_name": "invoice_2026-03.pdf",
"download_url": "https://pdf.funbrew.cloud/api/pdf/download/uuid.pdf",
"public_url": "https://pdf.funbrew.cloud/dl/token",
"file_size": 45321,
"expires_at": "2026-03-21T12:00:00.000000Z",
"max_downloads": 0,
"remaining_downloads": -1
}
}Response fields
| Name | Description |
|---|---|
download_url | URL to download with API key authentication (/api/pdf/download/…) |
public_url | URL of the download page that opens without an API key (/dl/…), for sharing |
max_downloads | Max downloads (0 = unlimited) |
remaining_downloads | Remaining downloads. -1 when unlimited (max_downloads is 0) |
test_mode | Only present when generated with test: true (value is true) |
URL → PDF
/api/pdf/generate-from-urlConvert a web page specified by URL to PDF.
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Target URL (JS execution, HTTPS supported) |
filename | string | Display filename for download | |
options.* | Same as HTML → PDF | ||
email.* | Same as HTML → PDF |
Template → PDF
/api/pdf/generate-from-templateGenerate a PDF by injecting variables into a pre-registered template.
| Name | Type | Required | Description |
|---|---|---|---|
template | string | Yes | Template slug |
variables | object | Template variables {"name": "Taro"} | |
filename | string | Display filename for download | |
password | string | Password required to open the PDF (max 128 chars, AES-256). Never stored or returned. Not available for URL or batch generation | |
options.* | Same as HTML → PDF |
Invoices: totals calculated from line items
If you send the line-items variable (type line_items; items in the gallery invoice) as an array of objects with description and amount, the API calculates the subtotal, consumption tax (rounded down) and total the same way as the dashboard form, formatted with ¥ and thousands separators. You do not need to send subtotal, tax or total. The tax rate is tax_rate (default 10). Amounts accept digits and thousands-separator commas only (JSON integers are also accepted, up to a total of 1 trillion yen); anything else returns 422. Variables of type date sent as YYYY-MM-DD are written as a Japanese-style date (year, month and day with Japanese characters).
curl -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-template \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"template": "invoice",
"variables": {
"company_name": "Sample Inc.",
"invoice_number": "INV-2026-001",
"date": "2026-11-30",
"issuer_name": "Your Company Inc.",
"registration_number": "T1234567890123",
"items": [
{"description": "Maintenance", "amount": "50,000"},
{"description": "Setup", "amount": 5000}
]
}
}'The PDF in this example shows subtotal ¥55,000, tax ¥5,500, total ¥60,500 and the issue date 30 November 2026 written in Japanese.
The totals use a Japan-specific format (¥ amounts, Japanese consumption tax and Japanese-style dates) and cannot be changed.
If you send line items as a string (the existing way), nothing is calculated and the values are inserted as sent (send subtotal, tax and total as well in that case).
Markdown → PDF
/api/pdf/generate-from-markdownGenerate a styled PDF from Markdown text. Supports GFM (GitHub Flavored Markdown) including tables, code blocks, and checklists.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Markdown text (max 5MB) |
theme | string | Theme name (business, modern, minimal, academic, creative). Default: business | |
filename | string | Display filename for download | |
password | string | Password required to open the PDF (max 128 chars, AES-256). Never stored or returned. Not available for URL or batch generation | |
options.* | Same as HTML → PDF | ||
email.* | Same as HTML → PDF |
Available Themes
| Theme | Description |
|---|---|
"business" | Business documents. Professional layout with muted colors |
"modern" | Modern design. Refined typography with accent colors |
"minimal" | Minimal design. Simple layout with generous whitespace |
"academic" | Academic papers. Serif fonts with paper-style layout |
"creative" | Creative. Colorful design with unique layout |
Request Example
curl -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-markdown \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{"markdown": "# Hello World\n\nThis is **bold** text.", "theme": "modern"}'Related APIs
/api/markdown/themesList available themes (no authentication required).
/api/markdown/previewConvert Markdown to HTML for preview (no authentication required). Returns themed HTML output.
Batch Generation
/api/pdf/batchGenerate multiple PDFs asynchronously in batch.
| Name | Type | Required | Description |
|---|---|---|---|
items | array | Yes | Array of generation requests (max 100) |
items[].type | string | Yes | html or url |
items[].html | string | * | Required when type=html |
items[].url | string | * | Required when type=url |
/api/pdf/batch/{batch_id}Check batch progress status.
PDF Merge
/api/pdf/mergeMerge multiple existing PDFs into one.
| Name | Type | Required | Description |
|---|---|---|---|
filenames | array | Yes | Array of PDF filenames to merge (2-50) |
Upload & Merge
/api/pdf/merge-uploadUpload PDF files directly and merge them into one. You can also mix uploaded files with existing server files.
Content-Type: multipart/form-data
| Name | Type | Required | Description |
|---|---|---|---|
files[] | file | PDF files to upload (max 50MB each) | |
filenames[] | string | Existing server filenames to include in the merge |
At least 2 files in total (uploaded + server filenames) are required.
curl -X POST https://pdf.funbrew.cloud/api/pdf/merge-upload \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "files[]=@invoice1.pdf" \ -F "files[]=@invoice2.pdf"
Download
/api/pdf/download/{filename}Download a generated PDF. Increments the download count.
File Info
/api/pdf/info/{filename}Get PDF file metadata (size, remaining downloads, expiry, etc.).
File Delete
/api/pdf/delete/{filename}Delete a PDF file.
Template CRUD
/api/templatesList all templates.
/api/templatesCreate a template. Use variable placeholders in html_content.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
slug | string | Yes | Unique identifier (lowercase alphanumeric + hyphens) |
html_content | string | Yes | HTML template |
variables | array | Variable definitions [{"name": "x", "required": true}] |
/api/templates/{id}/api/templates/{id}Email Delivery
Send generated PDFs as email attachments. Two methods are available.
A) Specify in API request
Add the email parameter to your generation request to send the PDF as an attachment after generation.
curl -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-html \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Invoice</h1>",
"email": {
"to": "customer@example.com",
"subject": "Your invoice",
"body": "Please find your invoice attached."
}
}'B) Pre-configure in dashboard
Set up recipient, subject, and body templates in Email Notification Settings. Emails are sent automatically on every PDF generation.
The following placeholders can be used in subject and body:
| Placeholder | Content |
|---|---|
{{filename}} | Filename |
{{file_size}} | File size |
{{expires_at}} | Expiry date |
{{download_url}} | Download URL |
Webhook / Slack Notifications
/api/webhooks/api/webhooksRegister a webhook URL. Events are sent via POST.
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Notification URL |
events | array | Yes | Events to notify (see below) |
Supported Events
| Event | Description |
|---|---|
pdf.generated | PDF generation complete |
pdf.downloaded | PDF downloaded |
pdf.expired | PDF expired |
tus.upload.completed | Resumable upload (tus) completed |
tus.upload.aborted | Resumable upload (tus) aborted |
source_type
The data.source_type field of the webhook payload tells you where the PDF came from (the same value appears in the "Source" field of Slack notifications and the source_type column of the PDF list CSV).
| Value | Description |
|---|---|
html | PDF generated from HTML (generate-from-html and generate-from-markdown APIs, html batch items). API Markdown generation is reported as html |
url | PDF generated from a URL (generate-from-url, url batch items) |
markdown | PDF created on the dashboard Markdown screen |
template | PDF generated from a template (generate-from-template, dashboard template screen) |
merge | Merged PDF (merge, merge-upload) |
split | Split PDF (split) |
compress | Compressed PDF (compress) |
rotate | PDF with rotated pages (rotate) |
metadata | PDF with updated metadata (metadata) |
page_number | PDF with page numbers added (page-numbers) |
pdfa | PDF converted to PDF/A (to-pdfa) |
to_image | Page images converted from a PDF (to-image). Each converted image counts toward your monthly PDF count |
pdf.generated is only sent for html, url, markdown and template. PDFs produced by post-processing (merge and below) carry this value only in pdf.downloaded and pdf.expired.
Payload example (pdf.generated)
{
"event": "pdf.generated",
"timestamp": "2026-11-16T06:00:00.000000Z",
"data": {
"filename": "uuid.pdf",
"download_url": "https://pdf.funbrew.cloud/dl/token",
"file_size": 45321,
"source_type": "template",
"expires_at": "2026-11-17T06:00:00.000000Z"
}
}This download_url is the share URL (/dl/…) that needs no API key. It is different from the download_url in the generation API response (/api/pdf/download/…, which requires an API key).
For pdf.downloaded, data also includes download_count (times downloaded) and remaining_downloads (downloads left; -1 means unlimited).
Slack Integration
When you specify a Slack Incoming Webhook URL, notifications are automatically formatted as Slack Block Kit messages with download buttons.
Webhook and Slack notifications can also be configured from the dashboard.
Signature Verification
Standard webhooks include an X-Webhook-Signature: sha256=HMAC(payload, secret) header.
Usage
/api/usageReturns current month's usage count, remaining quota, plan info, and enabled features.
S3 Storage Integration
Auto-upload generated PDFs to AWS S3 or S3-compatible services. When configured, PDFs are saved to both local and S3 storage, and the response includes an s3_url.
Configure from the dashboard. Also available via API:
/api/storage-config/api/storage-config/api/storage-config/api/storage-config| Name | Type | Required | Description |
|---|---|---|---|
driver | string | Yes | s3 |
config.bucket | string | Yes | Bucket name |
config.region | string | Yes | Region |
config.key | string | Yes | Access key ID |
config.secret | string | Yes | Secret access key |
config.endpoint | string | Custom endpoint (for S3-compatible services like Wasabi) |
Credentials are encrypted at rest on the server.
Error Codes
| Status | Meaning | Action |
|---|---|---|
401 | Authentication error | Check your API key |
403 | Forbidden / Feature not enabled | Upgrade your plan or check IP restrictions |
404 | Resource not found | Check the filename or ID |
422 | Validation error | Check request parameters |
429 | Limit exceeded (per-minute requests, monthly generations, or storage) | Check the error field. rate_limited → per-minute limit: wait the number of seconds in the Retry-After header and retry. monthly_limit → monthly generation limit (a batch can also exceed it once its items are added): wait until next month or upgrade. storage_limit → storage limit: delete PDFs you no longer need or upgrade |
500 | Server error | Contact support |
All error responses follow this format:
{ "success": false, "message": "Error description" }A 429 response also includes error, which names the limit (rate_limited / monthly_limit / storage_limit). message is human-readable text that may change, so do not use it for branching.
{ "success": false, "error": "monthly_limit", "message": "Monthly PDF generation limit reached. Limit: 30" }