Zones API
The Zones API provides CRUD operations for managing geographical zones (zonas), which are used to group and organize units by location or region.Endpoints
Get All Zones
Retrieves a list of all zones in the organization.Request
Method:GET
Endpoint: /zonas
Headers:
Authorization: Bearer token (required)
Response
Status Code:200 OK
Response Example
Create Zone
Registers a new geographical zone.Request
Method:POST
Endpoint: /zonas
Headers:
Authorization: Bearer token (required)Content-Type: application/json (required)
| Field | Type | Required | Description |
|---|---|---|---|
nombre | String | Yes | Name of the zone (cannot be blank) |
Response
Status Code:200 OK
Response Example
Update Zone
Updates an existing zone, including its name and active status.Request
Method:PUT
Endpoint: /zonas
Headers:
Authorization: Bearer token (required)Content-Type: application/json (required)
| Field | Type | Required | Description |
|---|---|---|---|
id | Integer | Yes | ID of the zone to update |
nombre | String | Yes | Updated name of the zone (cannot be blank) |
activo | Boolean | Yes | Active status of the zone |
Response
Status Code:200 OK
Response Example
Delete Zone
Permanently deletes a zone from the system.Request
Method:DELETE
Endpoint: /zonas/{id}
Path Parameters:
| Parameter | Type | Description |
|---|---|---|
id | Integer | ID of the zone to delete |
Authorization: Bearer token (required)
Response
Status Code:200 OK
Response Example
Entity Structure
Zone Entity
| Field | Type | Description |
|---|---|---|
id | Integer | Unique identifier for the zone |
nombre | String | Name of the zone |
activo | Boolean | Indicates if the zone is active |
Status Values
activo: true- The zone is active and can be assigned to unitsactivo: false- The zone is inactive and should not be used for new assignments
Relationships
Zones are geographical groupings that:- Can contain multiple organizational units
- Help organize units by region or location
- Are referenced when creating or updating units
- May be used for reporting and analytics purposes
Validation Rules
Create Zone
nombre: Required, cannot be blank or null
Update Zone
id: Required, must reference an existing zonenombre: Required, cannot be blank or nullactivo: Required, must be a boolean value
Error Responses
Validation Error
Status Code:400 Bad Request
Not Found Error
Status Code:404 Not Found
Referential Integrity Error
Status Code:409 Conflict
Use Cases
Regional Organization
Zones can be used to organize units by geographical regions:- North, South, East, West zones
- State or province-based zones
- Metropolitan vs. rural zones
- International vs. domestic zones
Operational Management
Zones enable:- Regional reporting and analytics
- Zone-specific supervisor assignments
- Geographical performance tracking
- Resource allocation by region
Best Practices
- Naming Convention: Use clear, descriptive names for zones (e.g., “Zona Norte”, “Región Metropolitana”)
- Status Management: Instead of deleting zones with existing units, set them to inactive (
activo: false) - Referential Integrity: Before deleting a zone, ensure no units reference it
- Hierarchical Organization: Consider zone hierarchy if needed (e.g., regions containing zones)
Get States (Geographic)
Retrieve the list of Mexican states (estados) for geographic reference. This is a read-only catalog used for address and location information.Authentication
This endpoint is publicly accessible and does not require authentication.Response
Array of state objects
Success message: “Estados registrados”
Example Request
cURL
Example Response
This catalog contains all 32 Mexican states and is used for address validation and geographic filtering throughout the system.
Related Endpoints
- Units API - Manage organizational units that belong to zones
- Employees API - Manage employees assigned to units within zones