Quickstart
For Developers
Add document generation into your application
How to use API
You couldn't ask for a simpler API to generate your documents. Carbone is the ideal solution for all developers.
Read full HTTP API documentation.
Get your production or test API key
The first step is to create your Carbone account and get your API key from Carbone Account:
There are two API keys:
Production API key
: Can be used to generate production documents and can only be accessed after setting up a payment methodTest API key
: Can be used to generate test PDFs with Watermark Carbone
The chosen key will then be passed in the header of each API call:
"authorization": "Bearer YOUR_API_TOKEN"
Upload template
Next, you need to upload your template. Assuming that your template is the file first-template.docx, you can call the API with the following command:
export CARBONE_API_TOKEN="test_eyJhbG....o3wfR" # To be replaced by your api key
export ABSOLUTE_FILE_PATH="/User/..../first-template.docx" # To be replaced by absolute path of a template
curl --location --request POST 'https://api.carbone.io/template' \
--header 'carbone-version: 4' \
--header 'Expect:' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer '${CARBONE_API_TOKEN} \
--form 'template=@'${ABSOLUTE_FILE_PATH}
Result is :
"success":true,"data":{"templateId":"98b97771cff0e8da2999b895abe38f4116aea2b84c87c77502070523dce9ae1c"}
The unique templateID corresponding to your template is in this example : 98b97771cff0e8da2999b895abe38f4116aea2b84c87c77502070523dce9ae1c
.
You can avoid this step if you use the studio to manage your templates. In this case, the templateID is directly accessible here:
Render report
Then, send your data to the API (Learn more about rendering options):
curl --location --request POST 'https://api.carbone.io/render/98b97771cff0e8da2999b895abe38f4116aea2b84c87c77502070523dce9ae1c' \
--header 'carbone-version: 4' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer '${CARBONE_API_TOKEN} \
--data-raw '{ "data": { "name": "John" }, "convertTo": "pdf" }'
You then retrieve the renderID in the response :
"success":true, "data":{"renderId":"MTAuMjAuMjEuNDMgICAgS7O2lB3-MV5t2da0wGSWZwcmVwb3J0.pdf"}
Download your report
Finally, get your report with the following command:
curl --location --request GET 'https://api.carbone.io/render/MTAuMjAuMjEuNDMgICAgS7O2lB3-MV5t2da0wGSWZwcmVwb3J0.pdf' \
--header 'carbone-version: 4' \
-o 'report.pdf'
Use our SDK
If you prefer not to integrate our HTTP APIs directly, you can use our SDKs: