devices
27 operations
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
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Command id. |
channeloptional | query | "0" | "1" | #242: |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: 6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/command-keys
Public keys of the platform command key
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"keys": [
{
"kid": "platform-cmd-3b5e0c1d2a4f6e7d",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
}
}
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices
Devices of the caller's tenant with their status read model
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 100. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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
}Response 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Response 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices
Register a device
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
DeviceCreate (required)
Media type: application/json
Example request · 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"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Response 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"
}Response 400 · application/json · unknown_profile
{
"error": "unknown profile",
"code": "unknown_profile"
}Response 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · device_id_taken
{
"error": "device id taken",
"code": "device_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}
One device with its status read model
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · getDevice
Same roles as the list; an operator reads only devices of its facilities.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/devices/{id}
Change a device's status or display fields
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Request body
DeviceUpdate (required)
Media type: application/json
Example request · application/json
{
"status": "inactive"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · nothing_to_update
{
"error": "nothing to update",
"code": "nothing_to_update"
}Response 400 · application/json · field_not_editable
{
"error": "field not editable",
"code": "field_not_editable"
}Response 400 · application/json · invalid_status
{
"error": "invalid status: active or inactive",
"code": "invalid_status"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/commands
Commands sent to one device
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 200. |
channeloptional | query | "0" | "1" | #242: |
nameoptional | query | string | #372: only the commands of this name (as the device profile declares it: |
statusoptional | query | "accepted" | "aborted" | "completed" | "expired" | "failed" | "pending" | "rejected" | "sent" | "succeeded" | #372: only the commands in this state; 400 |
fromoptional | query | string (date) | #372: only the commands issued from the start of this farm-local date (Asia/Ho_Chi_Minh), |
tooptional | query | string (date) | #372: only the commands issued up to the end of this farm-local date, |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Response 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}Response 400 · application/json · bad_name
{
"error": "bad name: a command name",
"code": "bad_name"
}Response 400 · application/json · bad_status
{
"error": "bad status: accepted, aborted, completed, expired, failed, pending, rejected, sent, succeeded",
"code": "bad_status"
}Response 400 · application/json · bad_from
{
"error": "bad from: a date YYYY-MM-DD",
"code": "bad_from"
}Response 400 · application/json · bad_to
{
"error": "bad to: a date YYYY-MM-DD",
"code": "bad_to"
}Response 400 · application/json · bad_range
{
"error": "bad range: to is before from",
"code": "bad_range"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/commands
Send a command to a device
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
CommandRequest (required)
Media type: application/json
Example request · application/json
{
"name": "set_model",
"params": {
"version": "m9"
}
}Responses
| Status | Type | Description |
|---|---|---|
| 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 ( |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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. |
Example responses
Response 202 · application/json
{
"id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10"
}Response 400 · application/json · params
{
"error": "params must be an object",
"code": "params_must_be_an_object"
}Response 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"
}Response 400 · application/json · strict_json
{
"error": "invalid params: a string holds U+0000",
"code": "invalid_params"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · device_not_approved
{
"error": "device not approved: knk-1",
"code": "device_not_approved"
}Response 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"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Response 503 · application/json
{
"error": "command signing unavailable",
"code": "command_signing_unavailable"
}GET /v1/gateways
Gateways of the caller's tenant
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 100. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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
}Response 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Response 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/gateways
Register a gateway
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
GatewayCreate (required)
Media type: application/json
Example request · application/json
{
"gateway_id": "gw-01",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Packing hall gateway"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Response 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"
}Response 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · gateway_id_taken
{
"error": "gateway id taken",
"code": "gateway_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/heartbeat
A gateway's newest status heartbeat
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Gateway id. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}
]
}
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/status-series
A gateway's status time series
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Gateway id. |
grainoptional | query | "minute" | "hourly" | "daily" | A sample a minute, or the hourly or daily rollups. |
fromoptional | 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 |
tooptional | query | string | End (excluded), as |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}
}
]
}Response 400 · application/json · bad_grain
{
"error": "bad grain: minute, hourly or daily",
"code": "bad_grain"
}Response 400 · application/json · bad_from
{
"error": "bad from",
"code": "bad_from"
}Response 400 · application/json · bad_to
{
"error": "bad to",
"code": "bad_to"
}Response 400 · application/json · bad_range
{
"error": "bad range: from must be before to",
"code": "bad_range"
}Response 400 · application/json · range_too_long
{
"error": "range too long",
"code": "range_too_long"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/keys
Device and gateway keys of the caller's tenant
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
owneroptional | query | string | A device or gateway id of the caller's tenant. |
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 100. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Response 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Response 400 · application/json · invalid_owner
{
"error": "invalid owner: a device or gateway id",
"code": "invalid_owner"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/keys
Register a public key for a device or gateway
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
KeyCreate (required)
Media type: application/json
Example request · 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"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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"
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Response 400 · application/json · invalid_kid
{
"error": "invalid kid: 1 to 128 letters, digits, '.', '_', ':' or '-', starting with a letter or digit",
"code": "invalid_kid"
}Response 400 · application/json · invalid_owner_type
{
"error": "invalid owner_type: device or gateway",
"code": "invalid_owner_type"
}Response 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"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/keys/{kid}/revoke
Revoke a key
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kidrequired | path | string | Key id. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
KeyRevoke (required)
Media type: application/json
Example request · application/json
{
"reason": "rotation"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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"
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · invalid_reason
{
"error": "invalid reason: rotation or compromise",
"code": "invalid_reason"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: knk-1-2026",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · key_already_revoked
{
"error": "key already revoked",
"code": "key_already_revoked"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/harvest-keys
Harvest app registrations of the caller's tenant
Authentication: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
cursoroptional | query | string |
|
limitoptional | query | integer | Page size, 1 to 100. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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
}Response 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Response 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys
Ask to register a harvest app install's key
Authentication: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
HarvestKeyRegister (required)
Media type: application/json
Example request · application/json
{
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone"
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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
}Response 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
}Response 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Response 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Response 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"
}Response 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Response 400 · application/json · invalid_label
{
"error": "invalid label: 1 to 100 characters without control characters",
"code": "invalid_label"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · key_already_registered
{
"error": "key already registered",
"code": "key_already_registered"
}Response 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/harvest-keys/{kid}
One harvest app registration
Authentication: 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).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kidrequired | path | string | Key id of the registration. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys/{kid}/approve
Approve a pending harvest app registration
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kidrequired | path | string | Key id of the registration. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}Response 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys/{kid}/reject
Reject a pending harvest app registration
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kidrequired | path | string | Key id of the registration. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Idempotent-Replayed | 200 | "true" |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"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
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}Response 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/placements
A device's placement versions
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/calibrations
A device's calibrations
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
sensor_serialoptional | query | string | Only the calibrations of this probe serial (1 to 100 characters). |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}
]
}Response 400 · application/json · sensor_serial
{
"error": "bad sensor_serial",
"code": "bad_sensor_serial"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/calibrations
Record a device calibration
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
CalibrationCreate (required)
Media type: application/json
Example request · 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
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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
}Response 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Response 400 · application/json · missing_field
{
"error": "missing field: valid_until",
"code": "missing_field"
}Response 400 · application/json · valid_until
{
"error": "invalid valid_until: after calibrated_at",
"code": "invalid_valid_until"
}Response 400 · application/json · hash_mismatch
{
"error": "certificate hash mismatch: the certificate does not hash to certificate_sha256",
"code": "certificate_hash_mismatch"
}Response 400 · application/json · unknown_certificate
{
"error": "unknown certificate_sha256: upload the certificate (PDF, JPEG or PNG) first",
"code": "unknown_certificate_sha256"
}Response 400 · application/json · unknown_supersedes
{
"error": "unknown supersedes: not a calibration of this device",
"code": "unknown_supersedes"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · superseded
{
"error": "calibration superseded: correct the record that superseded it",
"code": "calibration_superseded"
}Response 409 · application/json · idempotency_in_progress
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/metadata
A device's metadata
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: 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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id. |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 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
Authentication: cookie · listStationSignIns
Session only — not available to API tokens or OAuth clients
#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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Gateway id (the edge station's). |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 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 |
Example responses
Response 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
}
]
}Response 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 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)
Authentication: cookie · createStationSignIn
Session only — not available to API tokens or OAuth clients
#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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Gateway id (the edge station's). |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Request body
StationSignInRequest (optional)
Media type: application/json
Example request · application/json
{
"lifetime_s": 28800
}Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
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 |
Example responses
Response 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"
}Response 400 · application/json · lifetime
{
"error": "invalid lifetime_s: whole seconds from 900 to 28800",
"code": "invalid_lifetime_s"
}Response 400 · application/json · body
{
"error": "invalid body: only lifetime_s",
"code": "invalid_body"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · gateway_inactive
{
"error": "gateway inactive: the station's gateway is not active",
"code": "gateway_inactive"
}Response 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"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/station-delegations/{id}/revoke
Revoke a station sign-in
Authentication: cookie · revokeStationSignIn
Session only — not available to API tokens or OAuth clients
#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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Station sign-in id. |
Idempotency-Keyoptional | header | string | Makes a retry of this request safe (#169). A client-chosen key, 1 to 255 visible ASCII characters (a UUID is a good choice), scoped to the caller's tenant and principal (session user, API token or legacy token). The first request with a key runs; when it answers 2xx, that response (status, body and headers) is stored and replayed for 24 hours to every request with the same key and the same method, path, query and body bytes, marked |
Responses
| Status | Type | Description |
|---|---|---|
| 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. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 409 | string | Request id: the caller's |
Retry-After | 409 | string | Seconds to wait before retrying. |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"id": "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
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 404 · application/json
{
"error": "not found: 3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 409 · application/json · delegation_revoked
{
"error": "delegation revoked: the station sign-in is already revoked",
"code": "delegation_revoked"
}Response 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Response 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Response 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}