DocuStream
← Documentation

API Reference

Complete REST API documentation with request and response examples.

Authentication

All requests must include an API key header:

HeaderUsed For
x-api-keyCustomer API calls (templates, PDFs, billing)
x-admin-keyAdmin 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

Endpoint Overview

POST
/api/templates

Create a new template

GET
/api/templates

List all templates

GET
/api/templates/:id

Get a specific template

PUT
/api/templates/:id

Update a template

DELETE
/api/templates/:id

Delete a template

POST
/api/pdfs/generate

Generate a PDF from a template

GET
/api/pdfs

List all PDFs

GET
/api/pdfs/:id/download

Get a fresh signed download URL

GET
/api/billing/usage

Get current month usage

GET
/api/billing/records

Get historical billing records

POST
/api/admin/customers

Create a customer (admin)

GET
/api/admin/customers

List all customers (admin)

GET
/api/admin/customers/:id/stats

Get customer statistics (admin)

GET
/api/admin/billing

Platform-wide billing overview (admin)

Templates API

Create a Template

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"
}

List Templates

GET /api/templates · Header: x-api-key

curl https://your-api.docustream.com/api/templates \
  -H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"

Update a Template

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 a Template

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

PDF Generation API

Generate a PDF

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"
}

Download / Refresh a Signed URL

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"

List PDFs

GET /api/pdfs · Header: x-api-key

curl https://your-api.docustream.com/api/pdfs \
  -H "x-api-key: ak_live_xxxxxxxxxxxxxxxx"

Billing API

Get Usage Summary

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 Billing Records

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

Admin endpoints require the x-admin-key header.

Create a Customer

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"
}
⚠️ Save the apiKey immediately — it is not recoverable after creation.

List Customers

curl https://your-api.docustream.com/api/admin/customers \
  -H "x-admin-key: YOUR_ADMIN_KEY"

Get Customer Statistics

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 }
}

Platform Billing Overview

curl https://your-api.docustream.com/api/admin/billing \
  -H "x-admin-key: YOUR_ADMIN_KEY"