Skip to main content

List permissions

GET /api/permisos Returns a paginated list of permission records joined with profile and module names. Results are ordered by id ascending with a fixed page size of 5 records.

Query parameters

page
number
default:"1"
Page number to retrieve. Defaults to 1.

Response

success
boolean
required
true when the query completes without error.
data
object[]
required
Array of permission records for the requested page.
totalPages
number
required
Total number of pages calculated as ceil(totalRows / 5). Returns 1 when the table is empty.

Error response

500
{
  "statusCode": 500,
  "message": "Error al consultar permisos"
}

Examples

curl --request GET \
  --url 'https://your-domain.com/api/permisos?page=1' \
  --cookie 'auth_token=<your-jwt>'

Success response

200
{
  "success": true,
  "data": [
    {
      "id": 1,
      "idPerfil": 2,
      "idModulo": 3,
      "nombrePerfil": "Supervisor",
      "nombreModulo": "Usuario",
      "bitAgregar": false,
      "bitEditar": true,
      "bitConsulta": true,
      "bitEliminar": false,
      "bitDetalle": true
    }
  ],
  "totalPages": 4
}

Create permission

POST /api/permisos Creates a single permission record linking a profile to a module with specific action flags.

Request body

idPerfil
number
required
ID of the profile to assign permissions to.
idModulo
number
required
ID of the module the permissions apply to.
bitAgregar
boolean
default:"false"
Grant create access.
bitEditar
boolean
default:"false"
Grant edit access.
bitConsulta
boolean
default:"false"
Grant read/list access.
bitEliminar
boolean
default:"false"
Grant delete access.
bitDetalle
boolean
default:"false"
Grant detail-view access.

Response

success
boolean
required
true when the record is inserted successfully.
data
object
required
The newly created permisos_perfil row as returned by the database RETURNING clause.

Error responses

StatusMessageCause
400Perfil y Módulo son obligatoriosidPerfil or idModulo is missing from the request body.

Examples

curl --request POST \
  --url https://your-domain.com/api/permisos \
  --header 'Content-Type: application/json' \
  --cookie 'auth_token=<your-jwt>' \
  --data '{
    "idPerfil": 2,
    "idModulo": 3,
    "bitAgregar": false,
    "bitEditar": true,
    "bitConsulta": true,
    "bitEliminar": false,
    "bitDetalle": true
  }'

Success response

200
{
  "success": true,
  "data": {
    "id": 42,
    "idPerfil": 2,
    "idModulo": 3,
    "bitAgregar": false,
    "bitEditar": true,
    "bitConsulta": true,
    "bitEliminar": false,
    "bitDetalle": true
  }
}

Update permission

PUT /api/permisos/:id Replaces all fields on an existing permission record. You must supply the full set of fields — any boolean omitted is coerced to false.

Path parameters

id
number
required
Primary key of the permisos_perfil row to update.

Request body

idPerfil
number
required
ID of the profile.
idModulo
number
required
ID of the module.
bitAgregar
boolean
Grant create access.
bitEditar
boolean
Grant edit access.
bitConsulta
boolean
Grant read/list access.
bitEliminar
boolean
Grant delete access.
bitDetalle
boolean
Grant detail-view access.

Response

success
boolean
required
true when the update completes.
data
object
required
The updated permisos_perfil row as returned by the database RETURNING clause.

Examples

curl --request PUT \
  --url https://your-domain.com/api/permisos/42 \
  --header 'Content-Type: application/json' \
  --cookie 'auth_token=<your-jwt>' \
  --data '{
    "idPerfil": 2,
    "idModulo": 3,
    "bitAgregar": true,
    "bitEditar": true,
    "bitConsulta": true,
    "bitEliminar": false,
    "bitDetalle": true
  }'

Success response

200
{
  "success": true,
  "data": {
    "id": 42,
    "idPerfil": 2,
    "idModulo": 3,
    "bitAgregar": true,
    "bitEditar": true,
    "bitConsulta": true,
    "bitEliminar": false,
    "bitDetalle": true
  }
}

Delete permission

DELETE /api/permisos/:id Permanently removes a single permission record from the permisos_perfil table.

Path parameters

id
number
required
Primary key of the permisos_perfil row to delete.

Response

success
boolean
required
true when the delete completes.
message
string
required
Always "Eliminado correctamente".

Examples

curl --request DELETE \
  --url https://your-domain.com/api/permisos/42 \
  --cookie 'auth_token=<your-jwt>'

Success response

200
{
  "success": true,
  "message": "Eliminado correctamente"
}

Build docs developers (and LLMs) love