Generate a document.
Changed onRenders a document by merging a template with JSON data, or converts a pre-uploaded document to another format:
- Document generation - merge a Carbone template (using {d.field} tags) with a JSON dataset to produce a customised document.
- Document conversion - omit data (from carbone-version: 5) and pass a convertTo value to convert a pre-uploaded document (DOCX, XLSX, PPTX, HTML, ODT, ODS, ODP, ODG…) to another format. To convert without pre-uploading, use POST /render/template with a base64-encoded document in the body instead.
Features
- Dynamic Document Generation: Create documents by merging pre-designed templates with dynamic JSON data, ensuring consistency and customization in generated documents.
- Version Support: Utilize either a template ID or a specific version ID to control which version of a template is used for rendering, allowing for precise document generation.
- Output Format Flexibility: Generate documents in various formats by specifying output types, catering to diverse business and compliance needs.
- Constant Template ID: Multiple versions of a template can be associated with a single Template ID. Carbone checks the deployedAt timestamp to determine which version of the template is actively deployed. The version with the most recent deployedAt timestamp is selected for document generation.
Notes
- Direct download - Use the download query parameter and set it to true to receive the file as a direct stream, or false to receive a renderId for a separate GET /render/{renderId} download call.
- Converter - When the output format differs from the template format, set converter to L (LibreOffice, default), I (Carbone ICE, the fastest for DOCX/ODT to PDF), C (Chromium, for HTML) or O (OnlyOffice). See the converter field in the request body.
Request
- Base URLhttps://api.carbone.io
- AuthHTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
Unique identifier of the template or version ID
Query parameters
Controls how the document is returned.
- true: returns the document directly as a file stream (the Content-Type reflects the output format). The file is not stored on Carbone servers and no renderId is issued, so there is no need to call GET /render/{renderId}.
- false: returns a JSON object with a renderId; use GET /render/{renderId} to download the file in a second call.
Headers
Carbone API major version to use. Only a major version can be specified: it automatically includes all future minor versions and patches.
- 5: latest version, recommended.
- 4: default when the header is not provided.
- 3: legacy.
- staging: not intended for production environments.
It is strongly recommended to always set this header explicitly to avoid unexpected behavior. See API versioning documentation
URL that Carbone calls (HTTP POST) when an asynchronous render or conversion finishes. Providing it enables asynchronous mode, which raises the rendering timeout to 5 minutes.
Custom header forwarded on the webhook call only. It follows the carbone-webhook-header-<name> pattern, where any header <name> can be sent to your webhook (authorization is the most common). For the authorization header, this overrides carbone-egress-header-authorization for webhook calls.
Sets the authorization header Carbone sends on all egress traffic for this render: webhook calls, dynamic image URLs, and files fetched by appendFile. Example: carbone-egress-header-authorization: my-secret makes Carbone send authorization: my-secret on each outbound request. Only the authorization header can be customized, and the value must be shorter than 512 characters. For webhook calls, carbone-webhook-header-authorization overrides this value (webhook only).
Request body
Example request
{
"convertTo": "pdf",
"converter": "L",
"template": "base64-encoded-template",
"timezone": "Europe/Paris",
"lang": "fr-fr",
"complement": {},
"variableStr": "{#def = d.id}",
"reportName": "{d.date}",
"enum": {},
"translations": {
"fr": {
"one": "un"
},
"es": {
"one": "uno"
}
},
"currencySource": "EUR",
"currencyTarget": "USD",
"currencyRates": {
"EUR": 1,
"USD": 1.2
},
"batchSplitBy": "d.items",
"batchOutput": "zip",
"batchReportName": "report-{d.id}",
"preReleaseFeatureIn": 5000000,
"failOn": [
"IMAGE_URL_ERROR"
]
}Response
On success, by default a JSON response containing the renderId is returned. If the query parameter download=true is used, the response body is the converted/generated file stream and the Content-Type reflects the output format.
Example response
{
"data": {
"renderId": "MTAuMjAuMjEuMTAgICAg.pdf"
},
"message": "A render ID will be sent to your callback URL when the document is generated"
}Changes
- breaking
the
carbone-versionrequest header's property undefined was restricted to a list of enum values - breaking
the
headerrequest parametercarbone-versionwas restricted to a list of enum values - breaking
for the
queryrequest parameterdownload, default value was changed fromtruetofalse - breaking
request property
was restricted to a list of enum values - breaking
request property
///was restricted to a list of enum values - breaking
request property
///was restricted to a list of enum values - breaking
request property
///was restricted to a list of enum values - breaking
request property
///was restricted to a list of enum values - breaking
request property
was restricted to a list of enum values - breaking
the
///request property type changed fromnumbertointeger - breaking
the
///request property type changed fromnumbertointeger - warning
the
///request property's max was set to100.00 - warning
the
///request property's min was set to0.00 - info
added the new optional
headerrequest parametercarbone-egress-header-authorization - info
added the new optional
headerrequest parametercarbone-webhook-header-authorization - info
added the new optional
headerrequest parametercarbone-webhook-url - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
/// - info
added the new optional request property
- info
added the new optional request property
- info
added the new enum value
3to theheaderrequest parametercarbone-version - info
added the new enum value
4to theheaderrequest parametercarbone-version - info
added the new enum value
5to theheaderrequest parametercarbone-version - info
added the new enum value
stagingto theheaderrequest parametercarbone-version - info
for the
headerrequest parametercarbone-version, the type was generalized fromintegertostring, and format fromint32to no format - info
the request property
became optional - info
the
request property default valuezipwas added - info
the
request property default valueLwas added - info
the
request property default value100was removed - info
added the new
0.00enum value to the request property/// - info
added the new
0.00enum value to the request property/// - info
added the new
0.00enum value to the request property/// - info
added the new
1.00enum value to the request property/// - info
added the new
1.00enum value to the request property/// - info
added the new
1.00enum value to the request property/// - info
added the new
1200.00enum value to the request property/// - info
added the new
15.00enum value to the request property/// - info
added the new
150.00enum value to the request property/// - info
added the new
16.00enum value to the request property/// - info
added the new
17.00enum value to the request property/// - info
added the new
2.00enum value to the request property/// - info
added the new
2.00enum value to the request property/// - info
added the new
2.00enum value to the request property/// - info
added the new
20.00enum value to the request property/// - info
added the new
3.00enum value to the request property/// - info
added the new
3.00enum value to the request property/// - info
added the new
300.00enum value to the request property/// - info
added the new
4.00enum value to the request property/// - info
added the new
4.00enum value to the request property/// - info
added the new
600.00enum value to the request property/// - info
added the new
75.00enum value to the request property/// - info
added the new
Cenum value to the request property - info
added the new
Ienum value to the request property - info
added the new
Lenum value to the request property - info
added the new
Oenum value to the request property - info
added the new
pdfenum value to the request property - info
added the new
zipenum value to the request property - info
request property
list-of-types was widened by adding typesarrayto media typeapplication/json - info
the
/////request property's minLength was decreased from1to0 - info
added the non-success response with the status
- info
added the optional property
to the response with the status
- breaking
- breaking
for the
queryrequest parameterdownload, default value was changed fromfalsetotrue - breaking
the
request property type changed fromstringto no type - info
added the new optional request property
- info
added
subschema #1subschema #2to therequest propertyoneOflist - info
added the media type
application/mswordfor the response with the status - info
added the media type
application/rtffor the response with the status - info
added the media type
application/vnd.ms-excelfor the response with the status - info
added the media type
application/vnd.ms-excel.sheet.binary.macroenabled.12for the response with the status - info
added the media type
application/vnd.oasis.opendocument.presentation-templatefor the response with the status - info
added the media type
application/vnd.oasis.opendocument.spreadsheet-templatefor the response with the status - info
added the media type
application/vnd.oasis.opendocument.text-templatefor the response with the status - info
added the media type
application/xhtml+xmlfor the response with the status - info
added the media type
application/zipfor the response with the status - info
added the media type
image/webpfor the response with the status - info
added the media type
image/x-portable-bitmapfor the response with the status - info
added the media type
image/x-portable-graymapfor the response with the status - info
added the media type
image/x-portable-pixmapfor the response with the status - info
added the media type
image/x-wmffor the response with the status - info
added the media type
text/markdownfor the response with the status - info
added the non-success response with the status
- breaking