Skip to main content

GET /rol/listar

Retrieves a list of all available roles in the system.

Request

No parameters required.

Request Example

curl -X GET https://api.example.com/rol/listar \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

Returns an array of role objects.
roles
array
List of all available roles
idRol
number
Unique identifier for the role
nombre
string
Role name enum value. Possible values:
  • ADMIN - Administrator with full system access
  • USER - Standard user with limited permissions
  • ALMACENERO - Warehouse manager with inventory permissions
descripcion
string
Human-readable description of the role and its permissions

Response Example

[
  {
    "idRol": 1,
    "nombre": "ADMIN",
    "descripcion": "Administrador del sistema con acceso completo"
  },
  {
    "idRol": 2,
    "nombre": "USER",
    "descripcion": "Usuario estándar con permisos limitados"
  },
  {
    "idRol": 3,
    "nombre": "ALMACENERO",
    "descripcion": "Encargado de almacén con permisos de inventario"
  }
]

Status Codes

  • 200 OK - Roles retrieved successfully

Role Types

The system supports the following predefined roles:

ADMIN

Administrator role with complete system access. Can manage users, roles, inventory, sales, purchases, and all other system functions. Typical Permissions:
  • Create, update, and delete users
  • Assign roles to users
  • Full access to all modules
  • System configuration

USER

Standard user role with limited permissions. Suitable for sales representatives or basic system users. Typical Permissions:
  • View products and inventory
  • Process sales
  • View reports
  • Limited modification capabilities

ALMACENERO

Warehouse manager role focused on inventory management. Typical Permissions:
  • Manage product inventory
  • Process purchase orders
  • Update stock levels
  • Generate inventory reports
  • Limited access to sales and financial data

Using Roles in User Management

When creating or updating users, reference roles by their idRol:
# Create a user with ADMIN role (idRol: 1)
curl -X POST https://api.example.com/usuario/crear \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "nombres": "Admin",
    "apellidoPaterno": "User",
    "apellidoMaterno": "System",
    "dni": "11111111",
    "direccion": "System Address",
    "telefono": "+51999999999",
    "estado": true,
    "userName": "admin",
    "password": "securepass",
    "rolId": 1
  }'

Role-Based Access Control

Roles determine which endpoints and features users can access. The authentication service returns user permissions as part of the login response:
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "userName": "admin",
  "accesos": [
    {
      "nombre": "Dashboard",
      "url": "/dashboard",
      "icono": "dashboard-icon",
      "orden": 1
    }
  ]
}
The accesos array contains all menu items and features the user can access based on their assigned role.

Build docs developers (and LLMs) love