integrity
5 个操作
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
身份验证:cookie, bearer, oauth2 · OAuth2 作用域: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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
all可选 | query | string |
|
kind可选 | query | string | Only alerts of this kind ( |
severity可选 | query | string | Only alerts of this severity ( |
device_id可选 | query | string | Only alerts about this device. |
limit可选 | query | integer | Page size: 1 to 200 alerts (default 200). |
cursor可选 | query | string | The previous page's |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
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 |
响应示例
响应 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
}
]响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/alerts/{id}/resolve
Resolve an alert
身份验证:cookie, bearer, oauth2 · OAuth2 作用域: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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | The alert id. |
Idempotency-Key可选 | 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 |
请求体
AlertResolution (必填)
媒体类型: application/json
请求示例 · application/json
{
"note": "Scale replaced; the missing readings were re-entered by hand."
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
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 |
响应示例
响应 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
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown
{
"error": "unknown fields: reason",
"code": "unknown_fields"
}响应 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"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 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"
}响应 404 · application/json
{
"error": "not found: 7",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/envelopes/{id}/review
Approve or reject a quarantined envelope
身份验证:cookie, bearer, oauth2 · OAuth2 作用域: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.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Envelope id. |
Idempotency-Key可选 | 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 |
请求体
ReviewRequest (必填)
媒体类型: application/json
请求示例 · application/json
{
"decision": "approve",
"note": "weighed twice, scale re-calibrated"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
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 |
响应示例
响应 200 · application/json
{
"id": "3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
"status": "accepted"
}响应 400 · application/json · bad_decision
{
"error": "decision must be 'approve' or 'reject'",
"code": "decision_must_be_approve_or_reject"
}响应 400 · application/json · not_quarantined
{
"error": "envelope is accepted, not quarantined",
"code": "envelope_is_accepted_not_quarantined"
}响应 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}响应 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"
}响应 404 · application/json
{
"error": "not found: 3f2b8f0e-6a39-4f7e-9b1e-0d6c1c5e7a11",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}响应 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/quarantine
Envelopes held for review
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · listQuarantine
Up to 200 quarantined envelopes of the tenant, oldest received first. Approve or reject each with the review route.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
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 |
响应示例
响应 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"
]
}
]响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/volumes/{growing_area}/{season}
Declared volume of a growing area and season
身份验证:cookie, bearer, oauth2 · OAuth2 作用域: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).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
growing_area必填 | path | string | Growing area code. |
season必填 | path | string | Season label (the calendar year by default). |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 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. |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
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 |
响应示例
响应 200 · application/json
{
"growing_area": "VN-DL-SR-0123",
"season": "2026",
"declared_kg": 1200.5,
"cap_kg": 20000
}响应 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}响应 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}响应 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}响应 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}