Create Tractor
Create a new tractor in the catalog. This endpoint requires administrator authentication.Endpoint
Authentication
This endpoint requires both authentication and administrator privileges:Request Body
Tractor brand/manufacturer name. Cannot be empty.Example:
"John Deere", "Case IH", "New Holland"Tractor model identifier. Cannot be empty.Example:
"6130M", "Magnum 280", "T7.315"Engine power in horsepower (HP). Must be a positive number.Example:
130, 280, 315.5Type of traction system. Must be one of:
4x2, 4x4, track4x2- Two-wheel drive4x4- Four-wheel drivetrack- Track/crawler system
Display name for the tractor. If not provided, defaults to
brand + model.Example: "John Deere 6130M Premium"Total weight in kilograms. Must be a positive number if provided.Example:
5200, 11200.5Traction force in kilonewtons (kN). Must be a positive number if provided.Example:
45.5, 85.3Type of tires installed on the tractor.Example:
"radial", "bias", "dual radial"Tire width in millimeters. Must be a positive number if provided.Example:
540, 710Tire diameter in millimeters. Must be a positive number if provided.Example:
1600, 1880Recommended tire pressure in PSI. Must be a positive number if provided.Example:
15, 18, 12.5Current status of the tractor. Must be one of:
available, maintenance, inactiveDefaults to available if not specified.Response Fields
Indicates if the request was successful
The newly created tractor object with all fields, including the generated
tractor_idExample Request
Example Responses
Validation Rules
Required Fields (POST only)
Optional Field Validation
Numeric Fields
Numeric Fields
The following fields must be positive numbers if provided:
engine_power_hpweight_kgfuel_tank_l(if your database schema includes it)
0, -10, "abc", nullStatus Field
Status Field
If provided, must be one of:
available(default)maintenanceinactive
Traction Type
Traction Type
Must be one of:
4x2- Two-wheel drive4x4- Four-wheel drive (most common)track- Track/crawler system
Error Responses
400 Bad Request - Validation Errors
400 Bad Request - Validation Errors
Returned when request body fails validation. The response includes an
errors array with specific validation messages.Common validation errors:"brand es requerido"- Brand field is missing"model es requerido"- Model field is missing"engine_power_hp es requerido"- Power field is missing"engine_power_hp debe ser un número positivo"- Invalid power value"traction_type es requerido"- Traction type is missing"traction_type debe ser uno de: 4x2, 4x4, track"- Invalid traction type"status debe ser uno de: available, maintenance, inactive"- Invalid status
401 Unauthorized - Missing Token
401 Unauthorized - Missing Token
401 Unauthorized - Invalid Token
401 Unauthorized - Invalid Token
403 Forbidden - Insufficient Permissions
403 Forbidden - Insufficient Permissions
Returned when the authenticated user is not an administrator (
role_id !== 1).Solution: This endpoint is restricted to administrators only. Regular users cannot create tractors.500 Internal Server Error
500 Internal Server Error
Returned when an unexpected server error occurs (e.g., database connection issues, constraint violations).
Cache Invalidation
Creating a new tractor automatically invalidates all tractor-related caches. This ensures that GET requests to
/api/tractors and search endpoints immediately reflect the new tractor.Related Endpoints
List Tractors
View all tractors in the catalog
Update Tractor
Modify existing tractor details
Delete Tractor
Remove tractor from catalog
Authentication
Learn how to obtain admin credentials
