GenPDF API Documentation
GenPDF was built to solve a fundamental challenge in modern software development: the complexity of programmatic document generation. Traditionally, creating beautiful, structured PDFs required complex layout engines, manual design tweaking, and fragile templates. Our API leverages advanced intelligence to understand your document needs and deliver production-ready PDFs in seconds, allowing you to focus on your core product rather than document styling.
Overview
Why GenPDF?
Creating documents shouldn't feel like building a website from scratch every time. Whether it's an invoice, a resume, or a complex report, the design should be the least of your worries. GenPDF bridges the gap between raw data and professional presentation by using AI to handle the heavy lifting of layout, typography, and structure.
Who uses GenPDF?
SaaS & Fintech
Generate automated invoices, receipts, and financial statements without maintaining complex PDF templates.
HR Tech
Convert user profiles or candidate data into professionally formatted resumes and offer letters instantly.
Education & EdTech
Automate the creation of certificates, diplomas, and student progress reports with personalized data.
E-commerce
Create dynamic product catalogs, shipping labels, and order summaries on the fly from your inventory data.
API Versions
GenPDF currently supports both the recommended v2 job-based API and the older v1 synchronous API. In v2, the create endpoint returns only the queued job response, and the job status endpoint returns processing, completed, or failed states.
Endpoint Version
Switch between v2 and v1 to see the correct endpoints and response formats.
v2 - New, Faster & Reliable
Recommended async workflow. First create a job, then check its status using the job ID.
| Method | Endpoint | Description |
|---|---|---|
| POST | /public/v2/generate-pdfCreate PDF Job | Creates a PDF generation job and returns a queued response with a job ID. |
| GET | /public/v2/jobs/{job_id}Check Job Status | Checks the status of an existing PDF job and returns progress or the finished PDF URL. |
Create PDF Job
Creates a PDF generation job and returns a queued response with a job ID.
/public/v2/generate-pdfExample Request
curl -X POST "https://api.genpdf.app/public/v2/generate-pdf" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"prompt":"Create a simple invoice PDF for John Doe - $500"}'Example Responses
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890",
"status": "queued",
"check_status_url": "https://api.genpdf.app/public/v2/jobs/a1b2c3d4-e5f6-7890-abcd-1234567890"
}{ "error": "Invalid or missing API key" }
{ "error": "Rate limit exceeded. Try again in 60s" }Notes
- This endpoint starts the job and returns queued metadata.
- It does not return processing, completed, or failed states.
Check Job Status
Checks the status of an existing PDF job and returns progress or the finished PDF URL.
/public/v2/jobs/{job_id}Example Request
curl "https://api.genpdf.app/public/v2/jobs/a1b2c3d4-e5f6-7890-abcd-1234567890" -H "Authorization: Bearer YOUR_API_KEY"
Example Responses
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890",
"status": "processing"
}{
"job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890",
"status": "completed",
"pdf_url": "https://bjubpqvkpmjxnbmgqfdx.supabase.co/storage/v1/object/public/pdfs/a1b2c3d4.pdf"
}{
"job_id": "a1b2c3d4-e5f6-7890-abcd-1234567890",
"status": "failed",
"error": "Failed to generate PDF: Invalid prompt or generation timeout",
"prompt": "Create a simple invoice PDF"
}{ "error": "Invalid or missing API key" }
{ "error": "Job not found" }
{ "error": "Rate limit exceeded. Try again in 60s" }Notes
- Poll this endpoint using the job_id returned by the create-job call.
- Use pdf_url when the status becomes completed.
Authentication
All requests must include your API key in the Authorization header.
Security Best Practice
Never share your API keys or expose them in client-side code. We store only SHA-256 hashes of your keys for maximum security.
Rate Limiting
To ensure stability, we apply rate limits per API key. If you exceed these limits, the API will return a 429 Too Many Requests response.
Per Minute
10 Requests
Per Day
1,000 Requests
Token-Based Billing
We use a consumption-based token model similar to OpenAI. Tokens are deducted only after successful AI generation.
Simple Pricing
$1.00
per 100,000 tokens
Efficiency
~2,000 - 5,000
tokens per average PDF
- Tokens are deducted atomically during request processing
- Both input and output tokens are counted
- Failed or timed-out requests consume ZERO tokens
- View your detailed usage ledger in the dashboard
Legacy v1 Request Format
This section shows the older v1 synchronous request format. For the recommended v2 create-job and job-status flow, use the API Versions section above.
Endpoint
Body (JSON)
{
"prompt": "Create a detailed professional resume for a Senior Software Engineer including skills in React, Node.js, and Cloud Architecture."
}Legacy v1 cURL Example
curl -L -X POST "https://bjubpqvkpmjxnbmgqfdx.supabase.co/functions/v1/generate-pdf" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"prompt": "Create a simple invoice for web development services."
}' \
--output generated.pdf* This example is for v1. The response is a binary PDF, so use the --output flag to save it directly to a file.
Service Guarantees
Atomicity
Tokens are deducted only after successful generation.
No Waste
Failed or timed-out requests consume zero tokens.
Immutability
Usage records are permanent and auditable.
Control
Revoke API keys instantly without affecting billing.
Error Responses
| Status | Meaning | Common Cause |
|---|---|---|
| 400 | Bad Request | Invalid or missing prompt |
| 401 | Unauthorized | Missing or invalid API key |
| 402 | Payment Required | Insufficient token balance |
| 429 | Too Many Requests | Rate limit exceeded |
| 504 | Gateway Timeout | AI generation took too long |
| 500 | Server Error | Internal processing error |
Ready to start building?
Claim your 10,000 free credits and transform text to PDF in seconds.
Claim Free Credits