REST API Overview

Integrate automated document generation into your apps, CRM, or custom scripts using our simple HTTP REST API.

Looking for interactive reference?

Browse auto-generated endpoints, schemas, and test live queries from your browser.

Open Interactive Docs

Authentication

The TRYDOKU API uses Bearer Tokens to authenticate requests. You must include your token in the Authorization header of every request:

Authorization: Bearer YOUR_API_TOKEN
Need a token? You can generate and revoke API tokens under the API Keys tab in your Account Settings. Keep your tokens secure — never share them in public repositories.

API Endpoints

All request URLs start with the base URL https://www.trydoku.com/api.

Method Endpoint Description
POST /v1/generate Trigger a new document generation batch from a template.
GET /v1/batches/{batchId} Retrieve status and links of a document generation batch.
GET /v1/batches/{batchId}/zip Download all completed batch documents in a single ZIP file.

Quickstart: Generate Documents

To generate documents, send a JSON payload containing the template_uuid and an array of data items. Each item represents a single document row with its respective placeholder replacement values.

curl -X POST "https://www.trydoku.com/api/v1/generate" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "template_uuid": "e81d77a2-f674-4b53-a8ee-bf350284e311",
    "data": [
      {
        "Client_Name": "Acme Corporation",
        "Invoice_Number": "INV-2026-001",
        "Amount_Due": "1250.00"
      },
      {
        "Client_Name": "Globex Industries",
        "Invoice_Number": "INV-2026-002",
        "Amount_Due": "3400.00"
      }
    ]
  }'

Response Example

If validation and credit validation pass, the API returns a 201 Created response showing details of the newly created generation batch.

{
  "data": {
    "id": "a91b22e1-a714-4113-a83d-bc350284e300",
    "status": "processing",
    "total_items": 2,
    "processed_items": 0,
    "failed_items": 0,
    "created_at": "2026-07-16T18:20:00.000000Z",
    "updated_at": "2026-07-16T18:20:00.000000Z",
    "links": {
      "self": "https://www.trydoku.com/api/v1/batches/a91b22e1-a714-4113-a83d-bc350284e300",
      "zip": null
    }
  }
}

Validation Schema & Data Types

Validation schemas are configured directly within the interactive Template Composer UI. Once a schema is saved, all generation requests (both via the web dashboard and the public /v1/generate API) are validated against it automatically.

Supported Data Types & Rules

  • text: Default type. Allows any character string. Can be marked as required.
  • number: Strict numeric validation. Supports min, max, and step properties. Display formats include plain, currency (requires currency code e.g. "USD"), and percent.
  • date: Enforces strict timezone-free calendar dates in YYYY-MM-DD format.
  • boolean: Accepts logical states. Translates true/false, 1/0, and yes/no case-insensitively.
  • select: Dropdown lists. Enforces strict case-sensitive matches against a pre-configured array of options.

Schema Structure (JSON)

{
  "version": 1,
  "columns": {
    "invoice_date": {
      "type": "date",
      "required": true
    },
    "customer_approved": {
      "type": "boolean",
      "required": false
    }
  },
  "loops": {
    "items": {
      "columns": {
        "price": {
          "type": "number",
          "required": true,
          "format": "currency",
          "currency": "USD",
          "min": 0,
          "step": 0.01
        },
        "category": {
          "type": "select",
          "required": true,
          "options": ["hardware", "software", "support"]
        }
      }
    }
  }
}

Checking Status & Downloading

Since document generation is processed asynchronously, you must poll the batch status route using the batch ID returned in the generation response.

Check Status

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
  "https://www.trydoku.com/api/v1/batches/a91b22e1-a714-4113-a83d-bc350284e300"

Once status changes to "completed", a ZIP download link will be available in the links.zip response key:

{
  "data": {
    "id": "a91b22e1-a714-4113-a83d-bc350284e300",
    "status": "completed",
    "total_items": 2,
    "processed_items": 2,
    "failed_items": 0,
    "created_at": "2026-07-16T18:20:00.000000Z",
    "updated_at": "2026-07-16T18:20:05.000000Z",
    "links": {
      "self": "https://www.trydoku.com/api/v1/batches/a91b22e1-a714-4113-a83d-bc350284e300",
      "zip": "https://www.trydoku.com/api/v1/batches/a91b22e1-a714-4113-a83d-bc350284e300/zip"
    }
  }
}

Errors

The API uses standard HTTP status codes to communicate success or failure:

Code Description Typical Cause
401 Unauthenticated API Token is invalid or missing from the Authorization header.
402 Payment Required Your account does not have enough remaining credits to generate the requested documents.
422 Validation Error Missing required parameters (e.g., template_uuid), malformed payload, or template schema validation failure (errors returned in errors object mapped by field path e.g., data.0.invoice_date).