All requests must include an API key header:
| Header | Used For |
|---|---|
x-api-key | Customer API calls (templates, PDFs, billing) |
x-admin-key | Admin operations (customer management) |
# Customer request
curl -H "x-api-key: ak_live_xxxxxxxxxxxxxxxx" ...
# Admin request
curl -H "x-admin-key: YOUR_ADMIN_KEY" ...Base URL: https://your-api.docustream.com
/api/templatesCreate a new template
/api/templatesList all templates
/api/templates/:idGet a specific template
/api/templates/:idUpdate a template
/api/templates/:idDelete a template
/api/pdfs/generateGenerate a PDF from a template
/api/pdfsList all PDFs
/api/pdfs/:id/downloadGet a fresh signed download URL
/api/billing/usageGet current month usage
/api/billing/recordsGet historical billing records
/api/admin/customersCreate a customer (admin)
/api/admin/customersList all customers (admin)
/api/admin/customers/:id/statsGet customer statistics (admin)
/api/admin/billingPlatform-wide billing overview (admin)
POST /api/templates · Header: x-api-key
curl -X POST https://your-api.docustream.com/api/templates \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoice Template",
"content": "<html><body><h1>Invoice #{{invoiceNumber}}</h1><p>{{clientName}}</p></body></html>"
}'Response 201 Created:
{
"id": "tmpl_abc123",
"name": "Invoice Template",
"variables": ["invoiceNumber", "clientName"],
"createdAt": "2026-04-05T00:00:00.000Z"
}GET /api/templates · Header: x-api-key
curl https://your-api.docustream.com/api/templates \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"PUT /api/templates/:id · Header: x-api-key
curl -X PUT https://your-api.docustream.com/api/templates/tmpl_abc123 \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "name": "Invoice Template v2" }'DELETE /api/templates/:id · Header: x-api-key
curl -X DELETE https://your-api.docustream.com/api/templates/tmpl_abc123 \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"Response: 204 No Content
POST /api/pdfs/generate · Header: x-api-key
curl -X POST https://your-api.docustream.com/api/pdfs/generate \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"templateId": "tmpl_abc123",
"variables": {
"invoiceNumber": "INV-2026-001",
"clientName": "Acme Corp",
"amount": "1,250.00",
"dueDate": "April 30, 2026"
}
}'Response 201 Created:
{
"id": "pdf_xyz789",
"templateId": "tmpl_abc123",
"downloadUrl": "https://storage.example.com/pdfs/pdf_xyz789.pdf?X-Amz-Signature=...&X-Amz-Expires=3600",
"expiresAt": "2026-04-05T01:00:00.000Z",
"createdAt": "2026-04-05T00:00:00.000Z"
}GET /api/pdfs/:id/download · Header: x-api-key
curl "https://your-api.docustream.com/api/pdfs/pdf_xyz789/download?accessedBy=user@acme.com" \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"GET /api/pdfs · Header: x-api-key
curl https://your-api.docustream.com/api/pdfs \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"GET /api/billing/usage · Header: x-api-key
curl https://your-api.docustream.com/api/billing/usage \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"Response:
{
"currentMonth": "2026-04",
"pdfsGenerated": 47,
"plan": "pro"
}GET /api/billing/records · Header: x-api-key
curl https://your-api.docustream.com/api/billing/records \
-H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"Admin endpoints require the x-admin-key header.
POST /api/admin/customers · Header: x-admin-key
curl -X POST https://your-api.docustream.com/api/admin/customers \
-H "x-admin-key: YOUR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"email": "billing@acme.com",
"plan": "starter"
}'Response 201 Created:
{
"id": "cust_abc123",
"name": "Acme Corp",
"email": "billing@acme.com",
"apiKey": "ak_live_xxxxxxxxxxxxxxxx",
"plan": "starter",
"createdAt": "2026-04-05T00:00:00.000Z"
}apiKey immediately — it is not recoverable after creation.curl https://your-api.docustream.com/api/admin/customers \
-H "x-admin-key: YOUR_ADMIN_KEY"curl https://your-api.docustream.com/api/admin/customers/cust_abc123/stats \
-H "x-admin-key: YOUR_ADMIN_KEY"Response:
{
"customerId": "cust_abc123",
"pdfsGenerated": { "thisMonth": 47, "lastMonth": 120, "total": 342 },
"apiCalls": { "thisMonth": 215, "total": 1873 }
}curl https://your-api.docustream.com/api/admin/billing \
-H "x-admin-key: YOUR_ADMIN_KEY"