Overview
The Estado (State/Status) API manages system-wide state definitions used across multiple entities in the RestAPI system.Model Structure
The Estado model represents various states that entities can have throughout the system, such as active, inactive, pending, approved, etc.Fields
Primary key. Auto-incremented unique identifier for the state.
State identifier code. Used for programmatic state checking.Default:
0State name. Human-readable label for the state. Maximum 30 characters.
Endpoints
List States
Response
Unique database identifier
State identifier code
State name
Example Response
Get State
Path Parameters
The unique database identifier of the state to retrieve
Response
Unique database identifier
State identifier code
State name
Example Response
Get State by Code
Query Parameters
The state identifier code to filter by
Response
Returns an array of matching states.Example Response
Create State
Request Body
State identifier code. Should be unique within the system.
State name. Maximum 30 characters.
Example Request
Response
Unique database identifier for the newly created state
State identifier code
State name
Update State
Path Parameters
The unique database identifier of the state to update
Request Body
Updated state identifier code
Updated state name. Maximum 30 characters.
Example Request
Partial Update State
Path Parameters
The unique database identifier of the state to update
Request Body
Any subset of the state fields can be provided.Example Request
Delete State
Path Parameters
The unique database identifier of the state to delete
Response
Returns 204 No Content on successful deletion.Common State Codes
The following state codes are commonly used throughout the system:| id_estado | nombre | Description |
|---|---|---|
| 0 | Inactivo | Entity is inactive or not in use |
| 1 | Activo | Entity is active and operational |
| 2 | Pendiente | Entity is pending approval or processing |
| 3 | Deshabilitado | Entity is disabled by administrator |
| 4 | Aprobado | Entity has been approved |
| 5 | Rechazado | Entity has been rejected |
Relationships
The Estado model is referenced by:- Empresa: Companies have a state (active, inactive, etc.)
- Usuario: User status (0=Inactive, 1=Active, 3=Disabled)
- RolUsuario: Role status
- Vehiculo: Vehicle status
- Publicista: Advertiser status
- Chofer: Driver status
- Cliente: Client status
- CampanaPublicitaria: Campaign status
- Sector: Geographic sector status
Usage Notes
- The
id_estadofield is used for programmatic state checking in business logic - The
nombrefield provides human-readable labels for UI display - While some models use Estado as a foreign key, many use direct integer fields for state
- Consider standardizing state codes across the application for consistency
- State 0 typically represents inactive/initial state
- State 1 typically represents active/approved state
- Higher state codes are used for specific statuses like pending, disabled, rejected
Best Practices
- Consistency: Use consistent
id_estadovalues across the application - Documentation: Keep state definitions well-documented for developers
- Validation: Validate state transitions in business logic (e.g., can’t go from Rejected directly to Active)
- Audit: Consider logging state changes for audit purposes
- Localization: The
nombrefield should be in the application’s primary language (Spanish in this case)