Manage Data

Rest API

Complete REST API Reference for dnax Framework.

All API requests follow a single pattern:

POST /api/:tenant_id/:collection/:action
ParameterDescription
tenant_idTenant identifier
collectionCollection name
actionAction to perform

Content Types

TypeDescription
application/jsonJSON body
multipart/form-dataFile uploads
application/x-www-form-urlencodedForm data

Authentication (JWT)

For routes that require a logged-in user, send the token from login in the Authorization header:

Authorization: Bearer <jwt_token>

The framework verifies the JWT before the request reaches collection handlers. If the header is present and the token is invalid or expired, the response is 401. If you omit the header, no token is attached; use collection api.access rules to allow or deny actions and inspect claims via token.decoded (see Access control).

After login, the JSON body includes "token" — use that value as the Bearer token for subsequent POST /api/... calls.

Query Parameters

ParameterTypeDescription
cleanDeepbooleanRemove null, undefined, empty arrays
useCachebooleanEnable caching

Actions

find

Retrieve multiple documents.

POST /api/:tenant_id/:collection/find
Content-Type: application/json

{
  "params": {
    "$match": { "status": "active" },
    "$limit": 20,
    "$skip": 0,
    "$sort": { "createdAt": -1 }
  }
}

Response:

[{ "_id": "...", "name": "John", ... }, ...]

Body parameters:

ParameterTypeRequiredDescription
paramsFindOptionsNoQuery options (see below)

params options:

ParameterTypeDescription
$matchobjectFilter conditions
$limitnumberLimit results
$skipnumberSkip results
$sortobjectSort order
$projectobjectSelect fields
$includeArray<string | LookupOptions>Populate relationship fields via $lookup

findOne

Retrieve a single document by ID.

POST /api/:tenant_id/:collection/findOne
Content-Type: application/json

{
  "id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "params": {}
}

Body parameters:

ParameterTypeRequiredDescription
idstringYesDocument _id
paramsfindOneOptionsNoQuery options ($include)

insertOne

Insert a single document.

POST /api/:tenant_id/:collection/insertOne
Content-Type: application/json

{
  "data": {
    "name": "John Doe",
    "email": "[email protected]"
  }
}

Body parameters:

ParameterTypeRequiredDescription
dataobjectYesDocument to insert

insertMany

Insert multiple documents.

POST /api/:tenant_id/:collection/insertMany
Content-Type: application/json

{
  "data": [
    { "name": "Alice" },
    { "name": "Bob" }
  ]
}

Body parameters:

ParameterTypeRequiredDescription
dataobject[]YesArray of documents to insert

updateOne

Update a single document.

POST /api/:tenant_id/:collection/updateOne
Content-Type: application/json

{
  "id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "update": {
    "$set": { "name": "Jane Doe" }
  }
}

Body parameters:

ParameterTypeRequiredDescription
idstringYesDocument _id (alias: _id)
updateobjectYesUpdate document with operators ($set, $unset, ...)

updateMany

Update multiple documents.

POST /api/:tenant_id/:collection/updateMany
Content-Type: application/json

{
  "ids": ["64f1...", "64f2..."],
  "update": {
    "$set": { "status": "archived" }
  }
}

Body parameters:

ParameterTypeRequiredDescription
idsstring[]YesDocument _ids (alias: _ids)
updateobjectYesUpdate document with operators ($set, $unset, ...)

deleteOne

Delete a single document.

POST /api/:tenant_id/:collection/deleteOne
Content-Type: application/json

{
  "id": "64f1a2b3c4d5e6f7a8b9c0d1"
}

Body parameters:

ParameterTypeRequiredDescription
idstringYesDocument _id (alias: _id)

deleteMany

Delete multiple documents.

POST /api/:tenant_id/:collection/deleteMany
Content-Type: application/json

{
  "ids": ["64f1...", "64f2..."]
}

Body parameters:

ParameterTypeRequiredDescription
idsstring[]YesDocument _ids (alias: _ids)

aggregate

Run an aggregation pipeline.

POST /api/:tenant_id/:collection/aggregate
Content-Type: application/json

{
  "pipeline": [
    { "$match": { "status": "active" } },
    { "$group": { "_id": "$category", "total": { "$sum": 1 } } }
  ]
}

Body parameters:

ParameterTypeRequiredDescription
pipelineobject[]YesMongoDB aggregation pipeline stages

Update Operators

OperatorDescription
$setSet field values
$unsetRemove fields
$incIncrement value
$mulMultiply value
$pushAdd to array
$pullRemove from array
$addToSetAdd to set (unique)
Copyright © 2026