devices
27 thao tác
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
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: command_read · getCommand
Status moves pending, sent, then succeeded or failed. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Command id. |
channelkhông bắt buộc | query | "0" | "1" | #242: |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: 6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/command-keys
Public keys of the platform command key
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_command · listCommandKeys
#242: the public part of the platform command key, which signs every actuation command document (ES256 over the RFC 8785 canonical JSON of the document without sig; the document's sig.kid names the key). A controller is provisioned with it to verify the commands it receives. An empty keys list when the server has no command key: every actuation command is then refused. Allowed for tenant_admin and platform_admin (acting for the tenant), and an operator through a signed-in session or an operator API client, as issuing a command; auditors and labs are refused. Not audited (a read of public key material). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 200 · application/json
{
"keys": [
{
"kid": "platform-cmd-3b5e0c1d2a4f6e7d",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
}
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices
Devices of the caller's tenant with their status read model
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_read · listDevices
Devices ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only devices of its facilities: the device's facility, or its site when it has none).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices
Register a device
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · createDevice
Registers an active device of the caller's tenant (never a body field). The id must be unused by every tenant's devices and gateways: an existing record is never replaced. Audited (device.create). Allowed for platform_admin and tenant_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
DeviceCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · 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"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 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"
}Phản hồi 400 · application/json · unknown_profile
{
"error": "unknown profile",
"code": "unknown_profile"
}Phản hồi 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · device_id_taken
{
"error": "device id taken",
"code": "device_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}
One device with its status read model
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_read · getDevice
Same roles as the list; an operator reads only devices of its facilities.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PATCH /v1/devices/{id}
Change a device's status or display fields
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · updateDevice
Sets status (active or inactive; ingest and the broker accept only active devices) and the display fields. The id, site, facility and profile cannot change. Audited (device.update). Allowed for platform_admin and tenant_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Nội dung yêu cầu
DeviceUpdate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"status": "inactive"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · nothing_to_update
{
"error": "nothing to update",
"code": "nothing_to_update"
}Phản hồi 400 · application/json · field_not_editable
{
"error": "field not editable",
"code": "field_not_editable"
}Phản hồi 400 · application/json · invalid_status
{
"error": "invalid status: active or inactive",
"code": "invalid_status"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/commands
Commands sent to one device
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: command_read · listDeviceCommands
The device's commands newest first (issued_at, then id), with keyset pagination (at most 200 per page). Same roles and scope as reading the device. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk). #372: name, status, from and to filter the commands (the irrigation cockpit's command log); not part of the partner SDK clients either. A filter given empty (?name=) is no filter: an empty query value is dropped, as for every parameter.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 200. |
channelkhông bắt buộc | query | "0" | "1" | #242: |
namekhông bắt buộc | query | string | #372: only the commands of this name (as the device profile declares it: |
statuskhông bắt buộc | query | "accepted" | "aborted" | "completed" | "expired" | "failed" | "pending" | "rejected" | "sent" | "succeeded" | #372: only the commands in this state; 400 |
fromkhông bắt buộc | query | string (date) | #372: only the commands issued from the start of this farm-local date (Asia/Ho_Chi_Minh), |
tokhông bắt buộc | query | string (date) | #372: only the commands issued up to the end of this farm-local date, |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · bad_channel
{
"error": "bad channel",
"code": "bad_channel"
}Phản hồi 400 · application/json · bad_name
{
"error": "bad name: a command name",
"code": "bad_name"
}Phản hồi 400 · application/json · bad_status
{
"error": "bad status: accepted, aborted, completed, expired, failed, pending, rejected, sent, succeeded",
"code": "bad_status"
}Phản hồi 400 · application/json · bad_from
{
"error": "bad from: a date YYYY-MM-DD",
"code": "bad_from"
}Phản hồi 400 · application/json · bad_to
{
"error": "bad to: a date YYYY-MM-DD",
"code": "bad_to"
}Phản hồi 400 · application/json · bad_range
{
"error": "bad range: to is before from",
"code": "bad_range"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/commands
Send a command to a device
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_command · issueDeviceCommand
The command must be declared by the device profile and every param must be declared for it. The command is recorded before it is dispatched. A device of another tenant answers 404. #242: a command is issued only to an active, approved device reached by an active, approved key: one of its own, or that of an active, approved gateway at its site (409 device_not_approved otherwise, for every command). An actuation command (an irrigation controller's run_zone, a timed zone run, and set_program, a program lease) is sent as a command document signed with the platform command key (GET /v1/command-keys), which the controller verifies and enforces locally; every param it declares must be given within its declared range. Without a platform command key every actuation command is refused (503 command_signing_unavailable); config commands are not affected. A facility-scoped operator may issue calibrate, run_zone and set_program to a device of its facilities. A set_program whose program_version is not above the highest program_version of every set_program already recorded for the device (at any site, in any status) is refused (409 program_version_not_increasing): the controllers rely on strictly rising program versions per device. None of these refusals records a command, and the Idempotency-Key is not used up: a retry with the same key runs again. The 409 refusals and the 503 response are not part of the partner SDK clients (x-not-in-sdk).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
CommandRequest (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"name": "set_model",
"params": {
"version": "m9"
}
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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 ( |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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. |
Ví dụ phản hồi
Phản hồi 202 · application/json
{
"id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10"
}Phản hồi 400 · application/json · params
{
"error": "params must be an object",
"code": "params_must_be_an_object"
}Phản hồi 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"
}Phản hồi 400 · application/json · strict_json
{
"error": "invalid params: a string holds U+0000",
"code": "invalid_params"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · device_not_approved
{
"error": "device not approved: knk-1",
"code": "device_not_approved"
}Phản hồi 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"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}Phản hồi 503 · application/json
{
"error": "command signing unavailable",
"code": "command_signing_unavailable"
}GET /v1/gateways
Gateways of the caller's tenant
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · listGateways
Gateways ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor; gateways are site-wide, so operators are refused.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/gateways
Register a gateway
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · createGateway
Registers an active gateway of the caller's tenant. The id must be unused by every tenant's gateways and devices: an existing record is never replaced. Audited (gateway.create). Allowed for platform_admin and tenant_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
GatewayCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"gateway_id": "gw-01",
"site": "ph1",
"facility": "VN-TGPH-021",
"display_name": "Packing hall gateway"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 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"
}Phản hồi 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · gateway_id_taken
{
"error": "gateway id taken",
"code": "gateway_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/heartbeat
A gateway's newest status heartbeat
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · getGatewayHeartbeat
#24: the newest status heartbeat of a gateway of the caller's tenant. A gateway signs a status envelope about itself every 30 s by default (profile vn.agritrace.gateway, /developers/downloads/profiles/gateway.json: its gateway id as device.id, on the ingest route {tenant}/{site}/{gateway id}/status); the server keeps the newest one of each gateway, never as an envelope: ordered by seq, but a signed heartbeat with a lower seq and a later time is kept (a reset gateway) and a signed one with a higher seq and an earlier time is superseded; one dated past the server's maximum future skew is rejected (400 future_timestamp). heartbeat is null until the gateway sent one. A value the heartbeat did not carry is null. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Gateway id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}
]
}
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/gateways/{id}/status-series
A gateway's status time series
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · getGatewayStatusSeries
#128: the status series of a gateway of the caller's tenant. The server stores at most one of the gateway's status heartbeats a minute (the first one it keeps in each UTC minute of reception) and adds it to the gateway's hourly rollup. grain=minute returns those samples; hourly (the default) the hourly rollups; daily the hourly rollups merged per UTC day. A rollup gives the number of samples, for the outbox depth, the dead-letter count and the devices listed and ready the minimum, maximum, mean (null when no sample carried the value) and count of the samples that carried it, and the samples per link state. Samples are kept 30 days and hourly rollups 2 years; the range is clipped to what is kept (from in the answer is the start actually read, aligned down to the grain) and is at most 1 day for minute, 31 days for hourly and 731 days for daily (range_too_long). The newest heartbeat itself is getGatewayHeartbeat. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Gateway id. |
grainkhông bắt buộc | query | "minute" | "hourly" | "daily" | A sample a minute, or the hourly or daily rollups. |
fromkhông bắt buộc | 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 |
tokhông bắt buộc | query | string | End (excluded), as |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}
}
]
}Phản hồi 400 · application/json · bad_grain
{
"error": "bad grain: minute, hourly or daily",
"code": "bad_grain"
}Phản hồi 400 · application/json · bad_from
{
"error": "bad from",
"code": "bad_from"
}Phản hồi 400 · application/json · bad_to
{
"error": "bad to",
"code": "bad_to"
}Phản hồi 400 · application/json · bad_range
{
"error": "bad range: from must be before to",
"code": "bad_range"
}Phản hồi 400 · application/json · range_too_long
{
"error": "range too long",
"code": "range_too_long"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/keys
Device and gateway keys of the caller's tenant
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: tenant_read · listKeys
Keys ordered by kid, with keyset pagination (at most 100 per page); a key belongs to its owner's tenant. With owner, only that device's or gateway's keys. Never returns key material, only fingerprints. Allowed for platform_admin, tenant_admin and auditor.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
ownerkhông bắt buộc | query | string | A device or gateway id of the caller's tenant. |
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · invalid_owner
{
"error": "invalid owner: a device or gateway id",
"code": "invalid_owner"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/keys
Register a public key for a device or gateway
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · createKey
Adds an active key. The PEM must be one PUBLIC KEY block holding an EC P-256 SubjectPublicKeyInfo (private keys, certificates, other curves and trailing data are refused); the canonical PEM is stored. The kid must be unused by every tenant and not reserved by the deployed seed (provisioning reserves every seed kid). #201: the key waits for a platform admin's approval whatever its owner's (an approved device or gateway is listed in the pending queue again); until then evidence it signs counts as Self-declared. Audited (key.create; the row keeps the kid and fingerprint, never the PEM). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
KeyCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · 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"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · invalid_kid
{
"error": "invalid kid: 1 to 128 letters, digits, '.', '_', ':' or '-', starting with a letter or digit",
"code": "invalid_kid"
}Phản hồi 400 · application/json · invalid_owner_type
{
"error": "invalid owner_type: device or gateway",
"code": "invalid_owner_type"
}Phản hồi 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"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/keys/{kid}/revoke
Revoke a key
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · revokeKey
Marks the key revoked with its reason; ingest refuses it from then on. compromise also raises one high-severity key_compromised alert for the tenant. A revoked key cannot be revoked again (the first reason and time stay). Audited (key.revoke). Allowed for platform_admin and tenant_admin. Step-up (#87): a signed-in session of an account with two-step sign-in must have confirmed a code from its authenticator app (or a backup code) within the last 5 minutes and its password within the last 10 minutes, else 401 mfa_step_up_required before anything is done (no audit row): confirm both with POST /v1/auth/reauth, then repeat the request. A session of an account without two-step sign-in, API tokens and API clients are served as before.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
kidbắt buộc | path | string | Key id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
KeyRevoke (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"reason": "rotation"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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"
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · invalid_reason
{
"error": "invalid reason: rotation or compromise",
"code": "invalid_reason"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: knk-1-2026",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_already_revoked
{
"error": "key already revoked",
"code": "key_already_revoked"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/harvest-keys
Harvest app registrations of the caller's tenant
Xác thực: 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).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
cursorkhông bắt buộc | query | string |
|
limitkhông bắt buộc | query | integer | Page size, 1 to 100. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_cursor
{
"error": "bad cursor",
"code": "bad_cursor"
}Phản hồi 400 · application/json · bad_limit
{
"error": "bad limit",
"code": "bad_limit"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys
Ask to register a harvest app install's key
Xác thực: 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).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
HarvestKeyRegister (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n",
"facility": "VN-DL-PH-01",
"label": "Weighing desk phone"
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 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
}Phản hồi 400 · application/json · invalid_json
{
"error": "invalid JSON",
"code": "invalid_json"
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 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"
}Phản hồi 400 · application/json · unknown_facility
{
"error": "unknown facility",
"code": "unknown_facility"
}Phản hồi 400 · application/json · invalid_label
{
"error": "invalid label: 1 to 100 characters without control characters",
"code": "invalid_label"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · key_already_registered
{
"error": "key already registered",
"code": "key_already_registered"
}Phản hồi 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · facility_not_approved
{
"error": "facility not approved",
"code": "facility_not_approved"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/harvest-keys/{kid}
One harvest app registration
Xác thực: 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).
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
kidbắt buộc | path | string | Key id of the registration. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys/{kid}/approve
Approve a pending harvest app registration
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · approveHarvestKey
#160: a tenant admin approved the registration (final). The install's device (profile vn.agritrace.harvest-app, active, at the registration's facility) and its active device key are created in the same transaction; ingest accepts its signed harvest envelopes from then on. The deciding actor is the principal. Audited (harvest_key.approve). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
kidbắt buộc | path | string | Key id of the registration. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}Phản hồi 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/harvest-keys/{kid}/reject
Reject a pending harvest app registration
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · rejectHarvestKey
#160: a tenant admin rejected the registration (final). No device or key is created; the install makes a new key. The deciding actor is the principal. Audited (harvest_key.reject). Allowed for platform_admin and tenant_admin.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
kidbắt buộc | path | string | Key id of the registration. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 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"
}Phản hồi 404 · application/json
{
"error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · registration_already_decided
{
"error": "registration already decided",
"code": "registration_already_decided"
}Phản hồi 409 · application/json · key_id_taken
{
"error": "key id taken",
"code": "key_id_taken"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 409 · application/json · idempotency_key_unrecorded
{
"error": "idempotency key used: the request ran but its response was not recorded",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/placements
A device's placement versions
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_read · listDevicePlacements
SENS-A2 (#225): every placement version CropPath recorded for a device of the company, newest first, with the growing area it is bound to, the surveyed install point and the commissioning record. Same roles as reading the device; an operator reads only devices of its facilities. recorded_by (who at CropPath recorded it) is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/calibrations
A device's calibrations
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_read · listDeviceCalibrations
SENS-B1d (#234): every calibration recorded for a device of the company, newest first, with the one that supersedes each (superseded_by). sensor_serial lists one probe's only. Same roles as reading the device; an operator reads only devices of its facilities. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
sensor_serialkhông bắt buộc | query | string | Only the calibrations of this probe serial (1 to 100 characters). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}
]
}Phản hồi 400 · application/json · sensor_serial
{
"error": "bad sensor_serial",
"code": "bad_sensor_serial"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/devices/{id}/calibrations
Record a device calibration
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_admin · recordDeviceCalibration
SENS-B1d (#234): a company admin, or a platform admin acting for the company (X-Tenant), records a calibration of one of the company's devices, with its certificate (uploaded first with PUT /v1/attachments/{sha256}, or sent in certificate). Calibrations are append-only: a correction is a new calibration that names the one it corrects (supersedes); the corrected one is kept. Audited (device.calibration) in the company's activity log. Allowed for tenant_admin and platform_admin (and an API client with device_admin). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
CalibrationCreate (bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · 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
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · unknown_field
{
"error": "unknown field",
"code": "unknown_field"
}Phản hồi 400 · application/json · missing_field
{
"error": "missing field: valid_until",
"code": "missing_field"
}Phản hồi 400 · application/json · valid_until
{
"error": "invalid valid_until: after calibrated_at",
"code": "invalid_valid_until"
}Phản hồi 400 · application/json · hash_mismatch
{
"error": "certificate hash mismatch: the certificate does not hash to certificate_sha256",
"code": "certificate_hash_mismatch"
}Phản hồi 400 · application/json · unknown_certificate
{
"error": "unknown certificate_sha256: upload the certificate (PDF, JPEG or PNG) first",
"code": "unknown_certificate_sha256"
}Phản hồi 400 · application/json · unknown_supersedes
{
"error": "unknown supersedes: not a calibration of this device",
"code": "unknown_supersedes"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 403 · application/json · origin
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · superseded
{
"error": "calibration superseded: correct the record that superseded it",
"code": "calibration_superseded"
}Phản hồi 409 · application/json · idempotency_in_progress
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/devices/{id}/metadata
A device's metadata
Xác thực: cookie, bearer, oauth2 · Phạm vi OAuth2: device_read · getDeviceMetadata
SENS-B1d (#234): a device's placement version in force (#225) and its calibrations not superseded: the document an EPCIS deviceMetadata link of the device's readings can name later (/v1/devices/{id}/metadata on this deployment's origin). For the device's company (the roles that read the device; an operator only for devices of its facilities) and platform admins acting for it; never public, and another company's device answers 404. recorded_by of the placement is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Device id. |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 404 · application/json
{
"error": "not found: soil-07",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 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
Xác thực: cookie · listStationSignIns
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#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.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Gateway id (the edge station's). |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}
]
}Phản hồi 400 · application/json
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 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)
Xác thực: cookie · createStationSignIn
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#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.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Gateway id (the edge station's). |
Idempotency-Keykhông bắt buộc | 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 |
Nội dung yêu cầu
StationSignInRequest (không bắt buộc)
Kiểu nội dung: application/json
Ví dụ yêu cầu · application/json
{
"lifetime_s": 28800
}Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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"
}Phản hồi 400 · application/json · lifetime
{
"error": "invalid lifetime_s: whole seconds from 900 to 28800",
"code": "invalid_lifetime_s"
}Phản hồi 400 · application/json · body
{
"error": "invalid body: only lifetime_s",
"code": "invalid_body"
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 404 · application/json
{
"error": "not found: gw-01",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · gateway_inactive
{
"error": "gateway inactive: the station's gateway is not active",
"code": "gateway_inactive"
}Phản hồi 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"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}POST /v1/station-delegations/{id}/revoke
Revoke a station sign-in
Xác thực: cookie · revokeStationSignIn
Chỉ dùng phiên đăng nhập — API token và ứng dụng OAuth không gọi được
#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.
Tham số
| Tên | Vị trí | Kiểu | Mô tả |
|---|---|---|---|
idbắt buộc | path | string | Station sign-in id. |
Idempotency-Keykhông bắt buộc | 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 |
Phản hồi
| Mã trạng thái | Kiểu | Mô tả |
|---|---|---|
| 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. |
Header của phản hồi
| Tên | Mã trạng thái | Kiểu | Mô tả |
|---|---|---|---|
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 |
Ví dụ phản hồi
Phản hồi 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
}Phản hồi 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Phản hồi 400 · application/json · invalid_idempotency_key
{
"error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
"code": "invalid_idempotency_key"
}Phản hồi 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Phản hồi 403 · application/json · role
{
"error": "role not permitted",
"code": "role_not_permitted"
}Phản hồi 403 · application/json · tenant
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Phản hồi 403 · application/json · csrf
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Phản hồi 404 · application/json
{
"error": "not found: 3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
"code": "not_found"
}Phản hồi 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Phản hồi 409 · application/json · delegation_revoked
{
"error": "delegation revoked: the station sign-in is already revoked",
"code": "delegation_revoked"
}Phản hồi 409 · application/json · idempotency_key_in_use
{
"error": "idempotency key in use: retry later",
"code": "idempotency_key_in_use"
}Phản hồi 409 · application/json · idempotency_key_used
{
"error": "idempotency key used: the response is too large to replay",
"code": "idempotency_key_used"
}Phản hồi 422 · application/json
{
"error": "idempotency key mismatch: the key was used with another request",
"code": "idempotency_key_mismatch"
}Phản hồi 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}