Complete reference for the Phantom Ink PDF generation API.
Pass your API key in the Authorization header:
Authorization: Bearer sk_live_abc123xyz789Agents can omit the API key header. The API returns HTTP 402 Payment Required with payment instructions. Agent signs a USDC transaction on Polygon and resubmits the request.
| Method | Path | Description |
|---|---|---|
| POST | /api/generate | Generate a PDF from HTML, Markdown, or template |
| GET | /api/documents/{id} | Retrieve a previously generated document |
| GET | /api/usage | Get current credit balance and usage statistics |
| POST | /api/templates | List available document templates |
| POST | /api/health | Health check endpoint |
{
"format": "pdf", // "pdf" (required)
"html": "<h1>Document</h1>", // HTML string (one of: html, markdown, template)
"markdown": "# Document", // Markdown string (one of: html, markdown, template)
"template": "invoice", // Template name (one of: html, markdown, template)
"data": { // Template variables
"invoice_number": "INV-001",
"amount": "1000.00"
},
"options": {
"orientation": "portrait", // "portrait" or "landscape"
"margins": "1in", // CSS margin value
"style": "minimal", // CSS preset: "minimal", "formal", "modern"
"width": "8.5in", // Page width
"height": "11in" // Page height
}
}{
"success": true,
"document_id": "doc_abc123xyz789",
"url": "https://phantom-ink.melis.ai/documents/doc_abc123xyz789.pdf",
"created_at": "2026-03-28T10:30:00Z",
"cost_credits": 1,
"pages": 1
}Basic Plan1,000 requests/month
$0.005 per document. No burst limits.
Premium PlanUnlimited requests
$0.03 per document. Priority queue.
Rate limit headers included in all responses. Exceeding limits returns 429 Too Many Requests.
200Success400Bad Request — invalid parameters401Unauthorized — missing or invalid API key402Payment Required — x402 protocol429Too Many Requests — rate limit exceeded500Internal Server Error