Delete Semantics
All delete endpoints in the FDM REST API use the existing hard-delete behavior of the corresponding fdm-core function. There is no soft-delete, trash, or undo — deletions are permanent and cascade to child resources.
All delete operations are permanent. There is no way to recover deleted data. Confirm resource identifiers carefully before calling a delete endpoint.
Required authorization
All delete operations require at least the advisor role on the resource being deleted (or the parent resource for child-owned resources). fdm-core uses the write action for delete permission checks.
Idempotency
Delete endpoints are idempotent in effect — deleting a resource that is already gone leaves the system in the same state. However, repeated calls may return different HTTP status codes: the first delete returns 204, subsequent calls return 404 not-found. Design automation scripts to treat 404 as a success when the goal is to ensure the resource is gone.
Cascade behavior
DELETE /api/farms/{b_id_farm} — removeFarm
Deletes the farm and all resources owned by it, in order:
- All fields associated with the farm (each field is deleted via the field cascade below).
- All fertilizer acquiring records for the farm.
- All fertilizer picking records for farm-custom fertilizers.
- All derogation records for the farm.
- All authorization roles for the farm (principal access entries).
- The farm record itself.
Authorization check: write on farm.
DELETE /api/fields/{b_id} — removeField
Deletes the field and all resources owned by it, in order:
- All cultivations for the field (each cultivation is deleted via the cultivation cascade below).
- All soil sampling records for the field.
- All soil analysis records for the field.
- The field acquiring and field discarding records.
- All authorization roles for the field.
- The field record itself.
Authorization check: write on field.
DELETE /api/cultivations/{b_lu} — removeCultivation
Deletes the cultivation and directly associated records. Returns 404 if the cultivation does not exist.
- All harvest analyses linked to the cultivation's harvestable records.
- All harvestable sampling records.
- All cultivation harvesting records.
- The cultivation ending record.
- The cultivation starting record (field link).
- The cultivation record itself.
Authorization check: write on cultivation.
Note: Fertilizer applications linked to a cultivation are removed as part of the field delete cascade, not the cultivation delete. Deleting a cultivation alone does not remove its fertilizer application records.
DELETE /api/soil-analyses/{a_id} — removeSoilAnalysis
Deletes the soil analysis and its sampling records:
- The soil sampling record linked to this analysis.
- The soil analysis record itself.
Authorization check: write on soil_analysis.
Returns 404 if the analysis does not exist.
Summary table
| Endpoint | Hard delete | Cascades to | Idempotent | Auth required |
|---|---|---|---|---|
DELETE /api/farms/{b_id_farm} | ✅ | Fields → cultivations → harvests → soil analyses → fertilizers → derogations | ✅ | advisor or owner on farm |
DELETE /api/fields/{b_id} | ✅ | Cultivations → harvests, soil analyses | ✅ | advisor or owner on field |
DELETE /api/cultivations/{b_lu} | ✅ | Harvests and harvest analyses | ✅ | advisor or owner on cultivation |
DELETE /api/soil-analyses/{a_id} | ✅ | Soil sampling record | ✅ | advisor or owner on soil_analysis |