Skip to main content

Overview

The Drivers (Choferes) API allows you to manage driver information including personal details, identification, and location data. Drivers are linked to user accounts and can be associated with vehicles for campaign participation.

Base Endpoint

/Database/choferes/

Model Structure

Chofer Model

The Chofer model represents a driver in the system with the following fields:
id_chofer
integer
required
Unique identifier for the driver (auto-generated primary key)
id_usuario
integer
required
Foreign key reference to the Usuario (User) model. Links the driver to their user account
cedula_chofer
string
required
Driver’s identification number (cedula). Maximum 10 characters
nombre
string
required
Driver’s first name. Maximum 20 characters
apellido
string
required
Driver’s last name. Maximum 20 characters
fecha_nacimiento
date
required
Driver’s date of birth in ISO 8601 format (YYYY-MM-DD)
sexo
integer
required
Driver’s gender represented as an integer:
  • 0: Female
  • 1: Male
id_ciudad
integer
required
Foreign key reference to the Ciudad (City) model. Defaults to 1
id_pais
integer
required
Foreign key reference to the Pais (Country) model. Defaults to 1
estado
integer
required
Current status of the driver:
  • 0: Inactive
  • 1: Active
  • 3: Disabled

Endpoints

List All Drivers

GET /Database/Database/choferes/

Retrieve a list of all drivers in the system

Response

id_chofer
integer
Driver’s unique identifier
id_usuario
integer
Associated user account ID
cedula_chofer
string
Driver’s identification number
nombre
string
Driver’s first name
apellido
string
Driver’s last name
fecha_nacimiento
date
Driver’s date of birth
sexo
integer
Driver’s gender (0: Female, 1: Male)
id_ciudad
integer
City ID where the driver is located
id_pais
integer
Country ID where the driver is located
estado
integer
Driver’s status (0: Inactive, 1: Active, 3: Disabled)

Example Response

[
  {
    "id_chofer": 1,
    "id_usuario": 15,
    "cedula_chofer": "1234567890",
    "nombre": "Juan",
    "apellido": "Pérez",
    "fecha_nacimiento": "1985-03-15",
    "sexo": 1,
    "id_ciudad": 1,
    "id_pais": 1,
    "estado": 1
  },
  {
    "id_chofer": 2,
    "id_usuario": 22,
    "cedula_chofer": "0987654321",
    "nombre": "María",
    "apellido": "González",
    "fecha_nacimiento": "1990-07-22",
    "sexo": 0,
    "id_ciudad": 2,
    "id_pais": 1,
    "estado": 1
  }
]

Get Single Driver

GET /Database/Database/choferes/{id}/

Retrieve details of a specific driver by ID

Path Parameters

id
integer
required
The unique identifier of the driver

Example Response

{
  "id_chofer": 1,
  "id_usuario": 15,
  "cedula_chofer": "1234567890",
  "nombre": "Juan",
  "apellido": "Pérez",
  "fecha_nacimiento": "1985-03-15",
  "sexo": 1,
  "id_ciudad": 1,
  "id_pais": 1,
  "estado": 1
}

Create New Driver

POST /Database/Database/choferes/

Create a new driver in the system

Request Body

id_usuario
integer
required
User account ID to associate with this driver
cedula_chofer
string
required
Driver’s identification number (max 10 characters)
nombre
string
required
Driver’s first name (max 20 characters)
apellido
string
required
Driver’s last name (max 20 characters)
fecha_nacimiento
date
required
Driver’s date of birth (YYYY-MM-DD)
sexo
integer
required
Driver’s gender (0 or 1)
id_ciudad
integer
default:"1"
City ID (defaults to 1 if not provided)
id_pais
integer
default:"1"
Country ID (defaults to 1 if not provided)
estado
integer
required
Driver status (0, 1, or 3)

Example Request

{
  "id_usuario": 25,
  "cedula_chofer": "1122334455",
  "nombre": "Carlos",
  "apellido": "Rodríguez",
  "fecha_nacimiento": "1988-11-10",
  "sexo": 1,
  "id_ciudad": 1,
  "id_pais": 1,
  "estado": 1
}

Example Response

{
  "id_chofer": 3,
  "id_usuario": 25,
  "cedula_chofer": "1122334455",
  "nombre": "Carlos",
  "apellido": "Rodríguez",
  "fecha_nacimiento": "1988-11-10",
  "sexo": 1,
  "id_ciudad": 1,
  "id_pais": 1,
  "estado": 1
}

Update Driver

PUT /Database/Database/choferes/{id}/

Update an existing driver’s information (full update)

Path Parameters

id
integer
required
The unique identifier of the driver to update

Request Body

All fields from the create request are required for a full update.

Example Request

{
  "id_usuario": 25,
  "cedula_chofer": "1122334455",
  "nombre": "Carlos",
  "apellido": "Rodríguez García",
  "fecha_nacimiento": "1988-11-10",
  "sexo": 1,
  "id_ciudad": 2,
  "id_pais": 1,
  "estado": 1
}

Partial Update Driver

PATCH /Database/Database/choferes/{id}/

Partially update a driver’s information

Path Parameters

id
integer
required
The unique identifier of the driver to update

Request Body

Include only the fields you want to update.

Example Request

{
  "estado": 0,
  "id_ciudad": 3
}

Delete Driver

DELETE /Database/Database/choferes/{id}/

Delete a driver from the system

Path Parameters

id
integer
required
The unique identifier of the driver to delete

Response

HTTP 204 No Content

Relationships

The Chofer model has foreign key relationships with:
  • Usuario (id_usuario): Links to the user account. Each driver must have an associated user account with authentication credentials
  • Ciudad (id_ciudad): Links to the city where the driver is located
  • Pais (id_pais): Links to the country where the driver is located

Referenced By

Drivers are referenced by:
  • Vehiculo model via id_chofer - Links vehicles to their drivers
  • IngresoConductorCampana model - Associates drivers with advertising campaigns

Business Logic

Driver Registration Flow

  1. A user account must be created first with rol_usuario set to driver role
  2. The Chofer record is then created linking to the user via id_usuario
  3. Drivers can register vehicles under their account
  4. Drivers can apply to participate in advertising campaigns

Status Management

  • Active (1): Driver can participate in campaigns and use the system
  • Inactive (0): Driver account exists but is not currently active
  • Disabled (3): Driver has been disabled by administrators and cannot access the system

Validation Notes

  • cedula_chofer should be exactly 10 digits for most Latin American countries
  • fecha_nacimiento should represent an age of 18 years or older for driver eligibility
  • id_usuario must reference an existing user with appropriate driver role
  • The same cedula_chofer should not be registered multiple times

Example Use Cases

Creating a New Driver

curl -X POST https://api.example.com/Database/Database/choferes/ \
  -H "Content-Type: application/json" \
  -d '{
    "id_usuario": 30,
    "cedula_chofer": "1234567890",
    "nombre": "Luis",
    "apellido": "Martínez",
    "fecha_nacimiento": "1992-05-18",
    "sexo": 1,
    "id_ciudad": 1,
    "id_pais": 1,
    "estado": 1
  }'

Deactivating a Driver

curl -X PATCH https://api.example.com/Database/Database/choferes/1/ \
  -H "Content-Type: application/json" \
  -d '{
    "estado": 0
  }'

Filtering Active Drivers

curl -X GET "https://api.example.com/Database/Database/choferes/?estado=1"

Build docs developers (and LLMs) love