Generate Document
Generates a document from a template and a set of merge parameters and stores it in a destination
| Endpoint URL | Method |
|---|---|
https://apps.inkit.com/api/v1/generate | POST |
Request properties
| Property | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | Template ID to render |
name | string | No | Document name |
description | string | No | Document description |
custom_data | object | No | Custom metadata |
merge_parameters | object | Yes | Template merge parameters (key-value pairs) |
destinations | object | No | Commercial 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
| Property | Type | Description |
|---|---|---|
id | string | Public ID of the render data |
document_id | string | Public ID of the document |
file_id | string | Public ID of the inkit_storage file |
salesforce_piece_id | string | Returned only when the corresponding destination is included. |
magic_link_piece_id | string | Returned only when the corresponding destination is included. |
digital_signature_item_id | string | Returned only when the corresponding destination is included. |
amazon_s3_piece_id | string | Returned only when the corresponding destination is included. |
box_piece_id | string | Returned only when the corresponding destination is included. |
dropbox_piece_id | string | Returned only when the corresponding destination is included. |
google_drive_piece_id | string | Returned only when the corresponding destination is included. |
docusign_piece_id | string | Returned only when the corresponding destination is included. |
mail_piece_id | string | Returned 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.pdfAlternatively, 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.
Updated 11 days ago