This guide sets up a Data Source with one of the file-based load methods — Storage, OneDrive or GoogleDrive — from preparing the data to refreshing it between runs. For live data from an API, see GraphQL Data Sources. For what a Data Source is and how the load methods compare, see Data Sources.
You only need a Data Source record when you generate through Document Solutions and Document Requests. A one-call
POST /documents/document/generatetakes the same information inline in itsdataobject.
Shape your JSON to match what the template refers to, following the data format: named lists of records under a root data object, with every value a pre-formatted string.
{
"data": {
"Customer": [
{ "Name": "Acme Logistics Group", "AccountId": "0001008213" }
],
"Invoice": [
{
"InvoiceNumber": "INV-1001",
"EffectiveDate": "Jun 30, 2025",
"LineItems": [
{ "Description": "Freight", "UnitPrice": "4,800" }
]
}
]
}
}The object and field names are what your template refers to — {!Customer.Name}, a repeater over Invoice, and so on.
Upload to Doctavian Storage with POST /documents/data/upload, either as .json files in multipart/form-data or as a raw application/json body:
POST https://api.doctavian.com/v1/documents/data/upload
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: multipart/form-data
file: customer-data.json{
"result": {
"data": {
"files": [
{ "id": "3f9a7c14-2b8e-4d6a-9f01-5c7e2a1b3d4e", "fileName": "customer-data.json" }
]
}
}
}Keep the file's id: it becomes the Data Source's urn in Step 3, or can go straight into the data of a one-call generate. If the upload is rejected with 400 for its shape, check the root data object and that its members are lists.
The uploaded file is held for 24 hours, and removed sooner by the first generation that reads it, whether it succeeds or fails — see Storage. Step 6 covers refreshing it.
Keep the JSON file on the drive and note its file id; it becomes the Data Source's urn. Make sure the file is accessible to the caller's account for that drive, and that an account admin has connected that account in the portal under Self-service → Connectors. Drive files are not consumed by generation, so you can skip Step 6.
Give the Data Source a name and a loadMethod, and set urn to where the data is.
POST https://api.doctavian.com/v1/documents/datasource/create
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"dataSource": {
"name": "Q3 Sales Report Data",
"description": "Account records used for quarterly reports.",
"urn": "3f9a7c14-2b8e-4d6a-9f01-5c7e2a1b3d4e",
"loadMethod": "Storage",
"documentSolutions": [
{ "id": "d290f1ee-6c54-4b01-90e6-d701748f0851" }
]
}
}The created record comes back at result.data.dataSource; keep its id. Listing ids in documentSolutions attaches the Data Source to those solutions in the same call. A solution that can't be found is skipped rather than failing the request, so compare the returned documentSolutions with what you sent.
Call POST /documents/datasource/{dataSourceId}/data/load to check the Data Source works and to see the object and field names your template can use. It doesn't consume a Storage file, so you can call it as often as you like before generating.
POST https://api.doctavian.com/v1/documents/datasource/3f2504e0-4f89-41d3-9a0c-0305e82c3301/data/load
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"maxItems": 10
}{
"result": {
"data": {
"dataSourceData": {
"data": {
"Customer": [
{ "Name": "Acme Logistics Group", "AccountId": "0001008213" }
]
}
},
"truncated": false
}
}
}maxItems keeps only the first n entries of every array; truncated is true when that cut something short.404 DATA_SOURCE_DATA_NOT_FOUND means the Data Source exists but its file is gone — typically because a document has already been generated from it.400 CONNECTOR_REQUIRED or CONNECTOR_RECONNECT_REQUIRED means the file is on OneDrive or Google Drive and the caller's account for it is not connected, or must be reconnected. Fix it in the portal under Self-service → Connectors.If you didn't attach it on create, link it now. If either id doesn't exist, the call fails and nothing changes.
POST https://api.doctavian.com/v1/documents/solution/d290f1ee-6c54-4b01-90e6-d701748f0851/datasource/3f2504e0-4f89-41d3-9a0c-0305e82c3301/add
Authorization: Bearer <token>
x-api-key: <api-key>Detach it with DELETE /documents/solution/{documentSolutionId}/datasource/{dataSourceId}/remove. Generate from it by passing its id as dataSourceId on a Document Request — see Generate Document, Part 2.
Before each run, upload a fresh file (Step 2), then point the Data Source at it, then generate.
PUT https://api.doctavian.com/v1/documents/datasource/3f2504e0-4f89-41d3-9a0c-0305e82c3301/update
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"dataSource": {
"name": "Q3 Sales Report Data",
"description": "Account records used for quarterly reports.",
"urn": "b9f629a1-88e6-484b-97ff-d0a431ba660d",
"loadMethod": "Storage",
"documentSolutions": [
{ "id": "d290f1ee-6c54-4b01-90e6-d701748f0851" }
]
}
}Send the whole record, not just the new
urn: update is a full replacement, and anything you leave out is cleared. To move a Data Source between folders, usePUT /documents/datasource/{dataSourceId}/moveinstead.
If you skip the refresh, the next Document Request on this Data Source is still created, then ends in status Failed with FILE_MISSING_FROM_STORAGE.
To add extra or computed values, include a variables array on the Data Source (or in data.variables on a one-call generate). See Variables for how each type is applied.
"variables": [
{ "name": "Invoice.GeneratedOn", "value": "{!$now()}", "type": "fieldExpression" },
{ "name": "companyName", "value": "Contoso Ltd", "type": "global" }
]
GET /documents/datasource/list and GET /documents/datasource/{dataSourceId}/get — read them backDELETE /documents/datasource/{dataSourceId}/delete — delete one; it is also removed from every solution it was attached toPUT /documents/datasource/{dataSourceId}/move — file it in a folder created with POST /common/folder/create and folderEntityId: "DATA_SOURCES"See the API Reference for every Data Source operation, field and error code.