Create Implement
Create a new agricultural implement in the system catalog. This endpoint requires administrator authentication.Endpoint
Authentication
Include your JWT token in the Authorization header:Request Body
Name of the implementExample: “3-body disc plow”
Manufacturer brand nameExample: “Baldan”, “Tatu”, “Semeato”
Required horsepower (HP) to operate the implementValidation: Must be a positive numberExample:
50, 85, 120Working width in metersValidation: Must be a positive numberExample:
0.9, 1.5, 2.4Type of implement. Must be one of:
plow- Disc or moldboard plowsharrow- Disc or tine harrowsseeder- Seed planting equipmentsprayer- Pesticide/fertilizer sprayersharvester- Harvesting equipmentcultivator- Soil cultivation toolsmower- Mowing equipmenttrailer- Agricultural trailersother- Other agricultural implements
Compatible soil type(s)Common Values: “Loam”, “Clay”, “Sandy”, “Silty”, “All”Example: “Loam”, “Heavy clay”, “All”
Working depth in centimeters (for plows, cultivators, etc.)Validation: Must be a positive number if providedExample:
25, 30, 15Implement weight in kilogramsValidation: Must be a positive number if providedExample:
320, 450, 280Current status of the implement. Must be one of:
available- Ready for use (default)maintenance- Under maintenanceinactive- Not in service
Response
Indicates if the implement was created successfully
Success or error message
The newly created implement object with all fields including the generated
implement_id and registration_dateExamples
Create a Plow
Create a Seeder
Response Example (201 Created)
Error Responses
Validation Error (400)
Unauthorized - No Token (401)
Unauthorized - Invalid Token (401)
Forbidden - Not Admin (403)
Internal Server Error (500)
Validation Rules
Required Fields
The following fields are required when creating an implement:implement_name(non-empty string)brand(non-empty string)power_requirement_hp(positive number)working_width_m(positive number)implement_type(valid enum value)
Implement Type Validation
Theimplement_type field must be one of:
Status Validation
If provided,status must be one of:
available.
Numeric Validation
All numeric fields must be positive numbers:power_requirement_hp> 0working_width_m> 0working_depth_cm> 0 (if provided)weight_kg> 0 (if provided)
The validation middleware (
src/middleware/validation.middleware.js:65) automatically sanitizes inputs and validates all fields before processing.Implementation Notes
- Source:
src/routes/implement.routes.js:349- Route definition - Controller:
src/controllers/implementController.js:159-createImplementfunction - Model:
src/models/Implement.js:19-create(implementData)method - SQL:
INSERT INTO implement (...) VALUES (...) RETURNING * - Middleware Chain:
verifyTokenMiddleware- Validates JWT tokenisAdmin- Checks for admin role (role_id: 1)validateImplement- Validates request body fieldscreateImplement- Creates the implement
- Cache Invalidation: Automatically invalidates cache entries matching
*implements*pattern
Related Endpoints
List Implements
View all created implements
Get Implement
Retrieve a specific implement by ID
Update Implement
Modify an existing implement (Admin only)
Delete Implement
Remove an implement (Admin only)
Best Practices
Accurate Power Requirements
Ensure
power_requirement_hp reflects realistic tractor power needs based on implement size and soil conditionsClear Naming
Use descriptive implement names that include key specifications (e.g., “3-body disc plow” vs just “plow”)
Soil Compatibility
Specify accurate soil type compatibility to help users make informed equipment selections
Complete Data
Provide all optional fields (weight, working depth) when available for better recommendations
Implements created via this endpoint are immediately available for use in power calculations and tractor-implement matching recommendations.
