API Documentation
Complete reference for InvoPage PDF Generation API
Authentication
All API requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Get your API key from your dashboard after signing up.
Endpoints
POST /api/v1/pdf/from-html
Convert raw HTML to PDF.
Request Body
{
"html": "<html><body><h1>Hello</h1></body></html>",
"format": "A4",
"margin": { "top": 15, "bottom": 15, "left": 15, "right": 15 }
}
Response
Binary PDF file (application/pdf)
POST /api/v1/pdf/invoice
Generate professional invoices.
Request Body
{
"invoice": {
"from_name": "Your Company",
"from_address": "123 Main St",
"to_name": "Client Name",
"number": "INV-001",
"date": "2026-04-14",
"due_date": "2026-05-14",
"currency": "€",
"tax_rate": 21,
"items": [
{ "description": "Web Design", "quantity": 1, "price": 1000 },
{ "description": "Hosting", "quantity": 12, "price": 50 }
]
}
}
Response
Binary PDF (application/pdf)
POST /api/v1/pdf/receipt
Create receipts (6 templates: generic, hotel, restaurant, taxi, rent, parking, donation).
Request Body
{
"receipt": {
"business_name": "Coffee Shop",
"number": "RCP-001",
"date": "2026-04-14",
"payment_method": "cash",
"currency": "$",
"tax_rate": 0,
"template": "restaurant",
"items": [
{ "description": "Cappuccino", "quantity": 2, "price": 5 },
{ "description": "Pastry", "quantity": 1, "price": 4 }
]
}
}
Response
Binary PDF (application/pdf)
POST /api/v1/pdf/purchase-order
Generate purchase orders with line items, shipping, and payment terms.
Request Body
{
"po": {
"buyer_name": "Acme Corp",
"vendor_name": "Supplier Inc",
"po_number": "PO-12345",
"po_date": "2026-04-14",
"delivery_date": "2026-04-28",
"payment_terms": "net-30",
"currency": "€",
"tax_rate": 21,
"shipping_cost": 50,
"items": [
{ "description": "Widget A", "quantity": 100, "unit_price": 10 }
]
}
}
Response
Binary PDF (application/pdf)
Code Examples
cURL
curl -X POST https://invopage.com/api/v1/pdf/from-html \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice</h1>"}' \
-o invoice.pdf
Python
import requests
import json
api_key = "YOUR_API_KEY"
url = "https://invopage.com/api/v1/pdf/from-html"
payload = {
"html": "<h1>Invoice</h1><p>$100</p>"
}
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
with open("invoice.pdf", "wb") as f:
f.write(response.content)
Node.js
const fetch = require('node-fetch');
const fs = require('fs');
const apiKey = 'YOUR_API_KEY';
const url = 'https://invopage.com/api/v1/pdf/from-html';
const payload = {
html: '<h1>Invoice</h1><p>$100</p>'
};
fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(res => res.buffer())
.then(buffer => fs.writeFileSync('invoice.pdf', buffer));
Ruby
require 'net/http'
require 'json'
api_key = 'YOUR_API_KEY'
url = URI('https://invopage.com/api/v1/pdf/from-html')
payload = {
html: '<h1>Invoice</h1><p>$100</p>'
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url.path)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate(payload)
response = http.request(request)
File.write('invoice.pdf', response.body)
PHP
$apiKey = 'YOUR_API_KEY';
$url = 'https://invopage.com/api/v1/pdf/from-html';
$payload = [
'html' => '<h1>Invoice</h1><p>$100</p>'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
file_put_contents('invoice.pdf', $response);
Error Handling
The API returns standard HTTP status codes:
- 200 OK - Request successful, PDF returned
- 400 Bad Request - Invalid request format or missing required fields
- 401 Unauthorized - Invalid or missing API key
- 429 Too Many Requests - Rate limit exceeded
- 500 Server Error - Internal server error
Error responses include a JSON body with error details.
Rate Limits
| Plan | Rate | Daily Limit |
|---|---|---|
| Free | 10/minute | 1,000 |
| Starter | 30/minute | 100,000 |
| Pro | 60/minute | Unlimited |
Rate limit info is included in response headers (X-RateLimit-Remaining, X-RateLimit-Reset).