Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juescoryisus/QualityDocD/llms.txt

Use this file to discover all available pages before exploring further.

The documents resource is the core of QualityDocD’s Node.js API. Each document record is a container that tracks its own version history — every document carries a currentVersion field showing the version with status="current", or null if none has been approved yet. All endpoints in this group require a valid Bearer token and MODULE_2 access (any role from VIEWER and above), with the exception of version creation and approval, which require MODULE_1 (OPERATOR and above). Company scoping is enforced automatically: regular users only see documents that belong to their own company. Users with the SUPER_ADMIN role bypass this restriction and can retrieve documents across all companies.

GET /documents

Returns an array of all documents visible to the authenticated user, each with its currentVersion nested inline. Auth: Bearer token
Module access: MODULE_2 — VIEWER, COMMENTER, CONTRIBUTOR, OPERATOR, COMPANY_ADMIN, SUPER_ADMIN
curl -X GET https://api.qualitydocd.example/api/documents \
  -H "Authorization: Bearer <token>"

Response

id
integer
Unique identifier for the document.
companyId
integer
ID of the company that owns this document.
title
string
Human-readable document title.
format
string
File format of the document (e.g. pdf). Defaults to "pdf".
createdBy
integer
User ID of the user who created the document.
createdAt
string (ISO 8601)
Timestamp of when the document record was created.
currentVersion
object | null
The version with status="current", or null if the document has not yet been approved.
Example response
[
  {
    "id": 1,
    "companyId": 3,
    "title": "Manual de Calidad ISO 9001",
    "format": "pdf",
    "createdBy": 7,
    "createdAt": "2024-11-10T08:23:14.000Z",
    "currentVersion": {
      "id": 4,
      "documentId": 1,
      "companyId": 3,
      "majorVersion": 2,
      "minorVersion": 0,
      "versionNumber": "2.0",
      "status": "current",
      "contentUrl": "https://storage.example.com/docs/manual-v2.pdf",
      "contentText": "Política de calidad de la organización...",
      "createdBy": 7,
      "approvedBy": 9,
      "approvedAt": "2024-12-01T15:00:00.000Z",
      "createdAt": "2024-11-10T08:23:14.000Z"
    }
  }
]

POST /documents

Creates a new document record along with an initial version 1.0 with status="draft". The newly created document is returned with its initial version nested in currentVersion. Auth: Bearer token
Module access: MODULE_2 — VIEWER, COMMENTER, CONTRIBUTOR, OPERATOR, COMPANY_ADMIN, SUPER_ADMIN
curl -X POST https://api.qualitydocd.example/api/documents \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Manual de Calidad ISO 9001",
    "format": "pdf",
    "contentText": "Política de calidad de la organización"
  }'

Request body

title
string
required
The display title of the document. Must be at least 1 character.
format
string
File format of the document. Defaults to "pdf" if omitted.
contentUrl
string | null
Optional URL to the document file (e.g. a cloud storage link). May be null.
contentText
string
required
Plain-text content of the document. Used for full-text search indexing when the version is approved.
keywords
string[]
Optional array of keyword strings to associate with the document. Defaults to an empty array if omitted.

Response 201

Returns the created document object with the initial 1.0 draft version embedded in currentVersion.
{
  "id": 12,
  "companyId": 3,
  "title": "Manual de Calidad ISO 9001",
  "format": "pdf",
  "createdBy": 7,
  "createdAt": "2025-01-15T09:00:00.000Z",
  "currentVersion": {
    "id": 18,
    "documentId": 12,
    "companyId": 3,
    "majorVersion": 1,
    "minorVersion": 0,
    "versionNumber": "1.0",
    "status": "draft",
    "contentUrl": null,
    "contentText": "Política de calidad de la organización",
    "createdBy": 7,
    "approvedBy": null,
    "approvedAt": null,
    "createdAt": "2025-01-15T09:00:00.000Z"
  }
}
The initial version is always created as 1.0 with status="draft". To make it visible as the active document version, it must be approved via POST /documents/:id/versions/:versionId/approve.

GET /documents/:id

Retrieves a single document by ID with its currentVersion nested. Returns 404 if the document does not exist or belongs to a different company (for non-SUPER_ADMIN users). Auth: Bearer token
Module access: MODULE_2

Path parameters

id
integer
required
The ID of the document to retrieve.
curl -X GET https://api.qualitydocd.example/api/documents/12 \
  -H "Authorization: Bearer <token>"

Response 200

Returns a single document object in the same shape as items from GET /documents.
{
  "id": 12,
  "companyId": 3,
  "title": "Manual de Calidad ISO 9001",
  "format": "pdf",
  "createdBy": 7,
  "createdAt": "2025-01-15T09:00:00.000Z",
  "currentVersion": {
    "id": 18,
    "documentId": 12,
    "companyId": 3,
    "majorVersion": 1,
    "minorVersion": 0,
    "versionNumber": "1.0",
    "status": "current",
    "contentUrl": "https://storage.example.com/docs/manual.pdf",
    "contentText": "Política de calidad de la organización",
    "createdBy": 7,
    "approvedBy": 9,
    "approvedAt": "2025-01-20T14:00:00.000Z",
    "createdAt": "2025-01-15T09:00:00.000Z"
  }
}

Response 404

{ "error": "Document not found" }

GET /documents/:id/history

Returns all versions of a document — including draft, current, and obsolete — sorted by insertion order. This endpoint is useful for audit trails, compliance review, and comparing content across version iterations. Auth: Bearer token
Module access: MODULE_2

Path parameters

id
integer
required
The ID of the document whose history to retrieve.
curl -X GET https://api.qualitydocd.example/api/documents/12/history \
  -H "Authorization: Bearer <token>"

Response 200

Returns an array of all version objects for the document, from earliest to most recent.
[
  {
    "id": 18,
    "documentId": 12,
    "companyId": 3,
    "majorVersion": 1,
    "minorVersion": 0,
    "versionNumber": "1.0",
    "status": "obsolete",
    "contentUrl": null,
    "contentText": "Política de calidad v1",
    "createdBy": 7,
    "approvedBy": 9,
    "approvedAt": "2025-01-20T14:00:00.000Z",
    "createdAt": "2025-01-15T09:00:00.000Z"
  },
  {
    "id": 22,
    "documentId": 12,
    "companyId": 3,
    "majorVersion": 2,
    "minorVersion": 0,
    "versionNumber": "2.0",
    "status": "current",
    "contentUrl": "https://storage.example.com/docs/manual-v2.pdf",
    "contentText": "Política de calidad v2 — revisada",
    "createdBy": 7,
    "approvedBy": 9,
    "approvedAt": "2025-03-05T10:30:00.000Z",
    "createdAt": "2025-02-20T11:00:00.000Z"
  }
]
If the document ID is not found or belongs to a different company, this endpoint returns 404 { "error": "Document not found" }.

Build docs developers (and LLMs) love