Generate Document
Create a new document by submitting structured data and specifying a template. The result will be a .docx or .pdf file, depending on the output type you choose.
Endpoint
You can generate a document by sending a POST request to the following endpoint:
POST https://docubloom.com/api/template/generateHeaders
All requests must include your API key in the Authorization header. If you don’t have an API key yet, you can create one in your organization settings .
You should also set the Content-Type header to application/json to indicate that you are sending JSON data.
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest Body
Definition of fields
| Field | Type | Required | Description |
|---|---|---|---|
templateKey | string | ✅ | Key of the template to use |
output | string | ✅ | Either DOCX or PDF |
data | object | ✅ | JSON object matching the template variables |
Example Request Body
{
"templateKey": "my-template-key",
"output": "PDF",
"data": {
"name": "John",
"age": 30
}
}Response
If the request is successful, you will receive a 200 OK status code along with the document content in the response body.
The Content-Type header will indicate the format of the document generated:
- for PDF outputs:
application/pdf - for DOCX outputs:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
Status Codes
The API will return different HTTP status codes based on the outcome of your request.
| Status | Description |
|---|---|
200 | Document successfully generated |
400 | Invalid request body |
401 | Unauthorized – missing or invalid API key |
402 | Payment required – insufficient credit balance |
404 | Template not found |
500 | Internal server error |