PDF Generation API
Generate professional PDF documents — invoices, receipts, and reports — via API. Built with pdf-lib featuring styled headers, line-item tables, automatic tax calculations, and A4 formatting.
/api/v1/pdf/generateTry it out
/api/v1/pdf/generateParameters
Code
curl -X POST "https://khaleejiapi.dev/api/v1/pdf/generate?type=invoice&title=Invoice¤cy=AED&taxRate=5" \ -H "Authorization: Bearer your_api_key"Invoice / Receipt Fields
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Required | "invoice" or "receipt" |
| title | string | Optional | Document title (auto-generated if omitted) |
| invoiceNumber | string | Optional | Invoice/receipt number (auto-generated if omitted) |
| from | object | Optional | Sender: name, address, email |
| to | object | Optional | Recipient: name, address, email |
| items | array | Required | Line items (1–50): description, quantity, unitPrice |
| currency | string | Optional | Currency code (default: AED) |
| taxRate | number | Optional | Tax percentage (default: 0) |
| notes | string | Optional | Footer notes |
Report Fields
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Required | "report" |
| title | string | Optional | Report title |
| sections | array | Required | Report sections (1–20): heading, content |
Rate Limits
| Plan | Requests/Month | Rate Limit |
|---|---|---|
| Free | 500 | 5 req/min |
| Starter | 5,000 | 30 req/min |
| Professional | 50,000 | 120 req/min |
| Business | 250,000 | 500 req/min |
Debugging & Support
Include X-Request-ID when contacting support
Every response from KhaleejiAPI includes an X-Request-ID header — a unique identifier that lets our support team pull the exact log entry for your request within seconds. Always share it when reporting an unexpected error or unexpected result.
How to capture it
JavaScript / fetch
const res = await fetch("https://khaleejiapi.dev/api/v1/...", {
headers: { Authorization: "******" },
});
const requestId = res.headers.get("x-request-id");
console.log("Request ID:", requestId);
// → e.g. "req_01j9xkz4vp8..."cURL
curl -si "https://khaleejiapi.dev/api/v1/..." \ -H "Authorization: ******" | grep -i x-request-id # → x-request-id: req_01j9xkz4vp8...
Browser DevTools
Open DevTools (F12) → Network tab → click the failing request → scroll to the Response Headers section → copy the value next to x-request-id.
For a full list of error codes and guidance on common issues, see the Troubleshooting guide.