CropSense

Search documentation

Search for a command to run...

API Reference

Fields

The individual plots that make up a farm, including boundaries and metadata.

get/fields/{field_id}

Get a field by id

Requires an Authorization: Bearer header.

Parameters

field_idstringpathrequired

Response 200

field_idstringrequired
cropsense_field_idstringoptional
farm_idstringrequired
namestringrequired
field_typeenum<string>optional

Field type enum

open_fieldorchardplantationpastureforestagroforestryother
field_statusenum<string>optional

Field status enum

fallowharvestedplantedploughed
irrigation_typeenum<string>optional
latitudenumberrequired
longitudenumberrequired
area_hanumberrequired
addressstringoptional
citystringoptional
statestringoptional
countrystringoptional
attributesobjectoptional
geomobjectrequired
is_activebooleanrequired
active_crop_countintegeroptional
created_atstring<date-time>required
updated_atstring<date-time>required
GET /fields/{field_id}
curl -X GET "https://api.cropsense.africa/fields/8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Example response · 200
{
  "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
  "cropsense_field_id": "cropsense_field_id",
  "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
  "name": "Green Valley Farm",
  "field_type": "open_field",
  "field_status": "fallow",
  "irrigation_type": "rainfed",
  "latitude": 1.5,
  "longitude": 1.5,
  "area_ha": 1.5,
  "address": "address",
  "city": "city",
  "state": "state",
  "country": "Kenya",
  "attributes": {},
  "geom": {},
  "is_active": true,
  "active_crop_count": 1,
  "created_at": "2026-06-15T09:30:00Z",
  "updated_at": "2026-06-15T09:30:00Z"
}
put/fields/{field_id}

Update a field by id

Requires an Authorization: Bearer header.

Parameters

field_idstringpathrequired

Request body

namestringoptional
field_typeenum<string>optional

Field type enum

open_fieldorchardplantationpastureforestagroforestryother
field_statusenum<string>optional

Field status enum

fallowharvestedplantedploughed
irrigation_typeenum<string>optional

How a field is watered. Rainfed means no irrigation.

rainfeddripsprinklerfloodsurface
geomobjectoptional
attributesobjectoptional
updated_atstring<date-time>optional

Response 200

field_idstringrequired
cropsense_field_idstringoptional
farm_idstringrequired
namestringrequired
field_typeenum<string>optional

Field type enum

open_fieldorchardplantationpastureforestagroforestryother
field_statusenum<string>optional

Field status enum

fallowharvestedplantedploughed
irrigation_typeenum<string>optional
latitudenumberrequired
longitudenumberrequired
area_hanumberrequired
addressstringoptional
citystringoptional
statestringoptional
countrystringoptional
attributesobjectoptional
geomobjectrequired
is_activebooleanrequired
active_crop_countintegeroptional
created_atstring<date-time>required
updated_atstring<date-time>required
PUT /fields/{field_id}
curl -X PUT "https://api.cropsense.africa/fields/8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Green Valley Farm",
    "field_type": "open_field",
    "field_status": "fallow",
    "irrigation_type": "rainfed",
    "geom": {},
    "attributes": {},
    "updated_at": "2026-06-15T09:30:00Z"
  }'
Example response · 200
{
  "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
  "cropsense_field_id": "cropsense_field_id",
  "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
  "name": "Green Valley Farm",
  "field_type": "open_field",
  "field_status": "fallow",
  "irrigation_type": "rainfed",
  "latitude": 1.5,
  "longitude": 1.5,
  "area_ha": 1.5,
  "address": "address",
  "city": "city",
  "state": "state",
  "country": "Kenya",
  "attributes": {},
  "geom": {},
  "is_active": true,
  "active_crop_count": 1,
  "created_at": "2026-06-15T09:30:00Z",
  "updated_at": "2026-06-15T09:30:00Z"
}
delete/fields/{field_id}

Delete a field by id

Requires an Authorization: Bearer header.

Parameters

field_idstringpathrequired

Response 200

DELETE /fields/{field_id}
curl -X DELETE "https://api.cropsense.africa/fields/8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Example response · 200
null
post/fields/create

