CropPath for developers

API reference

integrity

5 operations

GET /v1/alerts

Alerts of the tenant

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · listAlerts

Up to limit alerts (default and most 200), newest first. Open alerts only unless all=1. A platform admin also gets the platform alerts that belong to no tenant (tenant null), such as facility_code_conflict from the facility backfill. B9 (#21): kind, severity and device_id keep the alerts equal to each one given; when more alerts follow, the X-Next-Cursor header carries the next page's cursor (the body stays an array). These parameters and the header are not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before them, and the 400 response keeps its 0.2.0 form: a bad kind, severity, device_id, limit or cursor also answers 400 (bad_kind, bad_severity, bad_device_id, bad_limit, bad_cursor).

Parameters

NameInTypeDescription
all
optional
querystring

1 includes resolved alerts; any other value or none returns open alerts only.

kind
optional
querystring

Only alerts of this kind (seq_gap, quarantined, label_clone_suspected, ...).

severity
optional
querystring

Only alerts of this severity (info, warning, high).

device_id
optional
querystring

Only alerts about this device.

limit
optional
queryinteger

Page size: 1 to 200 alerts (default 200).

cursor
optional
querystring

The previous page's X-Next-Cursor header.

Responses

StatusTypeDescription
200array<Alert>
application/json

Alerts.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Next-Cursor200string

The cursor of the next page, sent only when more alerts follow.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
[
  {
    "id": 7,
    "tenant": "coop-dl",
    "kind": "quarantined",
    "severity": "warning",
    "device_id": "scale-1",
    "envelope_id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
    "detail": {
      "reasons": [
        "volume_exceeds_cap"
      ]
    },
    "created_at": 1790000000.5,
    "resolved_at": null
  }
]
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/alerts/{id}/resolve

Resolve an alert

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: review · resolveAlert

B9 (#21): resolves one alert by hand, with an optional note. Idempotent: an alert already resolved is answered as it is (200, its first resolved_at) and nothing changes. Audited (alert.resolve, in the same transaction, also for an alert already resolved, with already_resolved; the note is kept in the audit row, the alert has no field for it). Allowed for tenant_admin and platform_admin acting for the tenant; a platform admin also resolves the platform alerts that belong to no tenant (tenant null), whose audit row belongs to no company. Another tenant's alert answers like a missing one. Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Parameters

NameInTypeDescription
id
required
pathstring

The alert id.

Idempotency-Key
optional
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

AlertResolution (required)

Media type: application/json

Example request · application/json
{
  "note": "Scale replaced; the missing readings were re-entered by hand."
}

Responses

StatusTypeDescription
200Alert
application/json

The alert, resolved (or as it was, when it already was).

400Error
application/json

Invalid JSON, an unknown field or a note that is not a string of at most 500 characters, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (only tenant_admin and platform_admin), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left.

404Error
application/json

No such alert of this tenant (another tenant's, or a platform alert for anyone but a platform admin, answers like a missing one).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "id": 7,
  "tenant": "coop-dl",
  "kind": "seq_gap",
  "severity": "warning",
  "device_id": "scale-1",
  "envelope_id": null,
  "detail": {
    "from": 4,
    "to": 6
  },
  "created_at": 1790000000.5,
  "resolved_at": 1790003600.5
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown
{
  "error": "unknown fields: reason",
  "code": "unknown_fields"
}
Response 400 · application/json · note
{
  "error": "note must be a string of at most 500 characters",
  "code": "note_must_be_a_string_of_at_most_500_characters"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 7",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/envelopes/{id}/review

Approve or reject a quarantined envelope

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: review · reviewEnvelope

Approving makes the envelope accepted (counted in volumes, queued for outbound delivery). Rejecting marks it rejected_after_review. An envelope of another tenant answers 404.

Parameters

NameInTypeDescription
id
required
pathstring

Envelope id.

Idempotency-Key
optional
headerstring

Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

ReviewRequest (required)

Media type: application/json

Example request · application/json
{
  "decision": "approve",
  "note": "weighed twice, scale re-calibrated"
}

Responses

StatusTypeDescription
200ReviewResult
application/json

The new status.

400Error
application/json

decision is not approve or reject, or the envelope is not quarantined; or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed).

404Error
application/json

No such envelope for this tenant.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The Idempotency-Key's first request is still running (retry after Retry-After seconds), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
  "status": "accepted"
}
Response 400 · application/json · bad_decision
{
  "error": "decision must be 'approve' or 'reject'",
  "code": "decision_must_be_approve_or_reject"
}
Response 400 · application/json · not_quarantined
{
  "error": "envelope is accepted, not quarantined",
  "code": "envelope_is_accepted_not_quarantined"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: 3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/quarantine

Envelopes held for review

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · listQuarantine

Up to 200 quarantined envelopes of the tenant, oldest received first. Approve or reject each with the review route.

Responses

StatusTypeDescription
200array<QuarantinedEnvelope>
application/json

Quarantined envelopes.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
[
  {
    "id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
    "device_id": "scale-1",
    "seq": 3,
    "kind": "event",
    "event_type": "receive",
    "event_time": "2026-09-30T08:00:00.000+07:00",
    "lot": "LOT-A",
    "growing_area": "VN-DL-SR-0123",
    "reasons": [
      "volume_exceeds_cap"
    ]
  }
]
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/volumes/{growing_area}/{season}

Declared volume of a growing area and season

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: aggregate_read · getVolume

Cross-tenant aggregate for one growing area: only totals, never other tenants' records. An unknown growing area or season answers 200, never 404: declared_kg is 0 when nothing is declared for that area and season, and cap_kg is null only for an unknown growing area or for an area a company added that CropPath has not approved yet (otherwise it is the area's area_ha times yield_kg_per_ha, whatever the season).

Parameters

NameInTypeDescription
growing_area
required
pathstring

Growing area code.

season
required
pathstring

Season label (the calendar year by default).

Responses

StatusTypeDescription
200Volume
application/json

Totals.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (interim tenant_admin or platform_admin guard until per-route policies land) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "growing_area": "VN-DL-SR-0123",
  "season": "2026",
  "declared_kg": 1200.5,
  "cap_kg": 20000
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}