Register Farmer for Trade
GET /api/v1/trades/{tradeId}/farmers
Description
This endpoint is used to register a farmer within the context of a specific trade, documenting their personal details, agricultural practices, and other relevant data to ensure compliance and traceability within agricultural supply chains.
URL Parameters:
tradeId(required): The unique identifier of the trade under which the farmer is being registered. This must be included in the URL path.
Headers:
tenantId(required): The tenant ID under which the farmer is being registered. This should be included as a header.userId(required): The user ID of the individual responsible for registering the farmer. This should also be included as a header.countryCode(required): The country code where the trade and farmer registration is taking place. This should be included as a header.
Request Body (application/json): Required. The body should include detailed information about the farmer:
{
"firstName": "string",
"lastName": "string",
"phone": "string",
"gender": "MALE",
"dob": "string",
"bvn": "string",
"nin": "string",
"country": {
"name": "string",
"code": "string",
"currency": "string"
},
"state": {
"name": "string",
"code": "string"
},
"city": {
"name": "string",
"code": "string"
},
"latitude": 0,
"longitude": 0,
"qualityRecordOfCrop": "string",
"essentialCertification": [
{
"docLinks": [
{}
]
}
],
"noOfarmerInCluster": 0,
"familySizeOfarmer": 0,
"challengesOrNeeds": "string",
"farmSize": 0,
"harvestingAndPostHarvestingService": "string",
"farmLabourPractices": "string",
"environmentalPractices": "string",
"farmClusterInformation": "string",
"targetQuantityPerCycle": "string",
"quantityAggregatedWeekly": "string",
"qualityAndQuantityRecords": "string",
"userId": "string",
"tenantId": "string"
}
Example Request:
curl -X POST "http://[base_url]/api/v1/trades/{tradeId}/farmers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [access_token]" \
-H "tenantId: TEN123" \
-H "userId: USR456" \
-H "countryCode: US" \
-d '{
"firstName": "John",
"lastName": "Doe",
"phone": "+1234567890",
"gender": "MALE",
"dob": "1980-01-01",
"bvn": "123456789012",
"nin": "987654321",
"country": {"name": "Nigeria", "code": "NG", "currency": "NGN"},
"state": {"name": "Lagos", "code": "LA"},
"city": {"name": "Ikeja", "code": "IK"},
"latitude": 6.5244,
"longitude": 3.3792,
"qualityRecordOfCrop": "High-quality maize",
"essentialCertification": [{"docLinks": [{"name": "Certification", "link": "http://example.com/cert.pdf"}]}],
"noOfarmerInCluster": 150,
"familySizeOfarmer": 4,
"challengesOrNeeds": "Need for better irrigation systems",
"farmSize": 50,
"harvestingAndPostHarvestingService": "Available",
"farmLabourPractices": "Fair labor practices observed",
"environmentalPractices": "Sustainable farming",
"farmClusterInformation": "Cluster near Ikeja",
"targetQuantityPerCycle": "5000 kg",
"quantityAggregatedWeekly": "350 kg",
"qualityAndQuantityRecords": "Regular updates maintained",
"userId": "USR456",
"tenantId": "TEN123"
}'
Responses:
- 201 Created: Indicates that the farmer has been successfully registered for the trade. The response typically includes details of the newly registered farmer.
Example Response:
{
"
message": "Farmer registered successfully.",
"farmerId": "farmer123"
}
Error Responses:
- 400 Bad Request: Incorrect or incomplete data for the farmer registration.
- 404 Not Found: No trade found with the provided
tradeId. - 403 Forbidden: The user does not have permission to register a farmer under the trade.
LANGUAGE
CURL REQUEST
curl --request GET \
--url /api/v1/trades/{tradeId}/farmers \
--header 'accept: application/json' \
--header 'content-type: application/json'
RESPONSE
Click Try It! to start a request and see the response here!