Create a field

Requires an Authorization: Bearer header.

Request body

farm_idstringrequired
namestringrequired
field_typeenum<string>optional

Field type enum

open_fieldorchardplantationpastureforestagroforestryother
field_statusenum<string>optional

Field status enum

fallowharvestedplantedploughed
irrigation_typeenum<string>optional
geomobjectrequired
attributesobjectoptional
created_atstring<date-time>optional
updated_atstring<date-time>optional

Response 200

field_idstringrequired
cropsense_field_idstringoptional
farm_idstringrequired
namestringrequired
field_typeenum<string>optional

Field type enum

open_fieldorchardplantationpastureforestagroforestryother
field_statusenum<string>optional

Field status enum

fallowharvestedplantedploughed
irrigation_typeenum<string>optional
latitudenumberrequired
longitudenumberrequired
area_hanumberrequired
addressstringoptional
citystringoptional
statestringoptional
countrystringoptional
attributesobjectoptional
geomobjectrequired
is_activebooleanrequired
active_crop_countintegeroptional
created_atstring<date-time>required
updated_atstring<date-time>required
POST /fields/create
curl -X POST "https://api.cropsense.africa/fields/create" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
    "name": "Green Valley Farm",
    "field_type": "open_field",
    "field_status": "fallow",
    "irrigation_type": "rainfed",
    "geom": {},
    "attributes": {},
    "created_at": "2026-06-15T09:30:00Z",
    "updated_at": "2026-06-15T09:30:00Z"
  }'
Example response · 200
{
  "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
  "cropsense_field_id": "cropsense_field_id",
  "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
  "name": "Green Valley Farm",
  "field_type": "open_field",
  "field_status": "fallow",
  "irrigation_type": "rainfed",
  "latitude": 1.5,
  "longitude": 1.5,
  "area_ha": 1.5,
  "address": "address",
  "city": "city",
  "state": "state",
  "country": "Kenya",
  "attributes": {},
  "geom": {},
  "is_active": true,
  "active_crop_count": 1,
  "created_at": "2026-06-15T09:30:00Z",
  "updated_at": "2026-06-15T09:30:00Z"
}
get/fields/farm/{farm_id}

Get fields by farm id

Get fields by farm id, each with its active crop count

Requires an Authorization: Bearer header.

Parameters

farm_idstringpathrequired

Response 200

fieldsField[]required
totalintegerrequired
GET /fields/farm/{farm_id}
curl -X GET "https://api.cropsense.africa/fields/farm/3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Example response · 200
{
  "fields": [
    {
      "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
      "cropsense_field_id": "cropsense_field_id",
      "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
      "name": "Green Valley Farm",
      "field_type": "open_field",
      "field_status": "fallow",
      "irrigation_type": "rainfed",
      "latitude": 1.5,
      "longitude": 1.5,
      "area_ha": 1.5,
      "address": "address",
      "city": "city",
      "state": "state",
      "country": "Kenya",
      "attributes": {},
      "geom": {},
      "is_active": true,
      "active_crop_count": 1,
      "created_at": "2026-06-15T09:30:00Z",
      "updated_at": "2026-06-15T09:30:00Z"
    }
  ],
  "total": 1
}
get/fields/at

Find your fields at a GPS location

Fields you can access that contain the point (distance_m 0) or, with radius_m, lie within that distance of it, nearest first. At most 20.

Requires an Authorization: Bearer header.

Parameters

latitudenumberqueryrequired
longitudenumberqueryrequired
radius_mnumberquery

Also match fields whose edge is within this many metres, to allow for GPS error. 0 matches only fields containing the point.

Response 200

fieldsFieldAtLocation[]required
totalintegerrequired
GET /fields/at
curl -X GET "https://api.cropsense.africa/fields/at?latitude=1.5&longitude=1.5&radius_m=0" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Example response · 200
{
  "fields": [
    {
      "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
      "cropsense_field_id": "cropsense_field_id",
      "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
      "farm_name": "farm_name",
      "name": "Green Valley Farm",
      "area_ha": 1.5,
      "latitude": 1.5,
      "longitude": 1.5,
      "distance_m": 1.5
    }
  ],
  "total": 1
}
post/fields/boundary/validate

