Skip to main content
POST
/
templates
/
{template_id}
/
generate-document
Generate Document from Template
curl --request POST \
  --url https://api.luminpdf.com/v1/templates/{template_id}/generate-document \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "tags": {
    "Client.Name": "Acme Corp",
    "Effective.Date": "2025-08-01"
  },
  "fields": {
    "CustomerName": "John Doe",
    "AgreeToTerms": true
  },
  "variables": {
    "Company.Name": "ACME Corp",
    "Document.Name": "NDA Document"
  },
  "collections": {
    "Opportunity.LineItems": [
      {
        "Product.Name": "Annual enterprise license",
        "Product.Quantity": "1",
        "Product.UnitPrice": "$1,000.00",
        "Product.Total": "$1,000.00"
      },
      {
        "Product.Name": "Premium support package",
        "Product.Quantity": "1",
        "Product.UnitPrice": "$500.00",
        "Product.Total": "$500.00"
      }
    ]
  },
  "document_name": "My Contract"
}
'
{
  "document_name": "<string>",
  "signed_url": "<string>",
  "expires_at": 123
}
This endpoint requires the following scope:templates

Authorizations

X-API-Key
string
header
required

Provide your API key in the X-API-Key header, e.g., X-API-Key: YOUR_API_KEY.

Path Parameters

template_id
string
required

ID of the template to generate document from.

Body

application/json
tags
object

Key–value pairs for Merge Tags defined in the Sign template. Keys must match tag names. Values replace the corresponding tags and are rendered as plain text in the generated document.

fields
object

Key–value pairs for Form Fields defined in the template. Keys must match field names. Values prefill the corresponding fields in the generated document.

variables
object

Key–value pairs for Variables defined in the AgreementGen template. Keys must match variable names. Values prefill the corresponding variables and are rendered as plain text in the generated document.

collections
object

Map of collection name → array of record objects used to expand table-scoped row-loop markers in the template.

  • Each key must match a collection name returned by Get Template Details under collections[].name.
  • Each value is an ordered array of flat record objects; each record is a key–value map where keys match the collection's variable names and values are strings.
  • Records are rendered in array order.
  • Maximum 100 items per collection, and up to 50 collections per request.

Applies to AgreementGen templates only. Ignored silently when the template type is not lumin.

document_name
string

Optional name for the generated document. If omitted, the document name defaults to the template's name.

Response

Returns the generated document.

document_name
string
required

Name of the generated document (from input or default).

signed_url
string<uri>
required

Signed HTTPS URL to download the generated document. Expires in 30 minutes.

expires_at
integer<unix-epoch>
required

Unix epoch timestamp (in seconds) indicating when signed_url will no longer work.