Skip to main content

Update Service Record

Update an existing lubrication service record.
PUT /api/engrases/:id

Path Parameters

id
number
required
Service record ID to update

Request Body

fecha
string
Service date in YYYY-MM-DD format
conductor_id
number
ID of the driver
placa_id
number
ID of the vehicle plate
area_operacion_id
number
ID of the operational area
lavado
number
Washing service cost
engrase
number
Lubrication service cost
otros
number
Other services cost
observaciones
string
Additional notes or comments
You can update any combination of fields. Only provided fields will be updated.

Response

Returns the updated service record with all fields.
id
number
Service record ID
actualizado_por
string
User ID who updated the record
actualizado_en
string
Timestamp of the update (ISO 8601)

Example Request

curl -X PUT "https://api.example.com/api/engrases/102" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "lavado": 30000,
    "observaciones": "Servicio actualizado - lavado premium"
  }'

Example Response

{
  "id": 102,
  "fecha": "2024-03-04",
  "conductor_id": 5,
  "placa_id": 23,
  "area_operacion_id": 2,
  "lavado": 30000,
  "engrase": 45000,
  "otros": 10000,
  "suma": 85000,
  "observaciones": "Servicio actualizado - lavado premium",
  "creado_por": "user-uuid-here",
  "actualizado_por": "user-uuid-here",
  "actualizado_en": "2024-03-04T15:30:00Z"
}

Common Update Scenarios

Update Cost Values

Modify service costs:
{
  "lavado": 30000,
  "engrase": 50000
}

Update Observations

Add or modify notes:
{
  "observaciones": "Servicio completado con retraso por lluvia"
}

Change Vehicle or Driver

Reassign the service to different vehicle/driver:
{
  "placa_id": 25,
  "conductor_id": 7
}

Change Date

Correct the service date:
{
  "fecha": "2024-03-05"
}

Automatic Updates

The following fields are automatically updated:
  • suma is recalculated when any cost field changes
  • actualizado_por is set to the authenticated user’s ID
  • actualizado_en is set to the current timestamp

Error Responses

Service Not Found

{
  "error": "Engrase not found"
}
Status: 404

Invalid Data

{
  "error": "Invalid conductor_id"
}
Status: 400

Unauthorized

{
  "error": "Unauthorized"
}
Status: 401

Best Practices

Audit Trail: Every update records who made the change and when
Partial Updates: Only send fields that need to be updated
Validation: Verify foreign key IDs exist before updating
Updates are immediate and cannot be undone. Consider implementing a confirmation step in your UI.

Build docs developers (and LLMs) love