Documents Service
The Documents Service handles document retrieval, upload, update, and deletion via the REST interface.
All authenticated endpoints require a Bearer token in the Authorization header.
Endpoint Reference — REST V1
| Method | Path | Auth | Body | Description |
|---|---|---|---|---|
| GET | /api/public/v1/documents/ping | No | — | Connectivity check |
| GET | /api/public/v1/documents/health | No | — | Service health status |
| GET | /api/public/v1/documents/version | No | — | Service version string |
| GET | /api/public/v1/documents/categories?usage={n} | Yes | — | Returns document categories valid for the given entity type (see below) |
| POST | /api/public/v1/documents/get-documents | Yes | JSON | Returns document version metadata for matching documents (no file bytes) |
| GET | /api/public/v1/documents/get-original-document/{versionGuid} | Yes | — | Returns a DownloadUrl for the raw file of a specific document version |
| GET | /api/public/v1/documents/stream/{versionGuid} | Yes | — | Streams the raw file bytes directly to the caller — no disk write, no URL redirect. Preferred for browser viewing or downloading. |
| POST | /api/public/v1/documents/get-original-document | Yes | JSON | Returns a DownloadUrl for the most recently changed file matching the request |
| POST | /api/public/v1/documents/get-all-documents | Yes | JSON | Merges all matching documents into a single PDF and returns a DownloadUrl |
| POST | /api/public/v1/documents/upload | Yes | multipart/form-data | Uploads a new document and links it to a parent entity |
| POST | /api/public/v1/documents/update-metadata | Yes | multipart/form-data | Saves a new version of an existing document and updates its metadata |
Document Categories
Categories are loaded from System_DocumentCategoryTypes and are filtered by entity type
using the usage query parameter. Always pass the usage value that matches the context
in which the upload button appears — the correct value is always known from screen context.
| usage value | Entity type |
|---|---|
1 | Shipment |
2 | Claim |
3 | Client |
4 | Carrier |
Example: GET /api/public/v1/documents/categories?usage=1 returns the categories valid for a Shipment.
Search Fields — get-documents, get-original-document (POST), get-all-documents
These three POST endpoints share the same search field set. Each uses a typed request object
(GetDocumentsRequest, GetOriginalDocumentRequest, GetAllDocumentsRequest)
but the available search fields are the same. Supply exactly one search strategy per request.
| Field | Type | Priority | Notes |
|---|---|---|---|
DMLoadNumber | string | 1 — highest | Most direct identifier. Wins over all other fields if present. |
InvoiceNumber | string | 2 | Used if DMLoadNumber is absent. |
InvoiceFromDate + InvoiceToDate + ClientReference | DateOnly? / string | 3 | All three are required together for a date range search. |
DocumentID | string (GUID) | 4 — lowest | Returns results for a single specific document. |
If no usable search criteria are supplied, the service returns HTTP 400 InvalidRequest.
File Retrieval — DownloadUrl Response Pattern
The three file-returning endpoints (get-all-documents, get-original-document POST,
and get-original-document/{versionGuid} GET) do not stream file bytes directly.
Instead they:
- Retrieve or generate the file
- Write it to the server's configured document storage folder (
RootPathDocumentsinSystem_Properties) - Return a JSON response whose
DownloadUrlis a publicly accessible HTTPS URL
Example Response
{
"Status": "OK",
"Message": "Document ready for download.",
"DownloadUrl": "https://easyfreight.nebulasuite.net/documents/DMLOAD_4363968_042226101901828.pdf"
}
File Naming Pattern
| Search type | File name prefix |
|---|---|
| DM Load Number | DMLOAD_{number}_{timestamp} |
| Invoice Number | INVOICE_{number}_{timestamp} |
| Version GUID (GET endpoint) | {documentName}_{versionGuid}_{timestamp} |
The timestamp suffix ensures uniqueness when the same request is made multiple times in rapid succession. Filenames are sanitized — any character that is not alphanumeric, a hyphen, or an underscore is replaced with an underscore.
RootPathDocuments UNC path in System_Properties. If write access is missing, the endpoint returns
an Error status with the attempted path in the message. The DownloadUrl always uses the
public-facing URL from RootPathOnlineDocuments — the UNC path is only used internally for the write.
get-all-documents — Merge Behaviour
Retrieves all documents matching the request, converts non-PDF files to PDF, merges them in category order,
and returns a single PDF via DownloadUrl.
Merge sort order
| Priority | Category |
|---|---|
| 1 | Bill of Lading / BOL |
| 2 | Shipping Label |
| 3 | Manifest |
| 4 | Weight and Measure |
| 5 | Proof of Delivery / POD |
| 6 | Invoice |
| 999 | All other documents |
Each page is stamped with the DM Load Number it belongs to — useful when a merged PDF spans multiple loads (e.g. when searching by invoice number that covers several shipments).
If a file cannot be converted to PDF (unsupported format, corrupt file, etc.), a placeholder page is inserted
in its place in the merged output noting the unconvertible file. The original file is always preserved and
remains downloadable via get-original-document.
Upload a Document
Accepts multipart/form-data. Uploads a new document and links it to any supported parent entity.
Parent entity linking — supply ONE of:
| Field | Required | Notes |
|---|---|---|
parentGuid | One of these two | GUID of any parent entity — shipment, carrier, client, claim, etc. Takes priority over dmLoadNumber if both are supplied. |
dmLoadNumber | One of these two | DM load number of a shipment. Resolved to the shipment's GUID internally. Use this as a convenience when you have the load number but not the GUID. |
Document fields
| Field | Required | Notes |
|---|---|---|
file | Yes | The file to upload. Extension is read from the filename. |
name | Yes | Document name stored in the system. |
categoryType | Yes | Must match a value in System_DocumentCategoryTypes. Use the /categories endpoint to get valid values for the current entity type. |
subject | No | Auto-generated if omitted. |
description | No | Auto-generated if omitted. |
Success Response (200)
{ "Status": "OK", "DocumentGuid": "{new-document-guid}", "VersionGuid": "{new-version-guid}" }
Use VersionGuid to immediately stream or view the uploaded file via /api/public/v1/documents/stream/{versionGuid} without a separate lookup.
Error Responses
- 400 — Missing file, missing required fields, invalid GUID format, or unrecognised category
- 404 — No shipment found for the provided
dmLoadNumber - 500 — Unexpected error during save
Update a Document
Accepts multipart/form-data. A new file is required — updating always creates
a new version. The document's parent entity link is not changed.
| Field | Required | Notes |
|---|---|---|
file | Yes | New version of the file. |
documentId | Yes | GUID of the document to update. Must be a valid non-empty GUID. |
categoryType | Yes | Must match a value in System_DocumentCategoryTypes. |
name | No | Updated document name. |
subject | No | Auto-generated if omitted. |
description | No | Auto-generated if omitted. |
Success Response (200)
{ "Status": "OK", "Message": "Document updated successfully." }
Error Responses
- 400 — Missing file, missing or invalid
documentId, or unrecognised category - 404 — No document found for the provided
documentId - 500 — Unexpected error during save
Stream a Document — stream/{versionGuid}
Streams the raw file bytes for a specific document version directly to the caller. No file is written to disk — bytes are fetched from the database and returned in a single response. The browser will display the file inline (e.g. PDF in a new tab) or prompt a download for unsupported formats.
When to use this vs. get-original-document
| Endpoint | Returns | Best for |
|---|---|---|
stream/{versionGuid} | File bytes directly | Opening in a browser tab, embedding in an iframe, or downloading. Faster — no disk write involved. |
get-original-document/{versionGuid} | JSON with DownloadUrl | When you need a shareable public URL rather than the file bytes directly. |
Tip: Use VersionGuid from upload
The upload endpoint now returns both DocumentGuid and VersionGuid on success.
You can pass the VersionGuid directly to this endpoint immediately after upload
without needing a separate get-documents lookup.
Error Responses
- 404 — No active version found for the provided GUID
- 503 — Stream endpoint not configured in System_JobEndpoints
Authentication
All authenticated endpoints require a Bearer token in the HTTP Authorization header:
Authorization: Bearer <your-token>
See the Authentication Guide for details on obtaining and using tokens.