DocForge

API documentation

Build PDFs from stored templates

Sign up, create a template in your dashboard, generate an API key, and start rendering PDFs with one authenticated request.

Authentication

Every public API request must include your DocForge key in the X-API-Key header. Generate keys from the dashboard after signing up. Keys are only shown in full once, so store them securely in your secrets manager.

X-API-Key: df_live_your_generated_key

Rate Limits

All /api/v1/* requests enforce a per-key burst limit over a 10 second window. Unauthenticated traffic is also capped at 30 requests per second per IP address before key validation to reduce brute-force guessing and abuse.

TierRequests / secondBurst allowance
Free10 requests / second100 requests / 10 second window
Pro50 requests / second500 requests / 10 second window
Business200 requests / second2000 requests / 10 second window

Responses include the following headers so clients can pace requests proactively:

  • X-RateLimit-Limit — total requests allowed in the current 10 second window
  • X-RateLimit-Remaining — remaining requests before throttling
  • X-RateLimit-Reset — Unix timestamp when the current window resets
  • Retry-After — included on 429 responses with the wait time in seconds
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 3
X-RateLimit-Limit: 500
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1712100000

{
  "error": "Rate limit exceeded",
  "retryAfter": 3
}

Endpoints

All routes below are available under the same base URL as your DocForge app.

Create a new stored template for the authenticated API key owner.

POST/api/v1/templates

Headers

  • Content-Type: application/json
  • X-API-Key: df_live_...

Request

interface CreateTemplateRequest {
  name: string;
  description?: string;
  content: string;
}

Response

{
  "id": "clx123",
  "name": "Invoice",
  "description": "Monthly invoice template",
  "createdAt": "2026-04-02T10:00:00.000Z"
}

cURL

curl -X POST http://localhost:3000/api/v1/templates   -H "Content-Type: application/json"   -H "X-API-Key: df_live_your_key"   -d '{
    "name": "Invoice",
    "description": "Monthly invoice template",
    "content": "<h1>Invoice {{invoiceNumber}}</h1>"
  }'

List all templates available to the authenticated user.

GET/api/v1/templates

Headers

  • X-API-Key: df_live_...

Request

No request body

Response

[
  {
    "id": "clx123",
    "name": "Invoice",
    "description": "Monthly invoice template",
    "createdAt": "2026-04-02T10:00:00.000Z",
    "updatedAt": "2026-04-02T10:00:00.000Z"
  }
]

cURL

curl http://localhost:3000/api/v1/templates   -H "X-API-Key: df_live_your_key"

Fetch one template, including full content, by ID.

GET/api/v1/templates/:id

Headers

  • X-API-Key: df_live_...

Request

No request body

Response

{
  "id": "clx123",
  "name": "Invoice",
  "description": "Monthly invoice template",
  "content": "<h1>Invoice {{invoiceNumber}}</h1>",
  "createdAt": "2026-04-02T10:00:00.000Z",
  "updatedAt": "2026-04-02T10:00:00.000Z"
}

cURL

curl http://localhost:3000/api/v1/templates/clx123   -H "X-API-Key: df_live_your_key"

Delete a stored template by ID.

DELETE/api/v1/templates/:id

Headers

  • X-API-Key: df_live_...

Request

No request body

Response

{
  "success": true
}

cURL

curl -X DELETE http://localhost:3000/api/v1/templates/clx123   -H "X-API-Key: df_live_your_key"

Render a stored template with JSON data and return a PDF binary.

POST/api/v1/render

Headers

  • Content-Type: application/json
  • X-API-Key: df_live_...

Request

interface RenderRequest {
  templateId: string;
  data: Record<string, unknown>;
  options?: {
    format?: 'A4' | 'Letter';
    landscape?: boolean;
    margin?: {
      top?: string;
      right?: string;
      bottom?: string;
      left?: string;
    };
  };
}

Response

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.pdf"

cURL

curl -X POST http://localhost:3000/api/v1/render   -H "Content-Type: application/json"   -H "X-API-Key: df_live_your_key"   -d '{
    "templateId": "clx123",
    "data": {
      "customer": "Acme Inc.",
      "invoiceNumber": "INV-2026-042"
    }
  }'   --output document.pdf

Fetch current monthly usage totals and plan limits for the key owner.

GET/api/v1/usage

Headers

  • X-API-Key: df_live_...

Request

No request body

Response

{
  "tier": "FREE",
  "limit": 50,
  "used": 12,
  "remaining": 38,
  "periodStart": "2026-04-01T00:00:00.000Z",
  "periodEnd": "2026-04-30T23:59:59.999Z"
}

cURL

curl http://localhost:3000/api/v1/usage   -H "X-API-Key: df_live_your_key"

Template Guide

Templates are HTML documents rendered with Handlebars. Use variable interpolation, conditionals, and loops to generate invoices, contracts, reports, and custom branded output.

  • • Variables: {{customer.name}}
  • • Conditionals: {{#if notes}}...{{/if}}
  • • Loops: {{#each items}}...{{/each}}
<html>
  <body>
    <h1>Invoice {{invoiceNumber}}</h1>
    <p>Customer: {'{{customer.name}}'}</p>
    <ul>
      {{#each items}}
        <li>{{name}} — {{quantity}} × {{price}}</li>
      {{/each}}
    </ul>
    {{#if notes}}
      <p>Notes: {{notes}}</p>
    {{/if}}
  </body>
</html>

Plans & Monthly Quotas

TierMonthly limitIncluded features
Free50 docs / monthHandlebars templating, PDF rendering, API access, usage analytics
Pro5,000 docs / monthEverything in Free plus priority rendering and email support
Business50,000 docs / monthEverything in Pro plus custom templates, dedicated support, and SLA

Error Codes

StatusMeaning
400Invalid body, template data, or malformed payload
401Missing or invalid API key
402Usage limit exceeded for current billing period
404Requested template resource not found
429Rate limit exceeded — check Retry-After header
500Unexpected render or server failure