QualityDocD documents use semantic versioning with aDocumentation 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.
major.minor format. Each version lives in one of three states: draft (newly created, not yet active), current (the single active version at any moment), or obsolete (superseded by a newer approval). Creating a new version always yields a draft; promoting it to current is a separate approval step that automatically retires the previous current version, tokenizes the document content into the PostgreSQL search index, and asynchronously pushes metadata to MongoDB.
Both endpoints in this group require MODULE_1 access — meaning OPERATOR, COMPANY_ADMIN, or SUPER_ADMIN roles.
POST /documents/:id/versions
Creates a new draft version for an existing document. The version number is calculated automatically from the document’s existing version history. Only users with MODULE_1 access may create new versions. Auth: Bearer tokenModule access: MODULE_1 — OPERATOR, COMPANY_ADMIN, SUPER_ADMIN
Path parameters
The ID of the document to add a new version to.
Request body
Plain-text content for this version. Stored in the database and used for search indexing when the version is approved.
Optional URL to the document file (e.g. a cloud storage link). May be omitted or
null.Controls whether the major or minor version component is incremented. Defaults to
false.false— bumps the minor version:1.3 → 1.4true— bumps the major version and resets minor to 0:1.3 → 2.0
Version numbering logic
The API inspects all existing versions for the document to determine the next version number:- Finds the highest
majorVersionacross all existing versions. - Among all versions sharing that major number, finds the highest
minorVersion. - If
bumpMajoristrue, setsnewMajor = latestMajor + 1andnewMinor = 0. - Otherwise, sets
newMajor = latestMajorandnewMinor = latestMinor + 1.
Response 201
Returns the newly created version object. Its status is always "draft".
Unique identifier for this version.
ID of the parent document.
Company the version belongs to.
Major component of the version number.
Minor component of the version number.
Human-readable version string, e.g.
"2.0" or "1.4".Always
"draft" for a freshly created version.The URL provided in the request body, or
null.The plain-text content provided in the request body.
User ID of the user who created this version.
Always
null for a freshly created draft version.Always
null for a freshly created draft version.Timestamp of when this version record was created.
Error responses
| Status | Body | Cause |
|---|---|---|
400 | { "error": "..." } | Request body failed validation |
404 | { "error": "Document not found" } | No document with that ID exists in the user’s company |
POST /documents/:id/versions/:versionId/approve
Promotes a draft version to"current", retiring any previously current version as "obsolete". This endpoint performs four distinct actions in sequence and then triggers an asynchronous MongoDB sync before returning.
Auth: Bearer tokenModule access: MODULE_1 with write flag — OPERATOR, COMPANY_ADMIN, SUPER_ADMIN
Path parameters
The ID of the parent document.
The ID of the version to approve. Must belong to the document specified by
id and to the authenticated user’s company.Approval flow
Retire existing current version
All versions of this document that currently have
status="current" are updated to status="obsolete". This ensures only one version is ever current at a time.Promote the target version
The target version is updated:
status is set to "current", approvedBy is set to the authenticated user’s ID, and approvedAt is set to the current UTC timestamp.Tokenize and index in PostgreSQL
The version’s
versionNumber is tokenized into titleTokens, and the version’s contentText is tokenized into bodyTokens. Both are deduplicated and merged into a combined tokens array. If no existing search_index row exists for this version, these arrays are inserted into the search_index table, enabling fast fallback full-text search if MongoDB is unavailable. If a row already exists, the index is left unchanged.MongoDB sync fields
When the async upsert runs, the following fields are written to thedocument_metadata collection:
| Field | Value |
|---|---|
documentId | Parent document ID |
versionId | Approved version ID |
companyId | Company ID |
title | Document title |
format | Document format (e.g. "pdf") |
version | Version number string (e.g. "2.0") |
status | Always "Approved" |
contentText | Plain-text content of the version |
tags | Array of lowercase words derived from the document title |
approvedAt | UTC timestamp of approval |
MongoDB sync failures are caught silently and logged as warnings. The approval response is always returned once the PostgreSQL steps complete, regardless of whether the MongoDB upsert succeeds.
Response 200
Returns the updated version object reflecting its new approved state.
Version ID.
Parent document ID.
Company ID.
Major version component.
Minor version component.
Human-readable version string.
Always
"current" after a successful approval.URL to the document file, if one was provided.
Plain-text content of the version.
User ID who created this version.
User ID who approved this version.
Timestamp of approval.
Error responses
| Status | Body | Cause |
|---|---|---|
403 | { "error": "Acceso denegado al MODULE_1" } | User lacks MODULE_1 write access |
404 | { "error": "Version not found" } | No version with that ID exists for the given document in the user’s company |