Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/tukit/llms.txt

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

Role management in TuKit is scoped exclusively to admin users. This endpoint completely replaces the roles array on a target user’s document using a MongoDB $set operation — it does not append to or merge with the existing roles. The caller must identify both the target user (userId) and themselves as the acting administrator (adminId). The controller verifies that the adminId account carries the role { name: "admin", value: "2" } before proceeding; if it does not, the request is rejected regardless of the JWT being otherwise valid. POST /api/user/update-role/:userId/:adminId

Authentication

token-access
string
required
A valid JWT obtained from the Login endpoint.

Path Parameters

userId
string
required
The MongoDB ObjectId of the user whose roles are being updated.
adminId
string
required
The MongoDB ObjectId of the requesting administrator. This account must have a role of { name: "admin", value: "2" } or the request will be rejected.

Request Body

roles
array
required
An array of role objects to set on the target user. Each object must contain a name and a value key. The existing roles array is fully replaced by this value.Role reference:
namevalueDescription
Usuario"1"Standard user
admin"2"Administrator
Example value:
[
  { "name": "admin", "value": "2" }
]

Response

200 — Success

msj
string
Human-readable confirmation that the roles were updated ("Rol de usuario actualizado correctamente").
status
boolean
Always true on success.
updatingRoles
object
The raw result object returned by Mongoose’s updateOne(). Contains MongoDB write-result metadata.

Error Responses

StatusCause
404No user document found for the provided userId.
404No user document found for the provided adminId.
203The adminId account does not have a role of { name: "admin", value: "2" }.
500Unexpected server or database error.
This endpoint performs a full replacement of the roles array, not a partial merge. Sending [{ "name": "admin", "value": "2" }] will remove any other roles previously assigned to the target user.

Example

curl -X POST https://your-tukit-api.com/api/user/update-role/64f1a2b3c4d5e6f7a8b9c0d1/64f9z9z9z9z9z9z9z9z9z9z9 \
  -H "Content-Type: application/json" \
  -H "token-access: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -d '{
    "roles": [
      { "name": "admin", "value": "2" }
    ]
  }'
Success response:
{
  "msj": "Rol de usuario actualizado correctamente",
  "status": true,
  "updatingRoles": {
    "acknowledged": true,
    "matchedCount": 1,
    "modifiedCount": 1
  }
}
Error — adminId lacks admin role:
{
  "msj": "No tienes permisos para esta función",
  "status": false
}
Error — target user not found:
{
  "msj": "Usuario no encontrado",
  "status": false
}

Build docs developers (and LLMs) love