Skip to content
MantraWorx
Developers › Documents API

Developers

Documents API

List, read, create and update documents, and avoid overwriting a newer edit.

On this page

The documents API reads and writes documents in the Documentation module. It follows the same permissions as the web app, on the docs.documents key.

Endpoints#

EndpointNeedsPurpose
GET /api/documentation/documentsviewList documents.
GET /api/documentation/documents/:idviewRead one document.
POST /api/documentation/documentswriteCreate a document.
PUT /api/documentation/documents/:idwriteUpdate a document.
DELETE /api/documentation/documents/:idwriteDelete a document.
GET /api/documentation/documents/:id/versionsviewList saved versions.
POST /api/documentation/documents/:id/versions/:versionNumber/restorewriteRestore an earlier version.
GET /api/documentation/foldersviewList folders.

You only see documents you have access to, even with view.

List documents#

GET /api/documentation/documents

QueryMeaning
page, limitPaging.
statusdraft, review, published or archived.
visibilityprivate, department, project or public.
searchWords to find in titles and text.
tagsComma-separated tags.
departmentIdOnly one department.
sortBy, sortOrderOrder of the results (asc or desc).
includeContenttrue to include each document's body. Off by default.
bash
curl "https://<your-host>/api/documentation/documents?status=published&limit=20" \
  -H "Authorization: Bearer $TOKEN"

The response has documents and pagination. Each document is shown here with its main fields.

json
{
  "documents": [
    {
      "id": "…",
      "title": "Onboarding checklist",
      "content_type": "markdown",
      "status": "published",
      "visibility": "department",
      "tags": ["hr"],
      "updated_at": "2026-10-01T09:30:00.000Z"
    }
  ],
  "pagination": { "currentPage": 1, "hasMore": false }
}

Create a document#

POST /api/documentation/documents needs write. Only title is required.

FieldTypeNotes
titlestringRequired.
contentstringThe body.
content_typestringhtml, markdown or plain.
summarystringShort description.
statusstringdraft, review, published or archived.
visibilitystringprivate, department, project or public.
folder_idstringPut the document in a folder.
tagsstring arrayLabels.
bash
curl -X POST https://<your-host>/api/documentation/documents \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Onboarding checklist", "content": "## Day one", "content_type": "markdown", "status": "draft"}'

Update without overwriting someone else#

PUT /api/documentation/documents/:id accepts the same fields. To avoid replacing a newer edit, also send baseUpdatedAt: the updated_at you last read.

js
await fetch(`https://<your-host>/api/documentation/documents/${id}`, {
  method: "PUT",
  headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
  body: JSON.stringify({ title: "New title", baseUpdatedAt: doc.updated_at }),
});

If someone saved a newer version first, the API answers 409 with the code DOCUMENT_CONFLICT and the current updated_at. Reload the document, merge the change and try again.

Note: A 403 means your role does not hold the level the call needs. See Roles and permissions.

Need more help?

Can’t find what you need? Talk to the team.

Contact support