Update Tractor
Update an existing tractor’s information. This endpoint requires administrator authentication. Only the fields provided in the request body will be updated (partial updates supported).Endpoint
Authentication
This endpoint requires both authentication and administrator privileges:Path Parameters
Unique identifier of the tractor to update. Must be a positive integer.
Request Body
All fields are optional. Only include the fields you want to update. The API uses SQL
COALESCE to preserve existing values for fields not included in the request.Tractor brand/manufacturer name. Cannot be empty if provided.Example:
"John Deere", "Case IH"Tractor model identifier. Cannot be empty if provided.Example:
"6130M", "Magnum 280"Engine power in horsepower (HP). Must be a positive number if provided.Example:
135, 285.5Type of traction system. Must be one of:
4x2, 4x4, trackDisplay name for the tractor.Example:
"John Deere 6130M Updated"Total weight in kilograms. Must be a positive number if provided.Example:
5300, 11500.5Traction force in kilonewtons (kN). Must be a positive number if provided.Example:
46.0, 87.2Type of tires installed on the tractor.Example:
"radial", "bias"Tire width in millimeters. Must be a positive number if provided.Example:
550, 720Tire diameter in millimeters. Must be a positive number if provided.Example:
1620, 1900Recommended tire pressure in PSI. Must be a positive number if provided.Example:
16, 18.5Current status of the tractor. Must be one of:
available, maintenance, inactiveResponse Fields
Indicates if the request was successful
The updated tractor object with all fields
Example Request - Partial Update
Example Request - Full Update
Example Responses
Validation Rules
Update-Specific Validation
For updates (PUT requests), required fields from creation are optional. However, if you provide a field, it must pass validation.
String Fields
String Fields
If provided, string fields cannot be empty:
brand- Cannot be empty string or whitespacemodel- Cannot be empty string or whitespace
"John Deere", "Updated Model"Invalid: "", " ", nullNumeric Fields
Numeric Fields
If provided, must be positive numbers:
engine_power_hpweight_kgtraction_force_kntire_width_mmtire_diameter_mmtire_pressure_psi
130, 5200.5, 45Invalid: 0, -10, "abc"Enum Fields
Enum Fields
Must match allowed values if provided:traction_type:
4x2, 4x4, trackstatus: available, maintenance, inactiveCommon Use Cases
Change Status
Update tractor status (e.g., from
available to maintenance)Update Specifications
Modify technical specifications after verification
Correct Model Info
Fix typos or update model information
Update Tire Config
Change tire specifications
Error Responses
400 Bad Request - Invalid ID
400 Bad Request - Invalid ID
Returned when the tractor ID in the URL path is not a valid positive integer.Examples:
/api/tractors/abc, /api/tractors/-1, /api/tractors/0400 Bad Request - Validation Errors
400 Bad Request - Validation Errors
Returned when the request body contains invalid data. The response includes an
errors array.Common errors:"brand no puede estar vacío"- Empty brand provided"model no puede estar vacío"- Empty model provided"engine_power_hp debe ser un número positivo"- Invalid power value"traction_type debe ser uno de: 4x2, 4x4, track"- Invalid traction type"status debe ser uno de: available, maintenance, inactive"- Invalid status
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Returned when the authenticated user is not an administrator.
404 Not Found
404 Not Found
Returned when no tractor exists with the specified ID.
500 Internal Server Error
500 Internal Server Error
Returned when an unexpected server error occurs.
Cache Invalidation
Updating a tractor automatically invalidates all tractor-related and recommendation caches. This ensures that GET requests immediately reflect the updated information.
Related Endpoints
Get Tractor
View current tractor details before updating
Create Tractor
Add new tractors to the catalog
Delete Tractor
Remove tractor from catalog
List Tractors
View all tractors
