integrity
5 operations
GET /v1/alertsAlerts of the tenantPOST /v1/alerts/{id}/resolveResolve an alertPOST /v1/envelopes/{id}/reviewApprove or reject a quarantined envelopeGET /v1/quarantineEnvelopes held for reviewGET /v1/volumes/{growing_area}/{season}Declared volume of a growing area and season
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
| Name | In | Type | Description |
|---|---|---|---|
alloptional | query | string |
|
kindoptional | query | string | Only alerts of this kind ( |
severityoptional | query | string | Only alerts of this severity ( |
device_idoptional | query | string | Only alerts about this device. |
limitoptional | query | integer | Page size: 1 to 200 alerts (default 200). |
cursoroptional | query | string | The previous page's |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | array<Alert>application/json | Alerts. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Next-Cursor | 200 | string | The |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
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
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | The alert id. |
Idempotency-Keyoptional | header | string | 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 |
Request body
AlertResolution (required)
Media type: application/json
Example request · application/json
{
"note": "Scale replaced; the missing readings were re-entered by hand."
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | Alertapplication/json | The alert, resolved (or as it was, when it already was). |
| 400 | Errorapplication/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. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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. |
| 404 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running ( |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
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
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Envelope id. |
Idempotency-Keyoptional | header | string | 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 |
Request body
ReviewRequest (required)
Media type: application/json
Example request · application/json
{
"decision": "approve",
"note": "weighed twice, scale re-calibrated"
}Responses
| Status | Type | Description |
|---|---|---|
| 200 | ReviewResultapplication/json | The new status. |
| 400 | Errorapplication/json | decision is not approve or reject, or the envelope is not quarantined; or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 404 | Errorapplication/json | No such envelope for this tenant. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The Idempotency-Key's first request is still running (retry after |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 422 | Errorapplication/json | The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
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
| Status | Type | Description |
|---|---|---|
| 200 | array<QuarantinedEnvelope>application/json | Quarantined envelopes. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
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
| Name | In | Type | Description |
|---|---|---|---|
growing_arearequired | path | string | Growing area code. |
seasonrequired | path | string | Season label (the calendar year by default). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | Volumeapplication/json | Totals. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
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"
}