Skip to main content
PUT
/
motorista
/
{id}
Update Driver
curl --request PUT \
  --url https://api.example.com/motorista/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "nombre1": "<string>",
  "nombre2": "<string>",
  "nombre3": "<string>",
  "apellido1": "<string>",
  "apellido2": "<string>",
  "apellido3": "<string>",
  "telefono": "<string>",
  "dui": "<string>",
  "nit": "<string>",
  "direccion": "<string>",
  "codigoEmpleado": "<string>",
  "cargoNominal": "<string>",
  "cargoFuncional": "<string>",
  "observaciones": "<string>",
  "idDepartamentoAsignado": 123,
  "idTipoLicencia": 123,
  "numeroLicencia": "<string>",
  "fechaVencimientoLicencia": "<string>",
  "idTipoDisponibilidad": 123,
  "imei": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": {}
}
Updates the information of an existing driver. All fields are optional - only provided fields will be updated.

Endpoint

PUT /motorista/{id_perfil}

Path Parameters

id_perfil
integer
required
The unique profile ID of the driver to update

Request Body

All fields are optional. Only include fields you want to update.
email
string
Driver’s email address. Must be unique and valid format.
nombre1
string
First name (max 100 characters)
nombre2
string
Second name (max 100 characters)
nombre3
string
Third name (max 100 characters)
apellido1
string
First surname (max 100 characters)
apellido2
string
Second surname (max 100 characters)
apellido3
string
Married name (max 100 characters)
telefono
string
Contact phone number (max 20 characters)
dui
string
National ID number. Format: ########-#. Must be unique.
nit
string
Tax identification number (max 17 characters)
direccion
string
Residential address (max 500 characters)
codigoEmpleado
string
Employee code (max 50 characters)
cargoNominal
string
Nominal position (max 150 characters)
cargoFuncional
string
Functional position (max 150 characters)
observaciones
string
Additional observations or notes
idDepartamentoAsignado
integer
ID of the assigned department. Must reference an existing department.
idTipoLicencia
integer
ID of the license type. Must reference an existing license type.
numeroLicencia
string
Driver’s license number (max 50 characters)
fechaVencimientoLicencia
string
License expiration date. Format: YYYY-MM-DD
idTipoDisponibilidad
integer
ID of the availability status. Must reference an existing availability type.
imei
string
Mobile device IMEI (max 100 characters). Must be unique if provided.

Response

success
boolean
Indicates if the operation was successful
message
string
Success or error message
data
object
Updated driver information with all current values

Example Request

{
  "telefono": "7777-9999",
  "direccion": "Nueva dirección, San Salvador",
  "idTipoDisponibilidad": 2,
  "fechaVencimientoLicencia": "2027-12-31"
}

Example Response

{
  "success": true,
  "message": "Motorista actualizado exitosamente",
  "data": {
    "idPerfil": 123,
    "nombreCompleto": "JUAN CARLOS MARTINEZ LOPEZ",
    "email": "[email protected]",
    "telefono": "7777-9999",
    "direccion": "Nueva dirección, San Salvador",
    "disponibilidad": "Ocupado",
    "fechaVencimientoLicencia": "2027-12-31"
  }
}

Validations

The endpoint performs the following validations:
  • Driver existence: Driver must exist and be active (not deleted)
  • Unique constraints: If email, DUI, or IMEI are being changed, they must be unique
  • Format validation:
    • Email must match valid email format
    • DUI must match format ########-#
    • Dates must match format YYYY-MM-DD
  • Foreign key validation: If changing department, license type, or availability, the referenced records must exist

Status Codes

  • 200: Driver updated successfully
  • 400: Validation error (invalid format)
  • 404: Driver not found or has been deleted
  • 409: Conflict (duplicate email, DUI, or IMEI)
  • 500: Internal server error

Error Response Examples

Driver Not Found

{
  "success": false,
  "message": "Motorista no encontrado o ha sido eliminado",
  "data": null
}

Duplicate Email

{
  "success": false,
  "message": "El correo electrónico ya está registrado para otro motorista",
  "data": null
}

Invalid Date Format

{
  "success": false,
  "message": "La fecha debe tener el formato YYYY-MM-DD",
  "data": null
}

Quick Availability Update

For updating only the driver’s availability status, use the dedicated PATCH endpoint for better performance.

Endpoint

PATCH /motorista/{id_perfil}/disponibilidad

Request Body

idTipoDisponibilidad
integer
required
ID of the new availability status

Example Request

{
  "idTipoDisponibilidad": 2
}

Example Response

{
  "success": true,
  "message": "Disponibilidad del motorista actualizada exitosamente",
  "data": {
    "idPerfil": 123,
    "nombreCompleto": "JUAN CARLOS MARTINEZ LOPEZ",
    "idTipoDisponibilidad": 2,
    "disponibilidad": "Ocupado"
  }
}

Use Cases

  • Quick status changes during mission assignments
  • Marking drivers as unavailable for maintenance
  • Updating availability from mobile apps
  • Real-time status updates in dispatch systems

Status Codes

  • 200: Availability updated successfully
  • 404: Driver not found
  • 500: Internal server error

Build docs developers (and LLMs) love