Generate Document

Generates a document from a template and a set of merge parameters and stores it in a destination

Endpoint URLMethod
https://apps.inkit.com/api/v1/generatePOST

Request properties

PropertyTypeRequiredDescription
template_idstringYesTemplate ID to render
namestringNoDocument name
descriptionstringNoDocument description
custom_dataobjectNoCustom metadata
merge_parametersobjectYesTemplate merge parameters (key-value pairs)
destinationsobjectNoCommercial destination configurations. Each destination requires its integration and account entitlement. Magic Link also requires its feature flag. Sepire is a legacy account-configured mail integration.

Response properties

HTTP 201 — Render created successfully

PropertyTypeDescription
idstringPublic ID of the render data
document_idstringPublic ID of the document
file_idstringPublic ID of the inkit_storage file
salesforce_piece_idstringReturned only when the corresponding destination is included.
magic_link_piece_idstringReturned only when the corresponding destination is included.
digital_signature_item_idstringReturned only when the corresponding destination is included.
amazon_s3_piece_idstringReturned only when the corresponding destination is included.
box_piece_idstringReturned only when the corresponding destination is included.
dropbox_piece_idstringReturned only when the corresponding destination is included.
google_drive_piece_idstringReturned only when the corresponding destination is included.
docusign_piece_idstringReturned only when the corresponding destination is included.
mail_piece_idstringReturned only when the corresponding destination is included.

Example request and response

Create or select a template in your account. Match merge_parameters to its merge-variable names. Use an empty object when the template has no merge variables.

curl --fail-with-body --request POST \
  "$INKIT_BASE_URL/api/v1/generate" \
  --header "X-Inkit-API-Token: $INKIT_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "template_id": "tmpl_REPLACEWITHYOURTEMPLATEID",
    "merge_parameters": {},
    "destinations": {"inkit_storage": {"name": "Generated document"}}
  }'

POST /api/v1/renders is an alias for the same operation. The server automatically adds Inkit Storage when omitted.

A successful 201 response contains an id for the render, a file_id for the stored file, and a document_id for the document. Destination-specific identifiers appear when those destinations are included. These are different resource identifiers; do not interchange them.

Poll using the render id:

curl --fail-with-body "$INKIT_BASE_URL/api/v1/renders/$INKIT_RENDER_ID" \
  --header "X-Inkit-API-Token: $INKIT_API_KEY"

Inspect status, destination_status, and destinations. A successful create response means processing was queued; it does not mean rendering or delivery has completed. Poll at a bounded interval and stop on failure or your application timeout.

After completion, download raw document bytes using the document_id:

curl --fail-with-body \
  "$INKIT_BASE_URL/api/v1/documents/$INKIT_DOCUMENT_ID/download" \
  --header "X-Inkit-API-Token: $INKIT_API_KEY" \
  --output generated.pdf

Alternatively, GET /api/v1/files/download/{file_id} returns a JSON object, with base64 data in file, plus file_name and mime_type. Decode file before saving it. Do not save this JSON response directly as a PDF.

Downloads can return 423 while processing and 410 after expiration. Use files and documents to choose the appropriate resource API.


Did this page help you?