ComposeIt LogoComposeIt

API Reference

Integrate ComposeIt document generation into your workflows.

Generate PDF, HTML, and image files programmatically by sending JSON data payloads to your activated templates using the ComposeIt REST API.


Authentication

All API requests must include your API key in the custom header:

Header NameDescription
x-api-keyYour private organization API key. Manage these in Dashboard > API Keys.

[!CAUTION] Treat your API keys as passwords. Do not expose them in client-side code (e.g. browsers, mobile applications) or public source control repositories.


Render Document

Generate compiled documents by compiling a template definition with dynamic data.

  • Endpoint: POST /api/export
  • Content-Type: application/json

Request Parameters

FieldTypeRequiredDescription
templateIdStringYesThe UUID of the template you wish to render.
templateVersionNumberNoA specific version number to render. Defaults to the active template version.
formatsArrayYesOutput formats to compile. Allowed values: ["pdf", "html", "image", "mjml"].
dataObjectNoKey-value pairs containing variables referenced inside your template.
expiresAtStringNoISO 8601 timestamp indicating when the generated download links should expire. (Default: 24 hours).
imageTypeStringNoOutput format of compiled images: "png" or "jpg". (Default: "png").
isTestBooleanNoIf true, compiles the document with a watermark and avoids counting against subscription usage limits.

Request Example

curl -X POST https://app.composeit.app/api/export \
  -H "Content-Type: application/json" \
  -H "x-api-key: your_live_api_key_here" \
  -d '{
    "templateId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
    "formats": ["pdf", "html"],
    "isTest": false,
    "data": {
      "number": "INV-10024",
      "date": "2026-06-26",
      "due_data": "2026-07-26",
      "bill_to": {
        "name": "Acme Corporation",
        "address": "123 Industrial Parkway, Suite A"
      },
      "products": [
        {
          "name": "Premium Plan Subscription",
          "quantity": 1,
          "unit_price": 99.00,
          "total": 99.00
        },
        {
          "name": "Setup & Configuration Service",
          "quantity": 2,
          "unit_price": 50.00,
          "total": 100.00
        }
      ],
      "sub_total": 199.00,
      "tax": 19.90,
      "grand_total": 218.90,
      "notes": "Thank you for partnering with ComposeIt!"
    }
  }'

Response Format

Returns a JSON object mapping each requested format to its compilation result:

{
  "pdf": {
    "url": "https://storage.composeit.website/outputs/9b1deb4d-pdf-output.pdf",
    "sizeBytes": 204550,
    "mimeType": "application/pdf",
    "checksum": "d3b07384d113edec49eaa6238ad5ff00"
  },
  "html": {
    "htmlDocument": "<!DOCTYPE html><html><head><style>...</style></head><body>...</body></html>",
    "checksum": "3b07384d113edec49eaa6238ad5ff001",
    "mimeType": "text/html",
    "url": "",
    "sizeBytes": 14205
  }
}

Error Handling

API responses return appropriate HTTP status codes along with an error message:

  • 400 Bad Request: Missing headers, invalid JSON payload, or unsupported format configuration.
  • 401 Unauthorized: Invalid or missing x-api-key.
  • 404 Not Found: The requested template ID does not exist.
  • 500 Internal Server Error: An unexpected server-side rendering error occurred.

Example Error Payload

{
  "error": "Not found"
}
We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our privacy policy.