Documents

Data Source Create

POST
/documents/datasource/create

Creates a data source: a reusable, named definition of where a document solution gets its data at generation time. One data source can be attached to several document solutions, so pipelines that draw on the same underlying data share a single definition.

Only name and loadMethod are mandatory. loadMethod decides how urn is read, and whether query and variables apply at all — they are read only for GraphQL and ignored for the other three methods.

For Storage, the urn points at a file uploaded through documents-data-upload. Those files are removed once a generate request consumes them or after 24 hours, whichever comes first, so a data source does not hold a permanent copy of your data. The working pattern is to upload a fresh file and update the data source's urn before each generation run.

A data source can be attached to document solutions in the same call by listing their ids in documentSolutions. That linking is best-effort: a solution that cannot be found is skipped rather than failing the request, so compare the returned list with what you sent. Solutions can also be attached later with documents-solution-data-source-add.

Identifiers, ownership, folder and timestamps are all server-assigned and returned in the response; sending them has no effect.

Authorization

AuthorizationBearer <token>

JWT token to authenticate the request.

In: header

X-Api-Key<token>

API key, sent as a request header.

In: header

Request Body

application/json

The DataSourceModel payload to create. Server-managed fields (ids, timestamps, links, isDeleted) are ignored.

TypeScript Definitions

Use the request body type in TypeScript.

Body for creating a data source, following the standard request envelope: the resource under its own name alongside an optional externalContext.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/documents/datasource/create" \  -H "Content-Type: application/json" \  -d '{    "dataSource": {      "name": "Q3 Sales Report Data",      "description": "Account records used for quarterly reports.",      "urn": "a4f8c9d2-6b3e-4f1a-9c7d-2e5b8a1f4d6c",      "loadMethod": "Storage",      "documentSolutions": [        {          "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922"        }      ]    },    "externalContext": {      "id": "789"    }  }'
{  "result": {    "statusCode": 201,    "message": "Created",    "data": {      "dataSource": {        "id": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",        "subscriptionId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",        "ownerId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",        "lastModifiedUserId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",        "name": "Q3 Sales Report Data",        "description": "Account records used for quarterly reports.",        "urn": "a4f8c9d2-6b3e-4f1a-9c7d-2e5b8a1f4d6c",        "loadMethod": "Storage",        "createdDate": "2026-09-18T12:15:53.000Z",        "lastModifiedDate": "2026-09-18T12:15:53.000Z",        "ownerName": "Jane Doe",        "lastModifiedUserName": "Jane Doe",        "documentSolutions": [          {            "id": "6ccb8ca9-2952-4dbf-a4b0-4a48bdeb1922",            "name": "Quarterly Invoicing",            "description": "Invoice run for quarterly billing."          }        ]      }    }  },  "origin": "POST https://api.doctavian.com/v1/documents/datasource/create",  "dateTime": "2026-09-18T12:15:53.000Z",  "externalContext": {    "id": "789"  },  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "c5e1fb3463b3143eab0b81d366561834"}
{  "error": {    "statusCode": 400,    "message": "Name is required.",    "innerErrors": [      {        "code": "DATA_NAME_REQUIRED",        "message": "Name is required.",        "userMessage": "Give the data source a name before saving it."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/datasource/create",  "dateTime": "2026-09-18T10:22:41.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "c8b41f7d20e94a63915ce2d8074fb35a"}
{  "error": {    "statusCode": 401,    "message": "The request could not be authenticated.",    "innerErrors": [      {        "code": "UNAUTHORIZED",        "message": "The request could not be authenticated.",        "userMessage": "Your session has expired or is invalid. Please sign in again."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/datasource/create",  "dateTime": "2026-09-18T10:22:41.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "c8b41f7d20e94a63915ce2d8074fb35a"}
{  "error": {    "statusCode": 403,    "message": "The caller is not authorized to perform this operation.",    "innerErrors": [      {        "code": "AUTHORIZATION_ERROR",        "message": "The caller is not authorized to perform this operation.",        "userMessage": "You do not have permission to do this. Contact your administrator."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/datasource/create",  "dateTime": "2026-09-18T10:22:41.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "c8b41f7d20e94a63915ce2d8074fb35a"}
{  "error": {    "statusCode": 500,    "message": "The data source could not be created.",    "innerErrors": [      {        "code": "CREATE_DATA_SOURCE_ERROR",        "message": "The data source could not be created.",        "userMessage": "Something went wrong. Please try again or contact support."      }    ]  },  "origin": "POST https://api.doctavian.com/v1/documents/datasource/create",  "dateTime": "2026-09-18T10:22:41.000Z",  "userId": "1a2b3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d",  "operationId": "c8b41f7d20e94a63915ce2d8074fb35a"}