Document Service

Back

Note: The sales order model has been replaced by the generic Document model. All endpoints are now under /api/v1/Documents. The document approach supports multiple document types (sales orders, credit notes, quotes, etc.) through the DocumentTypeId field.

Overview

Documents represent transactional records — sales orders, credit notes, quotes, and any other document type defined in ref.DocumentType.

Documents provide a consistent reference for:

Soft delete is supported — deleted documents have IsDeleted = true and a DeletedAt timestamp rather than being physically removed.

All document operations are tenant-aware.


Database tables


Endpoints

Back to Sales

GET

/api/v1/Documents

Returns a paginated, filterable list of documents.

Query parameters (pagination):

Query parameters (filters):

Query parameters (date window):

Example — all documents for entity 5 in April 2026:

GET /api/v1/Documents?entityId=5&dateFrom=2026-04-01&dateTo=2026-04-30&dateProperty=orderdate&pageSize=0

Response:

Authorization:


GET

/api/v1/Documents/{id}

Returns a single document by its numeric identifier, including all lines.

Route parameters:

Behavior:

Response:

Authorization:


GET

/api/v1/Documents/ref/{orderNumber}/entity/{entityId}

Returns a document matching both order reference and entity ID.

Route parameters:

Behavior:

Response:

Authorization:


GET

/api/v1/Documents/{id}/files

Returns a paginated list of file attachments linked to a document.

Route parameters:

Query parameters: see FileFilterRequest (standard pagination + search)

Response:

Authorization:


POST

/api/v1/Documents

Creates a new document.

Request body (DocumentModel):

Behavior:

Response:

Authorization:


POST

/api/v1/Documents/{id}/convert

Converts or clones an existing document into a different document type.

Route parameters:

Query parameters:

Behavior:

Response:

Authorization:


POST

/api/v1/Documents/{id}/actions/{actionCode}

Performs a lifecycle action on a document (e.g. BEGIN_PROCESSING, CANCEL, EMAIL_DOCUMENT_SUMMARY). This is the only way a document's status changes outside of creation/conversion — the caller names the action, not the destination status, and the server resolves the actual result (which may depend on live stock levels or tenant feature flags). See DocumentModel.DocumentActionState.AllowedActions for what's currently invokable on a given document.

Route parameters:

Behavior:

Response:

Authorization:


POST

/api/v1/Documents/PurchaseOrders

Generates Purchase Orders from Sales Orders that have lines with insufficient stock.

Behavior:

Response:

Authorization:


POST

/api/v1/Documents/{documentId}/files/assign

Assigns one or more existing files to a document.

Route parameters:

Request body (FileIdsRequest):

Response:

Authorization:


PUT

/api/v1/Documents/{id}

Updates an existing document.

Route parameters:

Request body (DocumentModel):

Behavior:

Response:

Authorization:


DELETE

/api/v1/Documents/{id}

Soft-deletes a document.

Route parameters:

Behavior:

Response:

Authorization:


DELETE

/api/v1/Documents/{documentId}/files/remove

Removes one or more file associations from a document (does not delete the file itself).

Route parameters:

Request body (FileIdsRequest):

Response:

Authorization:


Models

DocumentModel

Represents a document (sales order, credit note, quote, etc.).

Fields:

Validation:


DocumentLineModel

Represents a single line item within a document.

Fields:

Validation:


GeneratePurchaseOrdersResult

Returned by POST /api/v1/Documents/PurchaseOrders.

Fields:


DocumentAddressSnapshotModel

An immutable copy of an address stamped at the time the document was created (via cart convert or manual creation).

Fields:


Notes