Check a field boundary without creating a field

Report whether POST /fields/create would accept this boundary, with its area, centroid and any of your fields it overlaps. Always 200: a refused boundary comes back as valid=false with the reasons in `errors`. The country checks (field in Africa, same country as its farm) need a reverse geocode and are applied only at creation.

Requires an Authorization: Bearer header.

Request body

geomobjectrequired

GeoJSON Polygon or MultiPolygon, bare or wrapped in a Feature/FeatureCollection with one feature

exclude_field_idstringoptional

Response 200

validbooleanrequired
errorsBoundaryIssue[]optional
warningsBoundaryIssue[]optional
geometry_typestringoptional
area_hanumberoptional
latitudenumberoptional
longitudenumberoptional
overlapping_fieldsFieldOverlap[]optional
POST /fields/boundary/validate
curl -X POST "https://api.cropsense.africa/fields/boundary/validate" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "geom": {},
    "exclude_field_id": "exclude_field_id"
  }'
Example response · 200
{
  "valid": true,
  "errors": [
    {
      "code": "code",
      "message": "message"
    }
  ],
  "warnings": [
    {
      "code": "code",
      "message": "message"
    }
  ],
  "geometry_type": "geometry_type",
  "area_ha": 1.5,
  "latitude": 1.5,
  "longitude": 1.5,
  "overlapping_fields": [
    {
      "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
      "cropsense_field_id": "cropsense_field_id",
      "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
      "farm_name": "farm_name",
      "name": "Green Valley Farm",
      "area_ha": 1.5,
      "latitude": 1.5,
      "longitude": 1.5,
      "overlap_area_ha": 1.5,
      "overlap_pct_of_boundary": 1.5,
      "overlap_pct_of_field": 1.5
    }
  ]
}
post/fields/overlaps

Find your fields that overlap a boundary

Fields you can access that share at least 1 m² with the boundary, largest overlap first. 422 if the boundary is not a valid polygon.

Requires an Authorization: Bearer header.

Request body

geomobjectrequired

GeoJSON Polygon or MultiPolygon

exclude_field_idstringoptional

Response 200

fieldsFieldOverlap[]required
totalintegerrequired
POST /fields/overlaps
curl -X POST "https://api.cropsense.africa/fields/overlaps" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "geom": {},
    "exclude_field_id": "exclude_field_id"
  }'
Example response · 200
{
  "fields": [
    {
      "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
      "cropsense_field_id": "cropsense_field_id",
      "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
      "farm_name": "farm_name",
      "name": "Green Valley Farm",
      "area_ha": 1.5,
      "latitude": 1.5,
      "longitude": 1.5,
      "overlap_area_ha": 1.5,
      "overlap_pct_of_boundary": 1.5,
      "overlap_pct_of_field": 1.5
    }
  ],
  "total": 1
}
post/fields/within

Find your fields inside an area

Fields you can access in a polygon or bounding box, ordered by farm and field name. `total` counts every match; `fields` holds at most `limit`.

Requires an Authorization: Bearer header.

Request body

geomobjectoptional
bboxnumber[]optional
matchenum<string>optional

intersects: any part of the field is in the area. within: the whole field is.

limitintegeroptional

Response 200

fieldsFieldMatchSummary[]required
totalintegerrequired

Matching fields, which may exceed the number returned

POST /fields/within
curl -X POST "https://api.cropsense.africa/fields/within" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "geom": {},
    "bbox": [
      1.5
    ],
    "match": "intersects",
    "limit": 100
  }'
Example response · 200
{
  "fields": [
    {
      "field_id": "8b6e1a2f-2d4c-4e9a-9b0f-1c7d3e5a6f42",
      "cropsense_field_id": "cropsense_field_id",
      "farm_id": "3fa2c9e1-6b3a-4d2e-9c11-4a8e5f9d2b7a",
      "farm_name": "farm_name",
      "name": "Green Valley Farm",
      "area_ha": 1.5,
      "latitude": 1.5,
      "longitude": 1.5
    }
  ],
  "total": 1
}