Skip to main content
GET
/
api
/
opciones
Opciones
curl --request GET \
  --url https://api.example.com/api/opciones \
  --header 'Content-Type: application/json' \
  --data '
{
  "id_vista": 123,
  "nombre_vista": "<string>",
  "descripcion": "<string>",
  "estado": 123
}
'
{
  "results": [
    {
      "id_opcion": 123,
      "id_vista": 123,
      "nombre_vista": "<string>",
      "descripcion": "<string>",
      "estado": 123
    }
  ],
  "id_opcion": 123,
  "id_vista": 123,
  "nombre_vista": "<string>",
  "descripcion": "<string>",
  "estado": 123
}

Opciones API

The Opciones (Options/Actions) endpoint manages action-level entries in the hierarchical permission system. Opciones belong to Vistas and represent specific actions users can perform.

Hierarchy

Menu (Top Level)
 └── Vista (Views within menu)
     └── Opciones (Actions within view) ← Current Level

Model Structure

The Opciones model represents the lowest level of the permission hierarchy, defining specific actions available within a Vista.

Fields

id_opcion
integer
required
Auto-incremented primary key identifying the opcion
id_vista
integer
required
Foreign key reference to the parent Vista
nombre_vista
string
required
Name of the action/option (max 40 characters) Examples: “Crear”, “Editar”, “Eliminar”, “Ver”, “Exportar”
descripcion
string
Description of the action’s purpose (max 40 characters)
estado
integer
required
Status of the opcion
  • 0: Inactive
  • 1: Active

Endpoints

List All Opciones

GET /api/opciones/
Retrieve all opciones in the system.

Query Parameters

id_vista
integer
Filter opciones by vista ID
estado
integer
Filter by status (0: Inactive, 1: Active)

Response

results
array
id_opcion
integer
Unique identifier for the opcion
id_vista
integer
Parent vista ID
nombre_vista
string
Action name
descripcion
string
Action description
estado
integer
Action status

Example Response

{
  "results": [
    {
      "id_opcion": 1,
      "id_vista": 2,
      "nombre_vista": "Crear",
      "descripcion": "Create new campaign",
      "estado": 1
    },
    {
      "id_opcion": 2,
      "id_vista": 2,
      "nombre_vista": "Editar",
      "descripcion": "Edit existing campaign",
      "estado": 1
    },
    {
      "id_opcion": 3,
      "id_vista": 2,
      "nombre_vista": "Eliminar",
      "descripcion": "Delete campaign",
      "estado": 1
    },
    {
      "id_opcion": 4,
      "id_vista": 2,
      "nombre_vista": "Ver",
      "descripcion": "View campaign details",
      "estado": 1
    }
  ]
}

Get Opcion by ID

GET /api/opciones/{id_opcion}/
Retrieve details of a specific opcion.

Path Parameters

id_opcion
integer
required
The unique identifier of the opcion

Response

id_opcion
integer
Unique identifier for the opcion
id_vista
integer
Parent vista ID
nombre_vista
string
Action name
descripcion
string
Action description
estado
integer
Action status

Example Response

{
  "id_opcion": 1,
  "id_vista": 2,
  "nombre_vista": "Crear",
  "descripcion": "Create new campaign",
  "estado": 1
}

Get Opciones by Vista

GET /api/opciones/?id_vista={id_vista}
Retrieve all opciones belonging to a specific vista.

Example Response

{
  "results": [
    {
      "id_opcion": 1,
      "id_vista": 2,
      "nombre_vista": "Crear",
      "descripcion": "Create new campaign",
      "estado": 1
    },
    {
      "id_opcion": 2,
      "id_vista": 2,
      "nombre_vista": "Editar",
      "descripcion": "Edit existing campaign",
      "estado": 1
    }
  ]
}

Create Opcion

POST /api/opciones/
Create a new action option within a vista.

Request Body

id_vista
integer
required
The ID of the parent vista
nombre_vista
string
required
Name of the action (max 40 characters)
descripcion
string
Description of the action (max 40 characters)
estado
integer
required
Status of the action (0: Inactive, 1: Active)

Example Request

{
  "id_vista": 2,
  "nombre_vista": "Exportar",
  "descripcion": "Export campaign data",
  "estado": 1
}

Response

id_opcion
integer
The ID of the newly created opcion
id_vista
integer
Parent vista ID
nombre_vista
string
Action name
descripcion
string
Action description
estado
integer
Action status

Update Opcion

PUT /api/opciones/{id_opcion}/
PATCH /api/opciones/{id_opcion}/
Update an existing opcion. Use PUT for full updates or PATCH for partial updates.

Path Parameters

id_opcion
integer
required
The unique identifier of the opcion to update

Request Body

id_vista
integer
Updated parent vista ID
nombre_vista
string
Updated action name
descripcion
string
Updated description
estado
integer
Updated status

Delete Opcion

DELETE /api/opciones/{id_opcion}/
Delete an opcion from the system.

Path Parameters

id_opcion
integer
required
The unique identifier of the opcion to delete

Complete Hierarchy Example

Here’s a complete example showing the full permission hierarchy:
{
  "menu": {
    "id_menu": 2,
    "nombre_menu": "Campañas",
    "descripcion": "Campaign management",
    "vistas": [
      {
        "id_vista": 2,
        "nombre_vista": "Gestión de Campañas",
        "descripcion": "Manage campaigns",
        "opciones": [
          {
            "id_opcion": 1,
            "nombre_vista": "Crear",
            "descripcion": "Create new campaign"
          },
          {
            "id_opcion": 2,
            "nombre_vista": "Editar",
            "descripcion": "Edit campaign"
          },
          {
            "id_opcion": 3,
            "nombre_vista": "Eliminar",
            "descripcion": "Delete campaign"
          },
          {
            "id_opcion": 4,
            "nombre_vista": "Ver",
            "descripcion": "View campaign details"
          }
        ]
      },
      {
        "id_vista": 3,
        "nombre_vista": "Estadísticas",
        "descripcion": "Campaign statistics",
        "opciones": [
          {
            "id_opcion": 5,
            "nombre_vista": "Ver Reportes",
            "descripcion": "View campaign reports"
          },
          {
            "id_opcion": 6,
            "nombre_vista": "Exportar",
            "descripcion": "Export statistics"
          }
        ]
      }
    ]
  }
}

Common Action Names

Typical action names used in the system:
  • Crear - Create new records
  • Editar - Edit existing records
  • Eliminar - Delete records
  • Ver - View/read records
  • Exportar - Export data
  • Importar - Import data
  • Aprobar - Approve records
  • Rechazar - Reject records

Usage Notes

  • Opciones must belong to a valid Vista (id_vista foreign key)
  • Each opcion represents a specific action within a vista
  • Use DetallePermisos to control whether specific opciones are allowed for a role
  • Set estado to 0 to disable an action rather than deleting it
  • Action names should be consistent across similar vistas for better UX

Build docs developers (and LLMs) love