This guide walks you through generating your first document from scratch — creating a Data Source, connecting it to a Document Solution, uploading a template and data, and generating the output. By the end you'll have a finished document delivered in a single API call.
Make sure you have:
Authorization bearer token and your API key — see Authentication if notA Data Source tells a Document Solution where its data comes from. Create one using loadMethod: "Storage", the simplest option — the data you upload later is used as-is, with no transformation:
POST https://api.doctavian.com/v1/documents/datasource/create
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"name": "Contract Data Source",
"description": "Storage-based data source for contract generation",
"loadMethod": "Storage"
}The response returns a Data Source GUID — copy it, you'll need it in the next step:
{
"result": {
"data": {
"dataSourceGuid": "a44410d8-e75d-4cfb-ae34-706edcbacf84",
"name": "Contract Data Source",
"description": "Storage-based data source for contract generation",
"loadMethod": "Storage"
},
"statusCode": 200,
"message": "OK"
}
}The Document Solution ties your Data Source to one or more templates. Create it by referencing the Data Source's dataGuid:
POST https://api.doctavian.com/v1/documents/solution/create
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"name": "Contract Generation Pipeline",
"description": "Pipeline for generating signed contracts",
"dataGuid": "<your-data-source-guid>"
}The response returns a Document Solution GUID, nested under data.documentSolution:
{
"result": {
"data": {
"documentSolution": {
"documentSolutionGuid": "4c4b7221-9b88-486d-b2bb-3718866ebdd1",
"dataGuid": "a44410d8-e75d-4cfb-ae34-706edcbacf84",
"name": "Contract Generation Pipeline",
"description": "Pipeline for generating signed contracts"
}
},
"statusCode": 200,
"message": "OK"
}
}Upload your template file as multipart form-data:
POST https://api.doctavian.com/v1/documents/template/upload
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: multipart/form-data
file: <your template>The response returns an id — this is what you'll pass as template.urn when generating:
{
"result": {
"data": {
"files": [
{
"id": "c04624ab-33a4-4099-bf63-489e00e77709",
"fileName": "your-template.docx"
}
]
},
"statusCode": 201,
"message": "Created"
}
}Upload your JSON data file the same way:
POST https://api.doctavian.com/v1/documents/data/upload
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: multipart/form-data
file: <your data file>The response returns an id — this is what you'll pass as data.urn:
{
"result": {
"data": {
"files": [
{
"id": "3ca7cc99-0b30-4f69-b6aa-b6dc3c9deca9",
"fileName": "your-data.json"
}
]
},
"statusCode": 201,
"message": "Created"
}
}With the template and data uploaded, generate the document in a single call. The request body has three top-level sections:
urn and specifies its file formaturnPOST https://api.doctavian.com/v1/documents/document/generate
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"template": {
"name": "your-template.docx",
"urn": "<your-template-id>",
"fileFormat": "docx",
"loadMethod": "Storage"
},
"data": {
"loadMethod": "Storage",
"urn": "<your-data-id>"
},
"document": {
"name": "signed-contract",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root",
"locale": "en",
"timezone": "Europe/Dublin"
}
}A successful response returns the generated document's URN:
{
"result": {
"statusCode": 201,
"message": "Created",
"data": {
"document": {
"deliveryMethod": "Storage",
"name": "signed-contract",
"fileFormat": "pdf",
"urn": "50101a07-1c20-4929-ac78-9199b263c002"
}
}
},
"consumption": [
{ "dimension": "documents-generated", "value": 1 }
]
}See the full document generate schema in the API Reference.
The urn returned in Step 5 is the generated document's ID in storage. Download it with:
GET https://api.doctavian.com/v1/documents/document/<your-document-urn>/download
Authorization: Bearer <token>
x-api-key: <api-key>The response is the file itself, returned with Content-Type: application/pdf (or the appropriate MIME type for your output format) — not a JSON wrapper. Save the response body directly to open it and confirm your data landed correctly in the template.
For high-volume or batch generation, use POST /documents/document/generate/async instead of the synchronous endpoint. The request body is identical to Step 5 — same template, data, and document structure — with one addition: you need an x-client-authorization header so Doctavian knows where to send the callback once generation completes.
POST https://api.doctavian.com/v1/documents/document/generate/async
Authorization: Bearer <token>
x-api-key: <api-key>
x-client-authorization: <client-token>
Content-Type: application/json
{
"template": {
"name": "your-template.docx",
"urn": "<your-template-id>",
"fileFormat": "docx",
"loadMethod": "Storage"
},
"data": {
"loadMethod": "Storage",
"urn": "<your-data-id>"
},
"document": {
"name": "signed-contract",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root",
"locale": "en",
"timezone": "Europe/Dublin"
}
}A successful call returns 201 Created. Rather than waiting for the finished document in the response, Doctavian processes the request in the background and calls back to the destination configured in your x-client-authorization token once it's done. See Building the signed headers for how to construct that token.