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

Vistas API

The Vistas (Views) endpoint manages view-level entries in the hierarchical permission system. Vistas belong to Menus and contain multiple Opciones (action options).

Hierarchy

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

Model Structure

The Vista model represents the middle level of the permission hierarchy, connecting Menus to specific actions (Opciones).

Fields

id_vista
integer
required
Auto-incremented primary key identifying the vista
id_menu
integer
required
Foreign key reference to the parent Menu
nombre_vista
string
required
Name of the vista (max 40 characters)
descripcion
string
Description of the vista’s purpose (max 40 characters)
estado
integer
required
Status of the vista
  • 0: Inactive
  • 1: Active

Endpoints

List All Vistas

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

Query Parameters

id_menu
integer
Filter vistas by menu ID
estado
integer
Filter by status (0: Inactive, 1: Active)

Response

results
array
id_vista
integer
Unique identifier for the vista
id_menu
integer
Parent menu ID
nombre_vista
string
Vista name
descripcion
string
Vista description
estado
integer
Vista status

Example Response

{
  "results": [
    {
      "id_vista": 1,
      "id_menu": 1,
      "nombre_vista": "Panel Principal",
      "descripcion": "Main dashboard view",
      "estado": 1
    },
    {
      "id_vista": 2,
      "id_menu": 2,
      "nombre_vista": "Gestión de Campañas",
      "descripcion": "Campaign management view",
      "estado": 1
    },
    {
      "id_vista": 3,
      "id_menu": 2,
      "nombre_vista": "Estadísticas de Campañas",
      "descripcion": "Campaign statistics view",
      "estado": 1
    }
  ]
}

Get Vista by ID

GET /api/vistas/{id_vista}/
Retrieve details of a specific vista.

Path Parameters

id_vista
integer
required
The unique identifier of the vista

Response

id_vista
integer
Unique identifier for the vista
id_menu
integer
Parent menu ID
nombre_vista
string
Vista name
descripcion
string
Vista description
estado
integer
Vista status

Example Response

{
  "id_vista": 1,
  "id_menu": 1,
  "nombre_vista": "Panel Principal",
  "descripcion": "Main dashboard view",
  "estado": 1
}

Get Vistas by Menu

GET /api/vistas/?id_menu={id_menu}
Retrieve all vistas belonging to a specific menu.

Example Response

{
  "results": [
    {
      "id_vista": 2,
      "id_menu": 2,
      "nombre_vista": "Gestión de Campañas",
      "descripcion": "Campaign management view",
      "estado": 1
    },
    {
      "id_vista": 3,
      "id_menu": 2,
      "nombre_vista": "Estadísticas de Campañas",
      "descripcion": "Campaign statistics view",
      "estado": 1
    }
  ]
}

Create Vista

POST /api/vistas/
Create a new vista within a menu.

Request Body

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

Example Request

{
  "id_menu": 2,
  "nombre_vista": "Crear Campaña",
  "descripcion": "Create new campaign view",
  "estado": 1
}

Response

id_vista
integer
The ID of the newly created vista
id_menu
integer
Parent menu ID
nombre_vista
string
Vista name
descripcion
string
Vista description
estado
integer
Vista status

Update Vista

PUT /api/vistas/{id_vista}/
PATCH /api/vistas/{id_vista}/
Update an existing vista. Use PUT for full updates or PATCH for partial updates.

Path Parameters

id_vista
integer
required
The unique identifier of the vista to update

Request Body

id_menu
integer
Updated parent menu ID
nombre_vista
string
Updated vista name
descripcion
string
Updated description
estado
integer
Updated status

Delete Vista

DELETE /api/vistas/{id_vista}/
Delete a vista from the system. Note: This will cascade delete all associated Opciones.

Path Parameters

id_vista
integer
required
The unique identifier of the vista to delete

Hierarchy Example

Here’s how Vistas fit into the permission hierarchy:
{
  "menu": {
    "id_menu": 2,
    "nombre_menu": "Campañas",
    "vistas": [
      {
        "id_vista": 2,
        "nombre_vista": "Gestión de Campañas",
        "opciones": [
          {"id_opcion": 1, "nombre_vista": "Crear"},
          {"id_opcion": 2, "nombre_vista": "Editar"},
          {"id_opcion": 3, "nombre_vista": "Eliminar"}
        ]
      },
      {
        "id_vista": 3,
        "nombre_vista": "Estadísticas de Campañas",
        "opciones": [
          {"id_opcion": 4, "nombre_vista": "Ver Reportes"},
          {"id_opcion": 5, "nombre_vista": "Exportar Datos"}
        ]
      }
    ]
  }
}
  • Menus - Parent menus containing vistas
  • Opciones - Actions within vistas
  • PermisosXRol - Role-based permissions linking to vistas

Usage Notes

  • Vistas must belong to a valid Menu (id_menu foreign key)
  • Each vista can contain multiple Opciones (action options)
  • Deleting a vista will cascade delete all associated Opciones
  • Set estado to 0 to disable rather than deleting
  • Use PermisosXRol to control which roles can access specific vistas

Build docs developers (and LLMs) love