devices
27 个操作
GET /v1/commands/{id}State of a commandGET /v1/command-keysPublic keys of the platform command keyGET /v1/devicesDevices of the caller's tenant with their status read modelPOST /v1/devicesRegister a deviceGET /v1/devices/{id}One device with its status read modelPATCH /v1/devices/{id}Change a device's status or display fieldsGET /v1/devices/{id}/commandsCommands sent to one devicePOST /v1/devices/{id}/commandsSend a command to a deviceGET /v1/gatewaysGateways of the caller's tenantPOST /v1/gatewaysRegister a gatewayGET /v1/gateways/{id}/heartbeatA gateway's newest status heartbeatGET /v1/gateways/{id}/status-seriesA gateway's status time seriesGET /v1/keysDevice and gateway keys of the caller's tenantPOST /v1/keysRegister a public key for a device or gatewayPOST /v1/keys/{kid}/revokeRevoke a keyGET /v1/harvest-keysHarvest app registrations of the caller's tenantPOST /v1/harvest-keysAsk to register a harvest app install's keyGET /v1/harvest-keys/{kid}One harvest app registrationPOST /v1/harvest-keys/{kid}/approveApprove a pending harvest app registrationPOST /v1/harvest-keys/{kid}/rejectReject a pending harvest app registrationGET /v1/devices/{id}/placementsA device's placement versionsGET /v1/devices/{id}/calibrationsA device's calibrationsPOST /v1/devices/{id}/calibrationsRecord a device calibrationGET /v1/devices/{id}/metadataA device's metadataGET /v1/gateways/{id}/station-delegationsThe pending and active station sign-ins at a gatewayPOST /v1/gateways/{id}/station-delegationsSign in at an edge station (a one-time code to type there)POST /v1/station-delegations/{id}/revokeRevoke a station sign-in
GET /v1/commands/{id}
State of a command
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:command_read · getCommand
Status moves pending, sent, then succeeded or failed. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Command id. |
channel可选 | query | "0" | "1" | #242: |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Commandapplication/json | The recorded command. |
| 400 | Errorapplication/json |
|
| 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). |
| 404 | Errorapplication/json | No such command for this 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
"tenant": "coop-dl",
"site": "ph1",
"device_id": "knk-1",
"name": "set_model",
"params": {
"version": "m9"
},
"issued_by": "legacy-user",
"issued_at": 1790000000.5,
"status": "sent",
"result": null,
"completed_at": null
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}响应 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"
}响应 404 · application/json
{
"error": "not found: 6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/command-keys
Public keys of the platform command key
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_command · listCommandKeys
#242: the public part of the platform command key, which signs every actuation command document (ES256 over the RFC 8785 canonical JSON of the document without sig; the document's sig.kid names the key). A controller is provisioned with it to verify the commands it receives. An empty keys list when the server has no command key: every actuation command is then refused. Allowed for tenant_admin and platform_admin (acting for the tenant), and an operator through a signed-in session or an operator API client, as issuing a command; auditors and labs are refused. Not audited (a read of public key material). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CommandKeysapplication/json | The platform command keys (at most one today). |
| 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 (auditors, labs, an operator API token) 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
{
"keys": [
{
"kid": "platform-cmd-3b5e0c1d2a4f6e7d",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
}
}
]
}响应 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/devices
Devices of the caller's tenant with their status read model
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_read · listDevices
Devices ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only devices of its facilities: the device's facility, or its site when it has none).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
cursor可选 | query | string |
|
limit可选 | query | integer | Page size, 1 to 100. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | DevicePageapplication/json | One page of devices. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted 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
{
"items": [
{
"device_id": "knk-1",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"status": "active",
"display_name": "Knocker line 1",
"vendor_model": "SF-100",
"serial": "SF100-000123",
"created_at": 1790000000.5,
"commands": [
"calibrate",
"set_model",
"set_session"
],
"last_seen": 1790003600.25,
"max_seq": 412,
"last_model": "m1",
"firmware": "1.4.2",
"battery_pct": 87,
"battery_v": 3.92,
"last_calibrated_at": 1789990000,
"ready": true,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}
],
"next_cursor": null
}响应 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · bad_request_id
{
"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/devices
Register a device
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · createDevice
Registers an active device of the caller's tenant (never a body field). The id must be unused by every tenant's devices and gateways: an existing record is never replaced. Audited (device.create). Allowed for platform_admin and tenant_admin.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
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 |
请求体
DeviceCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"device_id": "knk-1",
"profile": "vn.agritrace.durian-knocker",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Knocker line 1",
"vendor_model": "SF-100",
"serial": "SF100-000123"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | Deviceapplication/json | The new device (never seen yet: no state, not ready). |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a malformed id or site, a profile that is not in the spec, a facility that is not one of the caller's tenant (missing and foreign alike), a value out of bounds, 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, 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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The id is used by a device or gateway (of any tenant; the owner is not revealed). Or the Idempotency-Key's first request is still running ( |
| 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 | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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 |
响应示例
响应 201 · application/json
{
"device_id": "knk-1",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"status": "active",
"display_name": "Knocker line 1",
"vendor_model": "SF-100",
"serial": "SF100-000123",
"created_at": 1790000000.5,
"commands": [
"calibrate",
"set_model",
"set_session"
],
"last_seen": null,
"max_seq": null,
"last_model": null,
"firmware": null,
"battery_pct": null,
"battery_v": null,
"last_calibrated_at": null,
"ready": false,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}响应 400 · application/json · invalid_device_id
{
"error": "invalid device_id: 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit",
"code": "invalid_device_id"
}响应 400 · application/json · unknown_profile
{
"error": "unknown profile",
"code": "unknown_profile"
}响应 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}响应 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"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · device_id_taken
{
"error": "device id taken",
"code": "device_id_taken"
}响应 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"
}响应 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}响应 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/devices/{id}
One device with its status read model
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_read · getDevice
Same roles as the list; an operator reads only devices of its facilities.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Deviceapplication/json | The device. |
| 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"device_id": "knk-1",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"status": "active",
"display_name": "Knocker line 1",
"vendor_model": "SF-100",
"serial": "SF100-000123",
"created_at": 1790000000.5,
"commands": [
"calibrate",
"set_model",
"set_session"
],
"last_seen": 1790003600.25,
"max_seq": 412,
"last_model": "m1",
"firmware": "1.4.2",
"battery_pct": 87,
"battery_v": 3.92,
"last_calibrated_at": 1789990000,
"ready": true,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}响应 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"
}响应 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/devices/{id}
Change a device's status or display fields
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · updateDevice
Sets status (active or inactive; ingest and the broker accept only active devices) and the display fields. The id, site, facility and profile cannot change. Audited (device.update). Allowed for platform_admin and tenant_admin.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
请求体
DeviceUpdate (必填)
媒体类型: application/json
请求示例 · application/json
{
"status": "inactive"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Deviceapplication/json | The device after the change. |
| 400 | Errorapplication/json | Invalid JSON, an empty body, a field that cannot change, a status other than active or inactive, a value out of bounds, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, 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 device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 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 | 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 | 413 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"device_id": "knk-1",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"profile": "vn.agritrace.durian-knocker",
"status": "inactive",
"display_name": "Knocker line 1",
"vendor_model": "SF-100",
"serial": "SF100-000123",
"created_at": 1790000000.5,
"commands": [
"calibrate",
"set_model",
"set_session"
],
"last_seen": 1790003600.25,
"max_seq": 412,
"last_model": "m1",
"firmware": "1.4.2",
"battery_pct": 87,
"battery_v": 3.92,
"last_calibrated_at": 1789990000,
"ready": false,
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · nothing_to_update
{
"error": "nothing to update",
"code": "nothing_to_update"
}响应 400 · application/json · field_not_editable
{
"error": "field not editable",
"code": "field_not_editable"
}响应 400 · application/json · invalid_status
{
"error": "invalid status: active or inactive",
"code": "invalid_status"
}响应 400 · application/json · bad_request_id
{
"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"
}响应 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: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/commands
Commands sent to one device
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:command_read · listDeviceCommands
The device's commands newest first (issued_at, then id), with keyset pagination (at most 200 per page). Same roles and scope as reading the device. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk). #372: name, status, from and to filter the commands (the irrigation cockpit's command log); not part of the partner SDK clients either. A filter given empty (?name=) is no filter: an empty query value is dropped, as for every parameter.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
cursor可选 | query | string |
|
limit可选 | query | integer | Page size, 1 to 200. |
channel可选 | query | "0" | "1" | #242: |
name可选 | query | string | #372: only the commands of this name (as the device profile declares it: |
status可选 | query | "accepted" | "aborted" | "completed" | "expired" | "failed" | "pending" | "rejected" | "sent" | "succeeded" | #372: only the commands in this state; 400 |
from可选 | query | string (date) | #372: only the commands issued from the start of this farm-local date (Asia/Ho_Chi_Minh), |
to可选 | query | string (date) | #372: only the commands issued up to the end of this farm-local date, |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | CommandPageapplication/json | One page of commands. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"items": [
{
"id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
"tenant": "coop-dl",
"site": "ph1",
"device_id": "knk-1",
"name": "set_model",
"params": {
"version": "m9"
},
"issued_by": "legacy-user",
"issued_at": 1790000000.5,
"status": "succeeded",
"result": {
"ok": true
},
"completed_at": 1790000003
}
],
"next_cursor": null
}响应 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}响应 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}响应 400 · application/json · bad_name
{
"error": "bad name: a command name",
"code": "bad_name"
}响应 400 · application/json · bad_status
{
"error": "bad status: accepted, aborted, completed, expired, failed, pending, rejected, sent, succeeded",
"code": "bad_status"
}响应 400 · application/json · bad_from
{
"error": "bad from: a date YYYY-MM-DD",
"code": "bad_from"
}响应 400 · application/json · bad_to
{
"error": "bad to: a date YYYY-MM-DD",
"code": "bad_to"
}响应 400 · application/json · bad_range
{
"error": "bad range: to is before from",
"code": "bad_range"
}响应 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"
}响应 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/commands
Send a command to a device
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_command · issueDeviceCommand
The command must be declared by the device profile and every param must be declared for it. The command is recorded before it is dispatched. A device of another tenant answers 404. #242: a command is issued only to an active, approved device reached by an active, approved key: one of its own, or that of an active, approved gateway at its site (409 device_not_approved otherwise, for every command). An actuation command (an irrigation controller's run_zone, a timed zone run, and set_program, a program lease) is sent as a command document signed with the platform command key (GET /v1/command-keys), which the controller verifies and enforces locally; every param it declares must be given within its declared range. Without a platform command key every actuation command is refused (503 command_signing_unavailable); config commands are not affected. A facility-scoped operator may issue calibrate, run_zone and set_program to a device of its facilities. A set_program whose program_version is not above the highest program_version of every set_program already recorded for the device (at any site, in any status) is refused (409 program_version_not_increasing): the controllers rely on strictly rising program versions per device. None of these refusals records a command, and the Idempotency-Key is not used up: a retry with the same key runs again. The 409 refusals and the 503 response are not part of the partner SDK clients (x-not-in-sdk).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device 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 |
请求体
CommandRequest (必填)
媒体类型: application/json
请求示例 · application/json
{
"name": "set_model",
"params": {
"version": "m9"
}
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 202 | CommandIssuedapplication/json | Recorded and handed to the transport. |
| 400 | Errorapplication/json | params is not an object, the command is not declared by the profile, a param is unknown, (#242) a param of the wrong type or outside its declared range or a required one missing, or the params are not strict JSON: a number that is not finite (NaN, Infinity) or a string holding U+0000 or a lone UTF-16 surrogate (U+D800-U+DFFF), anywhere in the params (invalid_params); 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 device for this tenant. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | #242: the device is not active and approved, or no active, approved key reaches it, neither one of its own nor that of an active, approved gateway at its site ( |
| 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. |
| 503 | Errorapplication/json | #242: an actuation command was refused because the server has no platform command key to sign it with ( |
响应头
| 名称 | 状态码 | 类型 | 说明 |
|---|---|---|---|
X-Request-Id | 202 | string | Request id: the caller's |
Idempotent-Replayed | 202 | "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 |
X-Request-Id | 503 | string | Request id: the caller's |
Retry-After | 503 | string | Seconds to wait before retrying. |
响应示例
响应 202 · application/json
{
"id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10"
}响应 400 · application/json · params
{
"error": "params must be an object",
"code": "params_must_be_an_object"
}响应 400 · application/json · undeclared
{
"error": "command 'reboot' not declared by profile vn.agritrace.durian-knocker",
"code": "command_reboot_not_declared_by_profile_vn_agritrace_durian_knocker"
}响应 400 · application/json · strict_json
{
"error": "invalid params: a string holds U+0000",
"code": "invalid_params"
}响应 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: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · device_not_approved
{
"error": "device not approved: knk-1",
"code": "device_not_approved"
}响应 409 · application/json · program_version_not_increasing
{
"error": "program version not increasing: 7 is not above 7, the device's highest",
"code": "program_version_not_increasing"
}响应 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"
}响应 503 · application/json
{
"error": "command signing unavailable",
"code": "command_signing_unavailable"
}GET /v1/gateways
Gateways of the caller's tenant
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · listGateways
Gateways ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor; gateways are site-wide, so operators are refused.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
cursor可选 | query | string |
|
limit可选 | query | integer | Page size, 1 to 100. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | GatewayPageapplication/json | One page of gateways. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted 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
{
"items": [
{
"gateway_id": "gw-01",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Packing hall gateway",
"status": "active",
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}
],
"next_cursor": null
}响应 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · bad_request_id
{
"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/gateways
Register a gateway
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · createGateway
Registers an active gateway of the caller's tenant. The id must be unused by every tenant's gateways and devices: an existing record is never replaced. Audited (gateway.create). Allowed for platform_admin and tenant_admin.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
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 |
请求体
GatewayCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"gateway_id": "gw-01",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Packing hall gateway"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | Gatewayapplication/json | The new gateway. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a malformed id or site, a facility that is not one of the caller's tenant, a value out of bounds, 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, 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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The id is used by a gateway or device (of any tenant; the owner is not revealed). Or the Idempotency-Key's first request is still running ( |
| 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 | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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 |
响应示例
响应 201 · application/json
{
"gateway_id": "gw-01",
"tenant": "coop-dl",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Packing hall gateway",
"status": "active",
"approval": "approved",
"approval_reason": null,
"approval_at": 1790000100
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}响应 400 · application/json · invalid_gateway_id
{
"error": "invalid gateway_id: 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit",
"code": "invalid_gateway_id"
}响应 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}响应 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"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · gateway_id_taken
{
"error": "gateway id taken",
"code": "gateway_id_taken"
}响应 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"
}响应 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}响应 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/gateways/{id}/heartbeat
A gateway's newest status heartbeat
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · getGatewayHeartbeat
#24: the newest status heartbeat of a gateway of the caller's tenant. A gateway signs a status envelope about itself every 30 s by default (profile vn.agritrace.gateway, /developers/downloads/profiles/gateway.json: its gateway id as device.id, on the ingest route {tenant}/{site}/{gateway id}/status); the server keeps the newest one of each gateway, never as an envelope: ordered by seq, but a signed heartbeat with a lower seq and a later time is kept (a reset gateway) and a signed one with a higher seq and an earlier time is superseded; one dated past the server's maximum future skew is rejected (400 future_timestamp). heartbeat is null until the gateway sent one. A value the heartbeat did not carry is null. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Gateway id. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | GatewayHeartbeatStatusapplication/json | The gateway's newest heartbeat, or null. |
| 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such gateway for this tenant: a gateway of another tenant answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"gateway_id": "gw-01",
"heartbeat": {
"received_at": 1790100030.25,
"time": "2026-09-23T08:00:30.000+00:00",
"seq": 2881,
"signed": true,
"outbox_depth": 3,
"dead_letter_count": 0,
"link": {
"state": "connected"
},
"peripherals_ready": [
{
"device": "knk-1",
"ready": true
},
{
"device": "scale-1",
"ready": false
}
]
}
}响应 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"
}响应 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/status-series
A gateway's status time series
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · getGatewayStatusSeries
#128: the status series of a gateway of the caller's tenant. The server stores at most one of the gateway's status heartbeats a minute (the first one it keeps in each UTC minute of reception) and adds it to the gateway's hourly rollup. grain=minute returns those samples; hourly (the default) the hourly rollups; daily the hourly rollups merged per UTC day. A rollup gives the number of samples, for the outbox depth, the dead-letter count and the devices listed and ready the minimum, maximum, mean (null when no sample carried the value) and count of the samples that carried it, and the samples per link state. Samples are kept 30 days and hourly rollups 2 years; the range is clipped to what is kept (from in the answer is the start actually read, aligned down to the grain) and is at most 1 day for minute, 31 days for hourly and 731 days for daily (range_too_long). The newest heartbeat itself is getGatewayHeartbeat. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Gateway id. |
grain可选 | query | "minute" | "hourly" | "daily" | A sample a minute, or the hourly or daily rollups. |
from可选 | query | string | Start: an ISO 8601 date or date-time (+07:00 without an offset). Default: 1 day (minute), 7 days (hourly) or 365 days (daily) before |
to可选 | query | string | End (excluded), as |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | GatewayStatusSeriesapplication/json | The series, oldest first. |
| 400 | Errorapplication/json | A bad grain or time, a range whose start is not before its end or longer than the grain allows, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such gateway for this tenant: a gateway of another tenant answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"gateway_id": "gw-01",
"grain": "hourly",
"bucket_s": 3600,
"from": 1790100000,
"to": 1790107200,
"items": [
{
"bucket_start": 1790100000,
"samples": 60,
"outbox_depth": {
"min": 0,
"max": 12,
"mean": 2.5,
"count": 60
},
"dead_letter_count": {
"min": 0,
"max": 0,
"mean": 0,
"count": 60
},
"peripherals_ready": {
"min": 1,
"max": 2,
"mean": 1.9,
"count": 60
},
"peripherals_total": {
"min": 2,
"max": 2,
"mean": 2,
"count": 60
},
"link": {
"connected": 58,
"disconnected": 2,
"unknown": 0
}
}
]
}响应 400 · application/json · bad_grain
{
"error": "bad grain: minute, hourly or daily",
"code": "bad_grain"
}响应 400 · application/json · bad_from
{
"error": "bad from",
"code": "bad_from"
}响应 400 · application/json · bad_to
{
"error": "bad to",
"code": "bad_to"
}响应 400 · application/json · bad_range
{
"error": "bad range: from must be before to",
"code": "bad_range"
}响应 400 · application/json · range_too_long
{
"error": "range too long",
"code": "range_too_long"
}响应 400 · application/json · bad_request_id
{
"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"
}响应 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/keys
Device and gateway keys of the caller's tenant
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:tenant_read · listKeys
Keys ordered by kid, with keyset pagination (at most 100 per page); a key belongs to its owner's tenant. With owner, only that device's or gateway's keys. Never returns key material, only fingerprints. Allowed for platform_admin, tenant_admin and auditor.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
owner可选 | query | string | A device or gateway id of the caller's tenant. |
cursor可选 | query | string |
|
limit可选 | query | integer | Page size, 1 to 100. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | KeyPageapplication/json | One page of keys. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id, or a malformed owner. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json |
|
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"items": [
{
"kid": "knk-1-2026",
"owner_type": "device",
"owner_id": "knk-1",
"status": "active",
"created_at": 1790000000.5,
"revoked_at": null,
"revoke_reason": null,
"revoked_by": null,
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"approval": "approved"
}
],
"next_cursor": null
}响应 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · invalid_owner
{
"error": "invalid owner: a device or gateway id",
"code": "invalid_owner"
}响应 400 · application/json · bad_request_id
{
"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"
}响应 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/keys
Register a public key for a device or gateway
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · createKey
Adds an active key. The PEM must be one PUBLIC KEY block holding an EC P-256 SubjectPublicKeyInfo (private keys, certificates, other curves and trailing data are refused); the canonical PEM is stored. The kid must be unused by every tenant and not reserved by the deployed seed (provisioning reserves every seed kid). #201: the key waits for a platform admin's approval whatever its owner's (an approved device or gateway is listed in the pending queue again); until then evidence it signs counts as Self-declared. Audited (key.create; the row keeps the kid and fingerprint, never the PEM). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
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 |
请求体
KeyCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"kid": "knk-1-2026",
"owner_type": "device",
"owner_id": "knk-1",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhaFFjV3QAoRFgCMO0lO2g8XMPeCX\n0MemwTpR6thzbANTI0unLVbZ1TwEmvZdARGAPji8g2MlIm1UAXv95sLWcg==\n-----END PUBLIC KEY-----\n"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | Keyapplication/json | The new key. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, a malformed kid or owner, an owner type other than device or gateway, an unacceptable PEM, 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, 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 | The owner is not a device or gateway of the caller's tenant (missing and foreign alike). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The kid is used (in any tenant; the owner is not revealed) or reserved by the seed; both answer alike. Or the Idempotency-Key's first request is still running ( |
| 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 | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
响应示例
响应 201 · application/json
{
"kid": "knk-1-2026",
"owner_type": "device",
"owner_id": "knk-1",
"status": "active",
"created_at": 1790000000.5,
"revoked_at": null,
"revoke_reason": null,
"revoked_by": null,
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"approval": "pending"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}响应 400 · application/json · invalid_kid
{
"error": "invalid kid: 1 to 128 letters, digits, '.', '_', ':' or '-', starting with a letter or digit",
"code": "invalid_kid"
}响应 400 · application/json · invalid_owner_type
{
"error": "invalid owner_type: device or gateway",
"code": "invalid_owner_type"
}响应 400 · application/json · invalid_public_key_pem
{
"error": "invalid public_key_pem: an EC P-256 public key as PEM SubjectPublicKeyInfo",
"code": "invalid_public_key_pem"
}响应 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: knk-1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}响应 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"
}POST /v1/keys/{kid}/revoke
Revoke a key
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · revokeKey
Marks the key revoked with its reason; ingest refuses it from then on. compromise also raises one high-severity key_compromised alert for the tenant. A revoked key cannot be revoked again (the first reason and time stay). Audited (key.revoke). Allowed for platform_admin and tenant_admin. Step-up (#87): a signed-in session of an account with two-step sign-in must have confirmed a code from its authenticator app (or a backup code) within the last 5 minutes and its password within the last 10 minutes, else 401 mfa_step_up_required before anything is done (no audit row): confirm both with POST /v1/auth/reauth, then repeat the request. A session of an account without two-step sign-in, API tokens and API clients are served as before.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
kid必填 | path | string | Key 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 |
请求体
KeyRevoke (必填)
媒体类型: application/json
请求示例 · application/json
{
"reason": "rotation"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Keyapplication/json | The key after revocation. |
| 400 | Errorapplication/json | Invalid JSON, a reason other than rotation or compromise, 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. Or a session of an account with two-step sign-in whose code was last confirmed more than 5 minutes ago, or its password more than 10 minutes ago ( |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, 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 key for this tenant: a key of another tenant's device or gateway answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The key is already revoked. Or the Idempotency-Key's first request is still running ( |
| 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
{
"kid": "knk-1-2026",
"owner_type": "device",
"owner_id": "knk-1",
"status": "revoked",
"created_at": 1790000000.5,
"revoked_at": 1790086400,
"revoke_reason": "rotation",
"revoked_by": "admin@coop.example",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"approval": "approved"
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · invalid_reason
{
"error": "invalid reason: rotation or compromise",
"code": "invalid_reason"
}响应 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: knk-1-2026",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · key_already_revoked
{
"error": "key already revoked",
"code": "key_already_revoked"
}响应 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/harvest-keys
Harvest app registrations of the caller's tenant
身份验证:cookie, bearer · listHarvestKeys
#160: registrations ordered by kid, with keyset pagination (at most 100 per page). An operator sees only those of its facilities. Allowed for platform_admin, tenant_admin, auditor and operator (its facilities).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
cursor可选 | query | string |
|
limit可选 | query | integer | Page size, 1 to 100. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | HarvestKeyPageapplication/json | One page of registrations. |
| 400 | Errorapplication/json | A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted 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
{
"items": [
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "pending",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": null,
"decided_at": null,
"revoked_at": null,
"revoke_reason": null
}
],
"next_cursor": null
}响应 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}响应 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}响应 400 · application/json · bad_request_id
{
"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/harvest-keys
Ask to register a harvest app install's key
身份验证:cookie, bearer · registerHarvestKey
#160: the harvest app (/harvest) generated a non-extractable ECDSA P-256 key and sends its public half. The registration is pending until a tenant admin approves or rejects it. Sending the same key again for the same facility answers the stored registration with 200, whatever its status. Audited (harvest_key.register, with the kid, device, facility and fingerprint; never the PEM). Allowed for platform_admin, tenant_admin and operator (its facilities).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
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 |
请求体
HarvestKeyRegister (必填)
媒体类型: application/json
请求示例 · application/json
{
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone"
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | HarvestKeyapplication/json | The same key was registered before for this facility: its registration, unchanged. |
| 201 | HarvestKeyapplication/json | The new pending registration. |
| 400 | Errorapplication/json | Invalid JSON, an unknown field, an unacceptable PEM, a facility that is not one of the caller's tenant within its scope, an invalid label, 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, 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). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The key is registered by another tenant or for another facility (whose is never said), or the derived device or key id is taken. Or the Idempotency-Key's first request is still running ( |
| 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 | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 | 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
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "approved",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": "admin@coop.example",
"decided_at": 1790003600,
"revoked_at": null,
"revoke_reason": null
}响应 201 · application/json
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "pending",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": null,
"decided_at": null,
"revoked_at": null,
"revoke_reason": null
}响应 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}响应 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}响应 400 · application/json · invalid_public_key_pem
{
"error": "invalid public_key_pem: an EC P-256 public key as PEM SubjectPublicKeyInfo",
"code": "invalid_public_key_pem"
}响应 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}响应 400 · application/json · invalid_label
{
"error": "invalid label: 1 to 100 characters without control characters",
"code": "invalid_label"
}响应 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"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · key_already_registered
{
"error": "key already registered",
"code": "key_already_registered"
}响应 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}响应 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"
}响应 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}响应 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/harvest-keys/{kid}
One harvest app registration
身份验证:cookie, bearer · getHarvestKey
#160: the registration's state; the app polls it while it waits for approval. Allowed for platform_admin, tenant_admin, auditor and operator (its facilities).
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
kid必填 | path | string | Key id of the registration. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | HarvestKeyapplication/json | The registration. |
| 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such registration for this tenant and scope: another tenant's, or one of a facility outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "approved",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": "admin@coop.example",
"decided_at": 1790003600,
"revoked_at": null,
"revoke_reason": 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"
}响应 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys/{kid}/approve
Approve a pending harvest app registration
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · approveHarvestKey
#160: a tenant admin approved the registration (final). The install's device (profile vn.agritrace.harvest-app, active, at the registration's facility) and its active device key are created in the same transaction; ingest accepts its signed harvest envelopes from then on. The deciding actor is the principal. Audited (harvest_key.approve). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
kid必填 | path | string | Key id of the registration. |
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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | HarvestKeyapplication/json | The registration, approved. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, 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 registration for this tenant and scope: another tenant's, or one of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The registration is no longer pending, or (approval) its device or key id was taken since. Or 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
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "approved",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": "admin@coop.example",
"decided_at": 1790003600,
"revoked_at": null,
"revoke_reason": null
}响应 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: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}响应 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}响应 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/harvest-keys/{kid}/reject
Reject a pending harvest app registration
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · rejectHarvestKey
#160: a tenant admin rejected the registration (final). No device or key is created; the install makes a new key. The deciding actor is the principal. Audited (harvest_key.reject). Allowed for platform_admin and tenant_admin.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
kid必填 | path | string | Key id of the registration. |
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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | HarvestKeyapplication/json | The registration, rejected. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, 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 registration for this tenant and scope: another tenant's, or one of a facility outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The registration is no longer pending, or (approval) its device or key id was taken since. Or 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
{
"kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
"device_id": "harvest-19fcfa6012e7f761a1f1e408",
"tenant": "coop-dl",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone",
"status": "rejected",
"fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
"fingerprint": "19fc…e0d9",
"requested_by": "op@coop.example",
"requested_at": 1790000000.5,
"decided_by": "admin@coop.example",
"decided_at": 1790003600,
"revoked_at": null,
"revoke_reason": null
}响应 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: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}响应 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}响应 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"
}GET /v1/devices/{id}/placements
A device's placement versions
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_read · listDevicePlacements
SENS-A2 (#225): every placement version CropPath recorded for a device of the company, newest first, with the growing area it is bound to, the surveyed install point and the commissioning record. Same roles as reading the device; an operator reads only devices of its facilities. recorded_by (who at CropPath recorded it) is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | DevicePlacementsapplication/json | The device's placement versions. |
| 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"device_id": "soil-07",
"registered_before_placements": false,
"items": [
{
"device_id": "soil-07",
"version": 2,
"mobility": "fixed",
"key_protection": "hardware",
"gnss": false,
"growing_area": "VN-TG-CL-0042",
"lat": 10.3512345,
"lon": 106.1234567,
"accuracy_m": 3.5,
"fix_at": 1790100000,
"installed_at": 1790100600,
"installer": "Nguyen Van A",
"photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
"depth_cm": 30,
"sensor_serial": "RS485-4IN1-00172",
"note": "Moved to block B after replanting",
"removed_at": null,
"recorded_at": 1790101000,
"valid_until": null
},
{
"device_id": "soil-07",
"version": 1,
"mobility": "fixed",
"key_protection": "hardware",
"gnss": false,
"growing_area": "VN-TG-CL-0042",
"lat": 10.3509876,
"lon": 106.1229876,
"accuracy_m": 4,
"fix_at": 1780000000,
"installed_at": 1780000600,
"installer": "Nguyen Van A",
"photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
"depth_cm": 30,
"sensor_serial": "RS485-4IN1-00172",
"note": null,
"removed_at": null,
"recorded_at": 1790101000,
"valid_until": 1790100600
}
]
}响应 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"
}响应 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/calibrations
A device's calibrations
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_read · listDeviceCalibrations
SENS-B1d (#234): every calibration recorded for a device of the company, newest first, with the one that supersedes each (superseded_by). sensor_serial lists one probe's only. Same roles as reading the device; an operator reads only devices of its facilities. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
sensor_serial可选 | query | string | Only the calibrations of this probe serial (1 to 100 characters). |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | Calibrationsapplication/json | The device's calibrations. |
| 400 | Errorapplication/json | A bad |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"device_id": "soil-07",
"items": [
{
"id": 12,
"device_id": "soil-07",
"sensor_serial": "RS485-4IN1-00172",
"capability": "soil.ph",
"calibrated_at": 1790000000,
"method": "ph_buffers",
"reference_values": {
"buffers_ph": [
4.01,
7,
10.01
]
},
"coefficients": {
"offset": -0.03,
"slope": 0.987
},
"performer": "Can Tho soil laboratory",
"accreditation": "iso17025_lab",
"certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
"valid_until": 1805552000,
"supersedes": null,
"created_at": 1790001000,
"created_by": "admin@coop.example",
"superseded_by": null
}
]
}响应 400 · application/json · sensor_serial
{
"error": "bad sensor_serial",
"code": "bad_sensor_serial"
}响应 400 · application/json · bad_request_id
{
"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"
}响应 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/calibrations
Record a device calibration
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_admin · recordDeviceCalibration
SENS-B1d (#234): a company admin, or a platform admin acting for the company (X-Tenant), records a calibration of one of the company's devices, with its certificate (uploaded first with PUT /v1/attachments/{sha256}, or sent in certificate). Calibrations are append-only: a correction is a new calibration that names the one it corrects (supersedes); the corrected one is kept. Audited (device.calibration) in the company's activity log. Allowed for tenant_admin and platform_admin (and an API client with device_admin). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device 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 |
请求体
CalibrationCreate (必填)
媒体类型: application/json
请求示例 · application/json
{
"sensor_serial": "RS485-4IN1-00172",
"capability": "soil.ph",
"calibrated_at": 1790000000,
"method": "ph_buffers",
"reference_values": {
"buffers_ph": [
4.01,
7,
10.01
]
},
"coefficients": {
"offset": -0.03,
"slope": 0.987
},
"performer": "Can Tho soil laboratory",
"accreditation": "iso17025_lab",
"certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
"valid_until": 1805552000
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | Calibrationapplication/json | The calibration recorded. |
| 400 | Errorapplication/json | An unknown, missing or malformed field (a |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods), or company read-only (the company is leaving CropPath or has left; nothing changes). |
| 404 | Errorapplication/json | No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The calibration named by |
| 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 | 201 | string | Request id: the caller's |
Idempotent-Replayed | 201 | "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 |
响应示例
响应 201 · application/json
{
"id": 12,
"device_id": "soil-07",
"sensor_serial": "RS485-4IN1-00172",
"capability": "soil.ph",
"calibrated_at": 1790000000,
"method": "ph_buffers",
"reference_values": {
"buffers_ph": [
4.01,
7,
10.01
]
},
"coefficients": {
"offset": -0.03,
"slope": 0.987
},
"performer": "Can Tho soil laboratory",
"accreditation": "iso17025_lab",
"certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
"valid_until": 1805552000,
"supersedes": null,
"created_at": 1790001000,
"created_by": "admin@coop.example",
"superseded_by": null
}响应 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}响应 400 · application/json · missing_field
{
"error": "missing field: valid_until",
"code": "missing_field"
}响应 400 · application/json · valid_until
{
"error": "invalid valid_until: after calibrated_at",
"code": "invalid_valid_until"
}响应 400 · application/json · hash_mismatch
{
"error": "certificate hash mismatch: the certificate does not hash to certificate_sha256",
"code": "certificate_hash_mismatch"
}响应 400 · application/json · unknown_certificate
{
"error": "unknown certificate_sha256: upload the certificate (PDF, JPEG or PNG) first",
"code": "unknown_certificate_sha256"
}响应 400 · application/json · unknown_supersedes
{
"error": "unknown supersedes: not a calibration of this device",
"code": "unknown_supersedes"
}响应 400 · application/json · bad_request_id
{
"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"
}响应 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"
}响应 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · superseded
{
"error": "calibration superseded: correct the record that superseded it",
"code": "calibration_superseded"
}响应 409 · application/json · idempotency_in_progress
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}响应 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/devices/{id}/metadata
A device's metadata
身份验证:cookie, bearer, oauth2 · OAuth2 作用域:device_read · getDeviceMetadata
SENS-B1d (#234): a device's placement version in force (#225) and its calibrations not superseded: the document an EPCIS deviceMetadata link of the device's readings can name later (/v1/devices/{id}/metadata on this deployment's origin). For the device's company (the roles that read the device; an operator only for devices of its facilities) and platform admins acting for it; never public, and another company's device answers 404. recorded_by of the placement is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Device id. |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | DeviceMetadataapplication/json | The device's metadata. |
| 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 or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one. |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"device_id": "soil-07",
"placement": {
"device_id": "soil-07",
"version": 2,
"mobility": "fixed",
"key_protection": "hardware",
"gnss": false,
"growing_area": "VN-TG-CL-0042",
"lat": 10.3512345,
"lon": 106.1234567,
"accuracy_m": 3.5,
"fix_at": 1790100000,
"installed_at": 1790100600,
"installer": "Nguyen Van A",
"photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
"depth_cm": 30,
"sensor_serial": "RS485-4IN1-00172",
"note": "Moved to block B after replanting",
"removed_at": null,
"recorded_at": 1790101000,
"valid_until": null
},
"calibrations": [
{
"id": 12,
"device_id": "soil-07",
"sensor_serial": "RS485-4IN1-00172",
"capability": "soil.ph",
"calibrated_at": 1790000000,
"method": "ph_buffers",
"reference_values": {
"buffers_ph": [
4.01,
7,
10.01
]
},
"coefficients": {
"offset": -0.03,
"slope": 0.987
},
"performer": "Can Tho soil laboratory",
"accreditation": "iso17025_lab",
"certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
"valid_until": 1805552000,
"supersedes": null,
"created_at": 1790001000,
"created_by": "admin@coop.example",
"superseded_by": null
}
],
"as_of": 1790200000
}响应 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"
}响应 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/station-delegations
The pending and active station sign-ins at a gateway
身份验证:cookie · listStationSignIns
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. The station sign-ins at the gateway that are pending (the code not typed yet, still valid) or active (claimed by the station, not ended, not revoked), the active ones first, each group newest first, at most 100 (an operator has at most 3 codes waiting at a station, so codes never push an active sign-in off the list): the caller's own, or every operator's for a company admin. Never the code. A gateway of another company, or out of an operator's facilities, answers like a missing one. Not audited (a read). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Gateway id (the edge station's). |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | StationDelegationListapplication/json | The sign-ins. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed. |
| 401 | Errorapplication/json | No valid session. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (an auditor or a lab; or an API token, an OAuth2 access token or the legacy token: a station sign-in is a person's, through a signed-in session only), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid. |
| 404 | Errorapplication/json | No such gateway (or another company's, or out of the operator's facilities). |
| 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 | 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 | 500 | string | Request id: the caller's |
响应示例
响应 200 · application/json
{
"items": [
{
"id": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"gateway": "gw-01",
"operator": "user-7",
"state": "active",
"issued_at": 1790560000,
"code_expires_at": 1790560600,
"expires_at": 1790588800,
"claimed_at": 1790560100,
"revoked_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"
}响应 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}响应 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/gateways/{id}/station-delegations
Sign in at an edge station (a one-time code to type there)
身份验证:cookie · createStationSignIn
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. The signed-in person lets the gateway's edge station record offline actions (accept a fruit, re-measure it, print its labels) for them until expires_at (lifetime_s, 900 to 28800 seconds, default 28800: at most one shift). The answer carries a one-time code (8 characters, valid 10 minutes, shown only here; only its SHA-256 is kept; at most 3 waiting per person and station, else 409 too_many_pending) that the operator types on the station's screen; the station claims it with a request signed by its own key (POST /v1/gateways/{id}/station-delegations/claim). No credential reaches the station: it can only record actions that the cloud checks when the station replays them (POST /v1/gateways/{id}/station-actions), and they count at most as Device-recorded. Audited (station.delegation.issue, never the code) in the company's activity log. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Gateway id (the edge station's). |
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 |
请求体
StationSignInRequest (可选)
媒体类型: application/json
请求示例 · application/json
{
"lifetime_s": 28800
}响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 201 | StationSignInapplication/json | The sign-in, with its one-time code. |
| 400 | Errorapplication/json | A bad body, a bad X-Request-Id, or a malformed or repeated Idempotency-Key header. |
| 401 | Errorapplication/json | No valid session. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (an auditor or a lab; or an API token, an OAuth2 access token or the legacy token: a station sign-in is a person's, through a signed-in session only), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid. |
| 404 | Errorapplication/json | No such gateway (or another company's, or out of the operator's facilities). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | The gateway is not active, or the caller already has 3 sign-in codes waiting (not typed yet, still valid) at this station ( |
| 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 | 201 | 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 | 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 |
响应示例
响应 201 · application/json
{
"id": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"gateway": "gw-01",
"operator": "user-7",
"state": "pending",
"issued_at": 1790560000,
"code_expires_at": 1790560600,
"expires_at": 1790588800,
"claimed_at": null,
"revoked_at": null,
"code": "K7MQ2XPA"
}响应 400 · application/json · lifetime
{
"error": "invalid lifetime_s: whole seconds from 900 to 28800",
"code": "invalid_lifetime_s"
}响应 400 · application/json · body
{
"error": "invalid body: only lifetime_s",
"code": "invalid_body"
}响应 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"
}响应 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · gateway_inactive
{
"error": "gateway inactive: the station's gateway is not active",
"code": "gateway_inactive"
}响应 409 · application/json · too_many_pending
{
"error": "too many pending: 3 sign-in codes are already waiting at this station; type one or revoke one first",
"code": "too_many_pending"
}响应 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"
}响应 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"
}POST /v1/station-delegations/{id}/revoke
Revoke a station sign-in
身份验证:cookie · revokeStationSignIn
仅限登录会话——API 令牌和 OAuth 客户端不可调用
#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. Revokes a station sign-in: the operator's own, or any of the company's for a company admin. From then on the station records nothing more under it (it learns of it on its next sync or replay and ends the operator's local session), and no action it recorded under it and has not replayed yet is applied (403 delegation_revoked). Another operator's sign-in, another company's or one at a gateway out of the operator's facilities answers like a missing one; one already revoked is 409. Audited (station.delegation.revoke) in the company's activity log. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
参数
| 名称 | 位置 | 类型 | 说明 |
|---|---|---|---|
id必填 | path | string | Station sign-in 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 |
响应
| 状态码 | 类型 | 说明 |
|---|---|---|
| 200 | StationDelegationapplication/json | Revoked. |
| 400 | Errorapplication/json | The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated. |
| 401 | Errorapplication/json | No valid session. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted (an auditor or a lab; or an API token, an OAuth2 access token or the legacy token: a station sign-in is a person's, through a signed-in session only), tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid. |
| 404 | Errorapplication/json | No such sign-in for the caller. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 409 | Errorapplication/json | Already revoked. Or 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 |
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": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"gateway": "gw-01",
"operator": "user-7",
"state": "revoked",
"issued_at": 1790560000,
"code_expires_at": 1790560600,
"expires_at": 1790588800,
"claimed_at": 1790560100,
"revoked_at": 1790570000
}响应 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"
}响应 404 · application/json
{
"error": "not found: 3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"code": "not_found"
}响应 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}响应 409 · application/json · delegation_revoked
{
"error": "delegation revoked: the station sign-in is already revoked",
"code": "delegation_revoked"
}响应 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"
}响应 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"
}