CropPath for developers

All guides

Batch requests

Available

Create up to 1,000 fruits, cartons, carton contents, harvest declarations or growers in one request: all written, or nothing.

The five routes below take a batch of 1 to 1,000 items, each item by the rules of the matching single-item route.

POST /v1/sessions/{id}/fruits/batch          {"count": 200}
POST /v1/lots/{lot}/cartons/batch            {"count": 40}
POST /v1/lots/{lot}/carton-contents/batch    {"items": [{"carton": "C-014-0017", "fruits": ["Q-014-0129"], "net_mass_kg": 3.1}]}
POST /v1/harvests/batch                      {"items": [{"growing_area": "VN-DL-SR-0123", "harvest_date": "2026-09-27", "kg": 1820}]}
POST /v1/growers/batch                       {"items": [{"name": "Nguyễn Văn A", "cooperative": "HTX Đắk Lắk"}]}

A batch is written whole or not at all. Every invalid item is reported by its position (400 invalid_batch) and nothing is written; the first item the stored data refuses cancels the whole batch and is reported (batch_rejected). Correct the named items and send the whole batch again.

Send an Idempotency-Key with every batch. CropPath keeps the key with the batch for good, so a batch is never applied twice under one key, even after 24 hours.

curl -sS https://<host>/v1/lots/LO-260928-014/cartons/batch \
  -H "Authorization: Bearer $CROPPATH_TOKEN" \
  -H "Idempotency-Key: cartons-LO-260928-014-1" \
  -H "Content-Type: application/json" \
  -d '{"count": 40}'

Data sent in a batch is your company's statement and always counts as Self-declared: a harvest declared in a batch is stored with source self_declared. An item cannot carry a signature: an item with a field its route does not define is refused. For evidence to count higher, a device CropPath approved must send its signed envelope itself to POST /v1/ingest/<route>.

In the API reference