CropPath for developers

API reference

devices

27 operations

GET /v1/commands/{id}

State of a command

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: command_read · getCommand

Status moves pending, sent, then succeeded or failed. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk).

Parameters

NameInTypeDescription
id
required
pathstring

Command id.

channel
optional
query"0" | "1"

#242: 1 adds the command channel members (kind, expires_at, reason, accepted_at) to each command; 0 or none leaves them out and answers exactly the members answered before; any other value is refused (400 bad channel). It selects no commands: the status of an actuation command (accepted, rejected, completed, aborted, expired) is answered either way.

Responses

StatusTypeDescription
200Command
application/json

The recorded command.

400Error
application/json

channel not 0 or 1, or the X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such command for this tenant.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
  "tenant": "coop-dl",
  "site": "ph1",
  "device_id": "knk-1",
  "name": "set_model",
  "params": {
    "version": "m9"
  },
  "issued_by": "legacy-user",
  "issued_at": 1790000000.5,
  "status": "sent",
  "result": null,
  "completed_at": null
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · bad_channel
{
  "error": "bad channel",
  "code": "bad_channel"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: 6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/command-keys

Public keys of the platform command key

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_command · listCommandKeys

#242: the public part of the platform command key, which signs every actuation command document (ES256 over the RFC 8785 canonical JSON of the document without sig; the document's sig.kid names the key). A controller is provisioned with it to verify the commands it receives. An empty keys list when the server has no command key: every actuation command is then refused. Allowed for tenant_admin and platform_admin (acting for the tenant), and an operator through a signed-in session or an operator API client, as issuing a command; auditors and labs are refused. Not audited (a read of public key material). Not part of the partner SDK clients (x-not-in-sdk): SDK 0.2.0 was released before it.

Responses

StatusTypeDescription
200CommandKeys
application/json

The platform command keys (at most one today).

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted (auditors, labs, an operator API token) or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "keys": [
    {
      "kid": "platform-cmd-3b5e0c1d2a4f6e7d",
      "alg": "ES256",
      "jwk": {
        "kty": "EC",
        "crv": "P-256",
        "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
        "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
      }
    }
  ]
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices

Devices of the caller's tenant with their status read model

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · listDevices

Devices ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor (the whole tenant) and for an operator signed in with a session (only devices of its facilities: the device's facility, or its site when it has none).

Parameters

NameInTypeDescription
cursor
optional
querystring

next_cursor of the previous page of devices.

limit
optional
queryinteger

Page size, 1 to 100.

Responses

StatusTypeDescription
200DevicePage
application/json

One page of devices.

400Error
application/json

A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "device_id": "knk-1",
      "tenant": "coop-dl",
      "site": "ph1",
      "facility": "VN-TGPH-021",
      "profile": "vn.agritrace.durian-knocker",
      "status": "active",
      "display_name": "Knocker line 1",
      "vendor_model": "SF-100",
      "serial": "SF100-000123",
      "created_at": 1790000000.5,
      "commands": [
        "calibrate",
        "set_model",
        "set_session"
      ],
      "last_seen": 1790003600.25,
      "max_seq": 412,
      "last_model": "m1",
      "firmware": "1.4.2",
      "battery_pct": 87,
      "battery_v": 3.92,
      "last_calibrated_at": 1789990000,
      "ready": true,
      "approval": "approved",
      "approval_reason": null,
      "approval_at": 1790000100
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/devices

Register a device

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · createDevice

Registers an active device of the caller's tenant (never a body field). The id must be unused by every tenant's devices and gateways: an existing record is never replaced. Audited (device.create). Allowed for platform_admin and tenant_admin.

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

DeviceCreate (required)

Media type: application/json

Example request · application/json
{
  "device_id": "knk-1",
  "profile": "vn.agritrace.durian-knocker",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "display_name": "Knocker line 1",
  "vendor_model": "SF-100",
  "serial": "SF100-000123"
}

Responses

StatusTypeDescription
201Device
application/json

The new device (never seen yet: no state, not ready).

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded). SELF-2-8 (#197): or the facility is a company's proposal CropPath has not approved yet.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 201 · application/json
{
  "device_id": "knk-1",
  "tenant": "coop-dl",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "profile": "vn.agritrace.durian-knocker",
  "status": "active",
  "display_name": "Knocker line 1",
  "vendor_model": "SF-100",
  "serial": "SF100-000123",
  "created_at": 1790000000.5,
  "commands": [
    "calibrate",
    "set_model",
    "set_session"
  ],
  "last_seen": null,
  "max_seq": null,
  "last_model": null,
  "firmware": null,
  "battery_pct": null,
  "battery_v": null,
  "last_calibrated_at": null,
  "ready": false,
  "approval": "approved",
  "approval_reason": null,
  "approval_at": 1790000100
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_device_id
{
  "error": "invalid device_id: 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit",
  "code": "invalid_device_id"
}
Response 400 · application/json · unknown_profile
{
  "error": "unknown profile",
  "code": "unknown_profile"
}
Response 400 · application/json · unknown_facility
{
  "error": "unknown facility",
  "code": "unknown_facility"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · device_id_taken
{
  "error": "device id taken",
  "code": "device_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 409 · application/json · facility_not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices/{id}

One device with its status read model

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · getDevice

Same roles as the list; an operator reads only devices of its facilities.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Responses

StatusTypeDescription
200Device
application/json

The device.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "device_id": "knk-1",
  "tenant": "coop-dl",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "profile": "vn.agritrace.durian-knocker",
  "status": "active",
  "display_name": "Knocker line 1",
  "vendor_model": "SF-100",
  "serial": "SF100-000123",
  "created_at": 1790000000.5,
  "commands": [
    "calibrate",
    "set_model",
    "set_session"
  ],
  "last_seen": 1790003600.25,
  "max_seq": 412,
  "last_model": "m1",
  "firmware": "1.4.2",
  "battery_pct": 87,
  "battery_v": 3.92,
  "last_calibrated_at": 1789990000,
  "ready": true,
  "approval": "approved",
  "approval_reason": null,
  "approval_at": 1790000100
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

PATCH /v1/devices/{id}

Change a device's status or display fields

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · updateDevice

Sets status (active or inactive; ingest and the broker accept only active devices) and the display fields. The id, site, facility and profile cannot change. Audited (device.update). Allowed for platform_admin and tenant_admin.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Request body

DeviceUpdate (required)

Media type: application/json

Example request · application/json
{
  "status": "inactive"
}

Responses

StatusTypeDescription
200Device
application/json

The device after the change.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "device_id": "knk-1",
  "tenant": "coop-dl",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "profile": "vn.agritrace.durian-knocker",
  "status": "inactive",
  "display_name": "Knocker line 1",
  "vendor_model": "SF-100",
  "serial": "SF100-000123",
  "created_at": 1790000000.5,
  "commands": [
    "calibrate",
    "set_model",
    "set_session"
  ],
  "last_seen": 1790003600.25,
  "max_seq": 412,
  "last_model": "m1",
  "firmware": "1.4.2",
  "battery_pct": 87,
  "battery_v": 3.92,
  "last_calibrated_at": 1789990000,
  "ready": false,
  "approval": "approved",
  "approval_reason": null,
  "approval_at": 1790000100
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · nothing_to_update
{
  "error": "nothing to update",
  "code": "nothing_to_update"
}
Response 400 · application/json · field_not_editable
{
  "error": "field not editable",
  "code": "field_not_editable"
}
Response 400 · application/json · invalid_status
{
  "error": "invalid status: active or inactive",
  "code": "invalid_status"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices/{id}/commands

Commands sent to one device

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: command_read · listDeviceCommands

The device's commands newest first (issued_at, then id), with keyset pagination (at most 200 per page). Same roles and scope as reading the device. #242: an irrigation controller's actuation commands (run_zone, set_program) move pending, sent, then accepted and completed or aborted, or rejected, or expired; channel=1 adds their kind, expiry, accepted time and reason. The parameter and those members are not part of the partner SDK clients (x-not-in-sdk). #372: name, status, from and to filter the commands (the irrigation cockpit's command log); not part of the partner SDK clients either. A filter given empty (?name=) is no filter: an empty query value is dropped, as for every parameter.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

cursor
optional
querystring

next_cursor of the previous page of commands.

limit
optional
queryinteger

Page size, 1 to 200.

channel
optional
query"0" | "1"

#242: 1 adds the command channel members (kind, expires_at, reason, accepted_at) to each command; 0 or none leaves them out and answers exactly the members answered before; any other value is refused (400 bad channel). It selects no commands: the status of an actuation command (accepted, rejected, completed, aborted, expired) is answered either way.

name
optional
querystring

#372: only the commands of this name (as the device profile declares it: run_zone, set_program, calibrate...); 400 bad_name for anything else than a lower-case token.

status
optional
query"accepted" | "aborted" | "completed" | "expired" | "failed" | "pending" | "rejected" | "sent" | "succeeded"

#372: only the commands in this state; 400 bad_status for another value.

from
optional
querystring (date)

#372: only the commands issued from the start of this farm-local date (Asia/Ho_Chi_Minh), YYYY-MM-DD, a year from 2000 to 9998; 400 bad_from.

to
optional
querystring (date)

#372: only the commands issued up to the end of this farm-local date, YYYY-MM-DD, a year from 2000 to 9998; 400 bad_to, and bad_range when it is before from.

Responses

StatusTypeDescription
200CommandPage
application/json

One page of commands.

400Error
application/json

A cursor that is not one this API issued, a limit out of range, channel not 0 or 1, a bad name, status, from or to filter (or to before from), or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such device for this tenant: a device of another tenant, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10",
      "tenant": "coop-dl",
      "site": "ph1",
      "device_id": "knk-1",
      "name": "set_model",
      "params": {
        "version": "m9"
      },
      "issued_by": "legacy-user",
      "issued_at": 1790000000.5,
      "status": "succeeded",
      "result": {
        "ok": true
      },
      "completed_at": 1790000003
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · bad_channel
{
  "error": "bad channel",
  "code": "bad_channel"
}
Response 400 · application/json · bad_name
{
  "error": "bad name: a command name",
  "code": "bad_name"
}
Response 400 · application/json · bad_status
{
  "error": "bad status: accepted, aborted, completed, expired, failed, pending, rejected, sent, succeeded",
  "code": "bad_status"
}
Response 400 · application/json · bad_from
{
  "error": "bad from: a date YYYY-MM-DD",
  "code": "bad_from"
}
Response 400 · application/json · bad_to
{
  "error": "bad to: a date YYYY-MM-DD",
  "code": "bad_to"
}
Response 400 · application/json · bad_range
{
  "error": "bad range: to is before from",
  "code": "bad_range"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/devices/{id}/commands

Send a command to a device

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_command · issueDeviceCommand

The command must be declared by the device profile and every param must be declared for it. The command is recorded before it is dispatched. A device of another tenant answers 404. #242: a command is issued only to an active, approved device reached by an active, approved key: one of its own, or that of an active, approved gateway at its site (409 device_not_approved otherwise, for every command). An actuation command (an irrigation controller's run_zone, a timed zone run, and set_program, a program lease) is sent as a command document signed with the platform command key (GET /v1/command-keys), which the controller verifies and enforces locally; every param it declares must be given within its declared range. Without a platform command key every actuation command is refused (503 command_signing_unavailable); config commands are not affected. A facility-scoped operator may issue calibrate, run_zone and set_program to a device of its facilities. A set_program whose program_version is not above the highest program_version of every set_program already recorded for the device (at any site, in any status) is refused (409 program_version_not_increasing): the controllers rely on strictly rising program versions per device. None of these refusals records a command, and the Idempotency-Key is not used up: a retry with the same key runs again. The 409 refusals and the 503 response are not part of the partner SDK clients (x-not-in-sdk).

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

CommandRequest (required)

Media type: application/json

Example request · application/json
{
  "name": "set_model",
  "params": {
    "version": "m9"
  }
}

Responses

StatusTypeDescription
202CommandIssued
application/json

Recorded and handed to the transport.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such device for this tenant.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (device_not_approved); or a set_program's program_version is not above the highest one already recorded for the device (program_version_not_increasing); nothing was recorded. Or the Idempotency-Key's first request is still running (retry after Retry-After seconds), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

#242: an actuation command was refused because the server has no platform command key to sign it with (command_signing_unavailable); nothing was recorded. Config commands are not affected.

Response headers

NameStatusTypeDescription
X-Request-Id202string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed202"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After503string

Seconds to wait before retrying.

Example responses

Response 202 · application/json
{
  "id": "6f1c1c52-62a0-4f0e-8c3a-0b7e8d6d3e10"
}
Response 400 · application/json · params
{
  "error": "params must be an object",
  "code": "params_must_be_an_object"
}
Response 400 · application/json · undeclared
{
  "error": "command 'reboot' not declared by profile vn.agritrace.durian-knocker",
  "code": "command_reboot_not_declared_by_profile_vn_agritrace_durian_knocker"
}
Response 400 · application/json · strict_json
{
  "error": "invalid params: a string holds U+0000",
  "code": "invalid_params"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · device_not_approved
{
  "error": "device not approved: knk-1",
  "code": "device_not_approved"
}
Response 409 · application/json · program_version_not_increasing
{
  "error": "program version not increasing: 7 is not above 7, the device's highest",
  "code": "program_version_not_increasing"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
Response 503 · application/json
{
  "error": "command signing unavailable",
  "code": "command_signing_unavailable"
}

GET /v1/gateways

Gateways of the caller's tenant

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · listGateways

Gateways ordered by id, with keyset pagination (at most 100 per page). Allowed for platform_admin, tenant_admin and auditor; gateways are site-wide, so operators are refused.

Parameters

NameInTypeDescription
cursor
optional
querystring

next_cursor of the previous page of gateways.

limit
optional
queryinteger

Page size, 1 to 100.

Responses

StatusTypeDescription
200GatewayPage
application/json

One page of gateways.

400Error
application/json

A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "gateway_id": "gw-01",
      "tenant": "coop-dl",
      "site": "ph1",
      "facility": "VN-TGPH-021",
      "display_name": "Packing hall gateway",
      "status": "active",
      "approval": "approved",
      "approval_reason": null,
      "approval_at": 1790000100
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/gateways

Register a gateway

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · createGateway

Registers an active gateway of the caller's tenant. The id must be unused by every tenant's gateways and devices: an existing record is never replaced. Audited (gateway.create). Allowed for platform_admin and tenant_admin.

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

GatewayCreate (required)

Media type: application/json

Example request · application/json
{
  "gateway_id": "gw-01",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "display_name": "Packing hall gateway"
}

Responses

StatusTypeDescription
201Gateway
application/json

The new gateway.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded). SELF-2-8 (#197): or the facility is a company's proposal CropPath has not approved yet.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 201 · application/json
{
  "gateway_id": "gw-01",
  "tenant": "coop-dl",
  "site": "ph1",
  "facility": "VN-TGPH-021",
  "display_name": "Packing hall gateway",
  "status": "active",
  "approval": "approved",
  "approval_reason": null,
  "approval_at": 1790000100
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_gateway_id
{
  "error": "invalid gateway_id: 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit",
  "code": "invalid_gateway_id"
}
Response 400 · application/json · unknown_facility
{
  "error": "unknown facility",
  "code": "unknown_facility"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · gateway_id_taken
{
  "error": "gateway id taken",
  "code": "gateway_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 409 · application/json · facility_not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/gateways/{id}/heartbeat

A gateway's newest status heartbeat

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · getGatewayHeartbeat

#24: the newest status heartbeat of a gateway of the caller's tenant. A gateway signs a status envelope about itself every 30 s by default (profile vn.agritrace.gateway, /developers/downloads/profiles/gateway.json: its gateway id as device.id, on the ingest route {tenant}/{site}/{gateway id}/status); the server keeps the newest one of each gateway, never as an envelope: ordered by seq, but a signed heartbeat with a lower seq and a later time is kept (a reset gateway) and a signed one with a higher seq and an earlier time is superseded; one dated past the server's maximum future skew is rejected (400 future_timestamp). heartbeat is null until the gateway sent one. A value the heartbeat did not carry is null. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Gateway id.

Responses

StatusTypeDescription
200GatewayHeartbeatStatus
application/json

The gateway's newest heartbeat, or null.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such gateway for this tenant: a gateway of another tenant answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "gateway_id": "gw-01",
  "heartbeat": {
    "received_at": 1790100030.25,
    "time": "2026-09-23T08:00:30.000+00:00",
    "seq": 2881,
    "signed": true,
    "outbox_depth": 3,
    "dead_letter_count": 0,
    "link": {
      "state": "connected"
    },
    "peripherals_ready": [
      {
        "device": "knk-1",
        "ready": true
      },
      {
        "device": "scale-1",
        "ready": false
      }
    ]
  }
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: gw-01",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/gateways/{id}/status-series

A gateway's status time series

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · getGatewayStatusSeries

#128: the status series of a gateway of the caller's tenant. The server stores at most one of the gateway's status heartbeats a minute (the first one it keeps in each UTC minute of reception) and adds it to the gateway's hourly rollup. grain=minute returns those samples; hourly (the default) the hourly rollups; daily the hourly rollups merged per UTC day. A rollup gives the number of samples, for the outbox depth, the dead-letter count and the devices listed and ready the minimum, maximum, mean (null when no sample carried the value) and count of the samples that carried it, and the samples per link state. Samples are kept 30 days and hourly rollups 2 years; the range is clipped to what is kept (from in the answer is the start actually read, aligned down to the grain) and is at most 1 day for minute, 31 days for hourly and 731 days for daily (range_too_long). The newest heartbeat itself is getGatewayHeartbeat. Same roles as listing the gateways; a gateway of another tenant answers exactly like a missing one. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Gateway id.

grain
optional
query"minute" | "hourly" | "daily"

A sample a minute, or the hourly or daily rollups.

from
optional
querystring

Start: an ISO 8601 date or date-time (+07:00 without an offset). Default: 1 day (minute), 7 days (hourly) or 365 days (daily) before to.

to
optional
querystring

End (excluded), as from. Default: now.

Responses

StatusTypeDescription
200GatewayStatusSeries
application/json

The series, oldest first.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such gateway for this tenant: a gateway of another tenant answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "gateway_id": "gw-01",
  "grain": "hourly",
  "bucket_s": 3600,
  "from": 1790100000,
  "to": 1790107200,
  "items": [
    {
      "bucket_start": 1790100000,
      "samples": 60,
      "outbox_depth": {
        "min": 0,
        "max": 12,
        "mean": 2.5,
        "count": 60
      },
      "dead_letter_count": {
        "min": 0,
        "max": 0,
        "mean": 0,
        "count": 60
      },
      "peripherals_ready": {
        "min": 1,
        "max": 2,
        "mean": 1.9,
        "count": 60
      },
      "peripherals_total": {
        "min": 2,
        "max": 2,
        "mean": 2,
        "count": 60
      },
      "link": {
        "connected": 58,
        "disconnected": 2,
        "unknown": 0
      }
    }
  ]
}
Response 400 · application/json · bad_grain
{
  "error": "bad grain: minute, hourly or daily",
  "code": "bad_grain"
}
Response 400 · application/json · bad_from
{
  "error": "bad from",
  "code": "bad_from"
}
Response 400 · application/json · bad_to
{
  "error": "bad to",
  "code": "bad_to"
}
Response 400 · application/json · bad_range
{
  "error": "bad range: from must be before to",
  "code": "bad_range"
}
Response 400 · application/json · range_too_long
{
  "error": "range too long",
  "code": "range_too_long"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: gw-01",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/keys

Device and gateway keys of the caller's tenant

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: tenant_read · listKeys

Keys ordered by kid, with keyset pagination (at most 100 per page); a key belongs to its owner's tenant. With owner, only that device's or gateway's keys. Never returns key material, only fingerprints. Allowed for platform_admin, tenant_admin and auditor.

Parameters

NameInTypeDescription
owner
optional
querystring

A device or gateway id of the caller's tenant.

cursor
optional
querystring

next_cursor of the previous page of keys.

limit
optional
queryinteger

Page size, 1 to 100.

Responses

StatusTypeDescription
200KeyPage
application/json

One page of keys.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

owner is not a device or gateway of the caller's tenant (missing and foreign alike).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "kid": "knk-1-2026",
      "owner_type": "device",
      "owner_id": "knk-1",
      "status": "active",
      "created_at": 1790000000.5,
      "revoked_at": null,
      "revoke_reason": null,
      "revoked_by": null,
      "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
      "fingerprint": "19fc…e0d9",
      "approval": "approved"
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · invalid_owner
{
  "error": "invalid owner: a device or gateway id",
  "code": "invalid_owner"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/keys

Register a public key for a device or gateway

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · createKey

Adds an active key. The PEM must be one PUBLIC KEY block holding an EC P-256 SubjectPublicKeyInfo (private keys, certificates, other curves and trailing data are refused); the canonical PEM is stored. The kid must be unused by every tenant and not reserved by the deployed seed (provisioning reserves every seed kid). #201: the key waits for a platform admin's approval whatever its owner's (an approved device or gateway is listed in the pending queue again); until then evidence it signs counts as Self-declared. Audited (key.create; the row keeps the kid and fingerprint, never the PEM). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

KeyCreate (required)

Media type: application/json

Example request · application/json
{
  "kid": "knk-1-2026",
  "owner_type": "device",
  "owner_id": "knk-1",
  "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhaFFjV3QAoRFgCMO0lO2g8XMPeCX\n0MemwTpR6thzbANTI0unLVbZ1TwEmvZdARGAPji8g2MlIm1UAXv95sLWcg==\n-----END PUBLIC KEY-----\n"
}

Responses

StatusTypeDescription
201Key
application/json

The new key.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

The owner is not a device or gateway of the caller's tenant (missing and foreign alike).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 201 · application/json
{
  "kid": "knk-1-2026",
  "owner_type": "device",
  "owner_id": "knk-1",
  "status": "active",
  "created_at": 1790000000.5,
  "revoked_at": null,
  "revoke_reason": null,
  "revoked_by": null,
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "approval": "pending"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_kid
{
  "error": "invalid kid: 1 to 128 letters, digits, '.', '_', ':' or '-', starting with a letter or digit",
  "code": "invalid_kid"
}
Response 400 · application/json · invalid_owner_type
{
  "error": "invalid owner_type: device or gateway",
  "code": "invalid_owner_type"
}
Response 400 · application/json · invalid_public_key_pem
{
  "error": "invalid public_key_pem: an EC P-256 public key as PEM SubjectPublicKeyInfo",
  "code": "invalid_public_key_pem"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: knk-1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · key_id_taken
{
  "error": "key id taken",
  "code": "key_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/keys/{kid}/revoke

Revoke a key

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · revokeKey

Marks the key revoked with its reason; ingest refuses it from then on. compromise also raises one high-severity key_compromised alert for the tenant. A revoked key cannot be revoked again (the first reason and time stay). Audited (key.revoke). Allowed for platform_admin and tenant_admin. Step-up (#87): a signed-in session of an account with two-step sign-in must have confirmed a code from its authenticator app (or a backup code) within the last 5 minutes and its password within the last 10 minutes, else 401 mfa_step_up_required before anything is done (no audit row): confirm both with POST /v1/auth/reauth, then repeat the request. A session of an account without two-step sign-in, API tokens and API clients are served as before.

Parameters

NameInTypeDescription
kid
required
pathstring

Key id.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

KeyRevoke (required)

Media type: application/json

Example request · application/json
{
  "reason": "rotation"
}

Responses

StatusTypeDescription
200Key
application/json

The key after revocation.

400Error
application/json

Invalid JSON, a reason other than rotation or compromise, or a bad X-Request-Id; or a malformed or repeated Idempotency-Key header.

401Error
application/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 (mfa_step_up_required, #87: confirm both with POST /v1/auth/reauth, then repeat the request; nothing was done and no audit row was written).

403Error
application/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).

404Error
application/json

No such key for this tenant: a key of another tenant's device or gateway answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The key is already revoked. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed (too large to store, or never recorded).

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "kid": "knk-1-2026",
  "owner_type": "device",
  "owner_id": "knk-1",
  "status": "revoked",
  "created_at": 1790000000.5,
  "revoked_at": 1790086400,
  "revoke_reason": "rotation",
  "revoked_by": "admin@coop.example",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "approval": "approved"
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · invalid_reason
{
  "error": "invalid reason: rotation or compromise",
  "code": "invalid_reason"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: knk-1-2026",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · key_already_revoked
{
  "error": "key already revoked",
  "code": "key_already_revoked"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/harvest-keys

Harvest app registrations of the caller's tenant

Authentication: cookie, bearer · listHarvestKeys

#160: registrations ordered by kid, with keyset pagination (at most 100 per page). An operator sees only those of its facilities. Allowed for platform_admin, tenant_admin, auditor and operator (its facilities).

Parameters

NameInTypeDescription
cursor
optional
querystring

next_cursor of the previous page of registrations.

limit
optional
queryinteger

Page size, 1 to 100.

Responses

StatusTypeDescription
200HarvestKeyPage
application/json

One page of registrations.

400Error
application/json

A cursor that is not one this API issued, a limit out of range, or a bad X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
      "device_id": "harvest-19fcfa6012e7f761a1f1e408",
      "tenant": "coop-dl",
      "facility": "VN-DL-PH-01",
      "label": "Weighing desk phone",
      "status": "pending",
      "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
      "fingerprint": "19fc…e0d9",
      "requested_by": "op@coop.example",
      "requested_at": 1790000000.5,
      "decided_by": null,
      "decided_at": null,
      "revoked_at": null,
      "revoke_reason": null
    }
  ],
  "next_cursor": null
}
Response 400 · application/json · bad_cursor
{
  "error": "bad cursor",
  "code": "bad_cursor"
}
Response 400 · application/json · bad_limit
{
  "error": "bad limit",
  "code": "bad_limit"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/harvest-keys

Ask to register a harvest app install's key

Authentication: cookie, bearer · registerHarvestKey

#160: the harvest app (/harvest) generated a non-extractable ECDSA P-256 key and sends its public half. The registration is pending until a tenant admin approves or rejects it. Sending the same key again for the same facility answers the stored registration with 200, whatever its status. Audited (harvest_key.register, with the kid, device, facility and fingerprint; never the PEM). Allowed for platform_admin, tenant_admin and operator (its facilities).

Parameters

NameInTypeDescription
Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

HarvestKeyRegister (required)

Media type: application/json

Example request · application/json
{
  "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone"
}

Responses

StatusTypeDescription
200HarvestKey
application/json

The same key was registered before for this facility: its registration, unchanged.

201HarvestKey
application/json

The new pending registration.

400Error
application/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.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed. SELF-2-8 (#197): or the facility is a company's proposal CropPath has not approved yet.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
  "device_id": "harvest-19fcfa6012e7f761a1f1e408",
  "tenant": "coop-dl",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone",
  "status": "approved",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "requested_by": "op@coop.example",
  "requested_at": 1790000000.5,
  "decided_by": "admin@coop.example",
  "decided_at": 1790003600,
  "revoked_at": null,
  "revoke_reason": null
}
Response 201 · application/json
{
  "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
  "device_id": "harvest-19fcfa6012e7f761a1f1e408",
  "tenant": "coop-dl",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone",
  "status": "pending",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "requested_by": "op@coop.example",
  "requested_at": 1790000000.5,
  "decided_by": null,
  "decided_at": null,
  "revoked_at": null,
  "revoke_reason": null
}
Response 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · invalid_public_key_pem
{
  "error": "invalid public_key_pem: an EC P-256 public key as PEM SubjectPublicKeyInfo",
  "code": "invalid_public_key_pem"
}
Response 400 · application/json · unknown_facility
{
  "error": "unknown facility",
  "code": "unknown_facility"
}
Response 400 · application/json · invalid_label
{
  "error": "invalid label: 1 to 100 characters without control characters",
  "code": "invalid_label"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · key_already_registered
{
  "error": "key already registered",
  "code": "key_already_registered"
}
Response 409 · application/json · key_id_taken
{
  "error": "key id taken",
  "code": "key_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 409 · application/json · facility_not_approved
{
  "error": "facility not approved",
  "code": "facility_not_approved"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/harvest-keys/{kid}

One harvest app registration

Authentication: cookie, bearer · getHarvestKey

#160: the registration's state; the app polls it while it waits for approval. Allowed for platform_admin, tenant_admin, auditor and operator (its facilities).

Parameters

NameInTypeDescription
kid
required
pathstring

Key id of the registration.

Responses

StatusTypeDescription
200HarvestKey
application/json

The registration.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
  "device_id": "harvest-19fcfa6012e7f761a1f1e408",
  "tenant": "coop-dl",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone",
  "status": "approved",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "requested_by": "op@coop.example",
  "requested_at": 1790000000.5,
  "decided_by": "admin@coop.example",
  "decided_at": 1790003600,
  "revoked_at": null,
  "revoke_reason": null
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/harvest-keys/{kid}/approve

Approve a pending harvest app registration

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · approveHarvestKey

#160: a tenant admin approved the registration (final). The install's device (profile vn.agritrace.harvest-app, active, at the registration's facility) and its active device key are created in the same transaction; ingest accepts its signed harvest envelopes from then on. The deciding actor is the principal. Audited (harvest_key.approve). Allowed for platform_admin and tenant_admin. Second admin approval (INTEGRITY-3, #203): while the company requires a second admin (PUT /v1/company/four-eyes), a direct call answers 403 second_admin_approval_required before anything is done (no audit row, no Idempotency-Key used): ask for it with POST /v1/approval-requests, and another admin of the company approves it.

Parameters

NameInTypeDescription
kid
required
pathstring

Key id of the registration.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Responses

StatusTypeDescription
200HarvestKey
application/json

The registration, approved.

400Error
application/json

The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
  "device_id": "harvest-19fcfa6012e7f761a1f1e408",
  "tenant": "coop-dl",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone",
  "status": "approved",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "requested_by": "op@coop.example",
  "requested_at": 1790000000.5,
  "decided_by": "admin@coop.example",
  "decided_at": 1790003600,
  "revoked_at": null,
  "revoke_reason": null
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · registration_already_decided
{
  "error": "registration already decided",
  "code": "registration_already_decided"
}
Response 409 · application/json · key_id_taken
{
  "error": "key id taken",
  "code": "key_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/harvest-keys/{kid}/reject

Reject a pending harvest app registration

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · rejectHarvestKey

#160: a tenant admin rejected the registration (final). No device or key is created; the install makes a new key. The deciding actor is the principal. Audited (harvest_key.reject). Allowed for platform_admin and tenant_admin.

Parameters

NameInTypeDescription
kid
required
pathstring

Key id of the registration.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Responses

StatusTypeDescription
200HarvestKey
application/json

The registration, rejected.

400Error
application/json

The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/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.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/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 (Retry-After), or it ran but its response cannot be replayed.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed200"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "kid": "harvest-19fcfa6012e7f761a1f1e408:k1",
  "device_id": "harvest-19fcfa6012e7f761a1f1e408",
  "tenant": "coop-dl",
  "facility": "VN-DL-PH-01",
  "label": "Weighing desk phone",
  "status": "rejected",
  "fingerprint_sha256": "19fcfa6012e7f761a1f1e408e6bc08ce10ce6a4347be82fd3c9ddf6a9fcfe0d9",
  "fingerprint": "19fc…e0d9",
  "requested_by": "op@coop.example",
  "requested_at": 1790000000.5,
  "decided_by": "admin@coop.example",
  "decided_at": 1790003600,
  "revoked_at": null,
  "revoke_reason": null
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 403 · application/json · company_read_only
{
  "error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
  "code": "company_read_only"
}
Response 404 · application/json
{
  "error": "not found: harvest-19fcfa6012e7f761a1f1e408:k1",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · registration_already_decided
{
  "error": "registration already decided",
  "code": "registration_already_decided"
}
Response 409 · application/json · key_id_taken
{
  "error": "key id taken",
  "code": "key_id_taken"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 409 · application/json · idempotency_key_unrecorded
{
  "error": "idempotency key used: the request ran but its response was not recorded",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices/{id}/placements

A device's placement versions

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · listDevicePlacements

SENS-A2 (#225): every placement version CropPath recorded for a device of the company, newest first, with the growing area it is bound to, the surveyed install point and the commissioning record. Same roles as reading the device; an operator reads only devices of its facilities. recorded_by (who at CropPath recorded it) is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Responses

StatusTypeDescription
200DevicePlacements
application/json

The device's placement versions.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "device_id": "soil-07",
  "registered_before_placements": false,
  "items": [
    {
      "device_id": "soil-07",
      "version": 2,
      "mobility": "fixed",
      "key_protection": "hardware",
      "gnss": false,
      "growing_area": "VN-TG-CL-0042",
      "lat": 10.3512345,
      "lon": 106.1234567,
      "accuracy_m": 3.5,
      "fix_at": 1790100000,
      "installed_at": 1790100600,
      "installer": "Nguyen Van A",
      "photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
      "depth_cm": 30,
      "sensor_serial": "RS485-4IN1-00172",
      "note": "Moved to block B after replanting",
      "removed_at": null,
      "recorded_at": 1790101000,
      "valid_until": null
    },
    {
      "device_id": "soil-07",
      "version": 1,
      "mobility": "fixed",
      "key_protection": "hardware",
      "gnss": false,
      "growing_area": "VN-TG-CL-0042",
      "lat": 10.3509876,
      "lon": 106.1229876,
      "accuracy_m": 4,
      "fix_at": 1780000000,
      "installed_at": 1780000600,
      "installer": "Nguyen Van A",
      "photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
      "depth_cm": 30,
      "sensor_serial": "RS485-4IN1-00172",
      "note": null,
      "removed_at": null,
      "recorded_at": 1790101000,
      "valid_until": 1790100600
    }
  ]
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: soil-07",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices/{id}/calibrations

A device's calibrations

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · listDeviceCalibrations

SENS-B1d (#234): every calibration recorded for a device of the company, newest first, with the one that supersedes each (superseded_by). sensor_serial lists one probe's only. Same roles as reading the device; an operator reads only devices of its facilities. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

sensor_serial
optional
querystring

Only the calibrations of this probe serial (1 to 100 characters).

Responses

StatusTypeDescription
200Calibrations
application/json

The device's calibrations.

400Error
application/json

A bad sensor_serial or X-Request-Id.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "device_id": "soil-07",
  "items": [
    {
      "id": 12,
      "device_id": "soil-07",
      "sensor_serial": "RS485-4IN1-00172",
      "capability": "soil.ph",
      "calibrated_at": 1790000000,
      "method": "ph_buffers",
      "reference_values": {
        "buffers_ph": [
          4.01,
          7,
          10.01
        ]
      },
      "coefficients": {
        "offset": -0.03,
        "slope": 0.987
      },
      "performer": "Can Tho soil laboratory",
      "accreditation": "iso17025_lab",
      "certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
      "valid_until": 1805552000,
      "supersedes": null,
      "created_at": 1790001000,
      "created_by": "admin@coop.example",
      "superseded_by": null
    }
  ]
}
Response 400 · application/json · sensor_serial
{
  "error": "bad sensor_serial",
  "code": "bad_sensor_serial"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: soil-07",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/devices/{id}/calibrations

Record a device calibration

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_admin · recordDeviceCalibration

SENS-B1d (#234): a company admin, or a platform admin acting for the company (X-Tenant), records a calibration of one of the company's devices, with its certificate (uploaded first with PUT /v1/attachments/{sha256}, or sent in certificate). Calibrations are append-only: a correction is a new calibration that names the one it corrects (supersedes); the corrected one is kept. Audited (device.calibration) in the company's activity log. Allowed for tenant_admin and platform_admin (and an API client with device_admin). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

CalibrationCreate (required)

Media type: application/json

Example request · application/json
{
  "sensor_serial": "RS485-4IN1-00172",
  "capability": "soil.ph",
  "calibrated_at": 1790000000,
  "method": "ph_buffers",
  "reference_values": {
    "buffers_ph": [
      4.01,
      7,
      10.01
    ]
  },
  "coefficients": {
    "offset": -0.03,
    "slope": 0.987
  },
  "performer": "Can Tho soil laboratory",
  "accreditation": "iso17025_lab",
  "certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
  "valid_until": 1805552000
}

Responses

StatusTypeDescription
201Calibration
application/json

The calibration recorded.

400Error
application/json

An unknown, missing or malformed field (a calibrated_at before 2020 or more than 300 s ahead, a valid_until not after it or more than about five years later, a value outside an enum, JSON values too large, too deep or with a number that is not finite, a capability outside the vocabulary that is not an x- extension), a certificate whose bytes do not hash to certificate_sha256 (certificate_hash_mismatch) or are not its media type, a certificate_sha256 the company's uploads do not hold as a PDF, JPEG or PNG when no certificate is sent, a supersedes that is not a calibration of this device, a bad X-Request-Id or Idempotency-Key.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/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).

404Error
application/json

No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The calibration named by supersedes is superseded already (correct the one that superseded it). Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Idempotent-Replayed201"true"

true when the response is the stored response of an earlier request with the same Idempotency-Key.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 201 · application/json
{
  "id": 12,
  "device_id": "soil-07",
  "sensor_serial": "RS485-4IN1-00172",
  "capability": "soil.ph",
  "calibrated_at": 1790000000,
  "method": "ph_buffers",
  "reference_values": {
    "buffers_ph": [
      4.01,
      7,
      10.01
    ]
  },
  "coefficients": {
    "offset": -0.03,
    "slope": 0.987
  },
  "performer": "Can Tho soil laboratory",
  "accreditation": "iso17025_lab",
  "certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
  "valid_until": 1805552000,
  "supersedes": null,
  "created_at": 1790001000,
  "created_by": "admin@coop.example",
  "superseded_by": null
}
Response 400 · application/json · unknown_field
{
  "error": "unknown field",
  "code": "unknown_field"
}
Response 400 · application/json · missing_field
{
  "error": "missing field: valid_until",
  "code": "missing_field"
}
Response 400 · application/json · valid_until
{
  "error": "invalid valid_until: after calibrated_at",
  "code": "invalid_valid_until"
}
Response 400 · application/json · hash_mismatch
{
  "error": "certificate hash mismatch: the certificate does not hash to certificate_sha256",
  "code": "certificate_hash_mismatch"
}
Response 400 · application/json · unknown_certificate
{
  "error": "unknown certificate_sha256: upload the certificate (PDF, JPEG or PNG) first",
  "code": "unknown_certificate_sha256"
}
Response 400 · application/json · unknown_supersedes
{
  "error": "unknown supersedes: not a calibration of this device",
  "code": "unknown_supersedes"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 403 · application/json · origin
{
  "error": "origin not allowed",
  "code": "origin_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: soil-07",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · superseded
{
  "error": "calibration superseded: correct the record that superseded it",
  "code": "calibration_superseded"
}
Response 409 · application/json · idempotency_in_progress
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/devices/{id}/metadata

A device's metadata

Authentication: cookie, bearer, oauth2 · OAuth2 scopes: device_read · getDeviceMetadata

SENS-B1d (#234): a device's placement version in force (#225) and its calibrations not superseded: the document an EPCIS deviceMetadata link of the device's readings can name later (/v1/devices/{id}/metadata on this deployment's origin). For the device's company (the roles that read the device; an operator only for devices of its facilities) and platform admins acting for it; never public, and another company's device answers 404. recorded_by of the placement is returned to platform admins only. Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Device id.

Responses

StatusTypeDescription
200DeviceMetadata
application/json

The device's metadata.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session, API token or legacy token.

403Error
application/json

The caller is known but refused: role not permitted or tenant not allowed (X-Tenant).

404Error
application/json

No such device for this company: a device of another company, or outside an operator's facilities, answers exactly like a missing one.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "device_id": "soil-07",
  "placement": {
    "device_id": "soil-07",
    "version": 2,
    "mobility": "fixed",
    "key_protection": "hardware",
    "gnss": false,
    "growing_area": "VN-TG-CL-0042",
    "lat": 10.3512345,
    "lon": 106.1234567,
    "accuracy_m": 3.5,
    "fix_at": 1790100000,
    "installed_at": 1790100600,
    "installer": "Nguyen Van A",
    "photo_sha256": "9b2f00000000000000000000000000000000000000000000000000000000a17c",
    "depth_cm": 30,
    "sensor_serial": "RS485-4IN1-00172",
    "note": "Moved to block B after replanting",
    "removed_at": null,
    "recorded_at": 1790101000,
    "valid_until": null
  },
  "calibrations": [
    {
      "id": 12,
      "device_id": "soil-07",
      "sensor_serial": "RS485-4IN1-00172",
      "capability": "soil.ph",
      "calibrated_at": 1790000000,
      "method": "ph_buffers",
      "reference_values": {
        "buffers_ph": [
          4.01,
          7,
          10.01
        ]
      },
      "coefficients": {
        "offset": -0.03,
        "slope": 0.987
      },
      "performer": "Can Tho soil laboratory",
      "accreditation": "iso17025_lab",
      "certificate_sha256": "5d41402abc4b2a76b9719d911017c592ae2f1f9e2c1b0a7d9b8e3f4a6c2d1e0f",
      "valid_until": 1805552000,
      "supersedes": null,
      "created_at": 1790001000,
      "created_by": "admin@coop.example",
      "superseded_by": null
    }
  ],
  "as_of": 1790200000
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 404 · application/json
{
  "error": "not found: soil-07",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

GET /v1/gateways/{id}/station-delegations

The pending and active station sign-ins at a gateway

Authentication: cookie · listStationSignIns

Session only — not available to API tokens or OAuth clients

#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. The station sign-ins at the gateway that are pending (the code not typed yet, still valid) or active (claimed by the station, not ended, not revoked), the active ones first, each group newest first, at most 100 (an operator has at most 3 codes waiting at a station, so codes never push an active sign-in off the list): the caller's own, or every operator's for a company admin. Never the code. A gateway of another company, or out of an operator's facilities, answers like a missing one. Not audited (a read). Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Gateway id (the edge station's).

Responses

StatusTypeDescription
200StationDelegationList
application/json

The sign-ins.

400Error
application/json

The X-Request-Id header is present and malformed.

401Error
application/json

No valid session.

403Error
application/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.

404Error
application/json

No such gateway (or another company's, or out of the operator's facilities).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "items": [
    {
      "id": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
      "gateway": "gw-01",
      "operator": "user-7",
      "state": "active",
      "issued_at": 1790560000,
      "code_expires_at": 1790560600,
      "expires_at": 1790588800,
      "claimed_at": 1790560100,
      "revoked_at": null
    }
  ]
}
Response 400 · application/json
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 404 · application/json
{
  "error": "not found: gw-01",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/gateways/{id}/station-delegations

Sign in at an edge station (a one-time code to type there)

Authentication: cookie · createStationSignIn

Session only — not available to API tokens or OAuth clients

#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. The signed-in person lets the gateway's edge station record offline actions (accept a fruit, re-measure it, print its labels) for them until expires_at (lifetime_s, 900 to 28800 seconds, default 28800: at most one shift). The answer carries a one-time code (8 characters, valid 10 minutes, shown only here; only its SHA-256 is kept; at most 3 waiting per person and station, else 409 too_many_pending) that the operator types on the station's screen; the station claims it with a request signed by its own key (POST /v1/gateways/{id}/station-delegations/claim). No credential reaches the station: it can only record actions that the cloud checks when the station replays them (POST /v1/gateways/{id}/station-actions), and they count at most as Device-recorded. Audited (station.delegation.issue, never the code) in the company's activity log. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Gateway id (the edge station's).

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Request body

StationSignInRequest (optional)

Media type: application/json

Example request · application/json
{
  "lifetime_s": 28800
}

Responses

StatusTypeDescription
201StationSignIn
application/json

The sign-in, with its one-time code.

400Error
application/json

A bad body, a bad X-Request-Id, or a malformed or repeated Idempotency-Key header.

401Error
application/json

No valid session.

403Error
application/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.

404Error
application/json

No such gateway (or another company's, or out of the operator's facilities).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

The gateway is not active, or the caller already has 3 sign-in codes waiting (not typed yet, still valid) at this station (too_many_pending: type one or revoke one first). Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

413Error
application/json

The request body is over 1 MiB.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 201 · application/json
{
  "id": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
  "gateway": "gw-01",
  "operator": "user-7",
  "state": "pending",
  "issued_at": 1790560000,
  "code_expires_at": 1790560600,
  "expires_at": 1790588800,
  "claimed_at": null,
  "revoked_at": null,
  "code": "K7MQ2XPA"
}
Response 400 · application/json · lifetime
{
  "error": "invalid lifetime_s: whole seconds from 900 to 28800",
  "code": "invalid_lifetime_s"
}
Response 400 · application/json · body
{
  "error": "invalid body: only lifetime_s",
  "code": "invalid_body"
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 404 · application/json
{
  "error": "not found: gw-01",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · gateway_inactive
{
  "error": "gateway inactive: the station's gateway is not active",
  "code": "gateway_inactive"
}
Response 409 · application/json · too_many_pending
{
  "error": "too many pending: 3 sign-in codes are already waiting at this station; type one or revoke one first",
  "code": "too_many_pending"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}

POST /v1/station-delegations/{id}/revoke

Revoke a station sign-in

Authentication: cookie · revokeStationSignIn

Session only — not available to API tokens or OAuth clients

#85 (owner decision 2026-10-17, option b): operators keep working at an edge station with the WAN down. Revokes a station sign-in: the operator's own, or any of the company's for a company admin. From then on the station records nothing more under it (it learns of it on its next sync or replay and ends the operator's local session), and no action it recorded under it and has not replayed yet is applied (403 delegation_revoked). Another operator's sign-in, another company's or one at a gateway out of the operator's facilities answers like a missing one; one already revoked is 409. Audited (station.delegation.revoke) in the company's activity log. Allowed for tenant_admin and platform_admin (acting for the company through X-Tenant) and for an operator within its facilities (the gateway's), through a signed-in session only: an API token, an API client or the legacy token is refused (403); auditors and labs are refused (403). Added after the partner SDK 0.2.0 (x-not-in-sdk): not part of the generated SDK clients.

Parameters

NameInTypeDescription
id
required
pathstring

Station sign-in id.

Idempotency-Key
optional
headerstring

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 Idempotent-Replayed: true, without running the operation again or writing another audit row. The same key with another request is 422 idempotency_key_mismatch; while the first request still runs it is 409 idempotency_key_in_use with Retry-After. A request that fails before its operation commits releases the key, so it may be sent again (corrected) with the same key. An operation that committed is never run again under its key, even when its response could not be recorded (a 500 after the commit; a server stop or a database error between the commit and the record): the retry is 409 idempotency_key_in_use for up to 5 minutes, then 409 idempotency_key_used until the key expires. A malformed or repeated header is 400 invalid_idempotency_key.

Responses

StatusTypeDescription
200StationDelegation
application/json

Revoked.

400Error
application/json

The X-Request-Id header is present and malformed, or the Idempotency-Key header is malformed or repeated.

401Error
application/json

No valid session.

403Error
application/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.

404Error
application/json

No such sign-in for the caller.

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

409Error
application/json

Already revoked. Or the Idempotency-Key's first request is still running (Retry-After), or it ran but its response cannot be replayed.

422Error
application/json

The Idempotency-Key was used by this principal within 24 hours with another method, path, query or body.

500Error
application/json

Unexpected failure; the detail is only in the server log.

Response headers

NameStatusTypeDescription
X-Request-Id200string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id401string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id403string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id409string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Retry-After409string

Seconds to wait before retrying.

X-Request-Id422string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Example responses

Response 200 · application/json
{
  "id": "3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
  "gateway": "gw-01",
  "operator": "user-7",
  "state": "revoked",
  "issued_at": 1790560000,
  "code_expires_at": 1790560600,
  "expires_at": 1790588800,
  "claimed_at": 1790560100,
  "revoked_at": 1790570000
}
Response 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
Response 400 · application/json · invalid_idempotency_key
{
  "error": "invalid idempotency key: one header of 1 to 255 visible ASCII characters",
  "code": "invalid_idempotency_key"
}
Response 401 · application/json
{
  "error": "missing or invalid token",
  "code": "missing_or_invalid_token"
}
Response 403 · application/json · role
{
  "error": "role not permitted",
  "code": "role_not_permitted"
}
Response 403 · application/json · tenant
{
  "error": "tenant not allowed",
  "code": "tenant_not_allowed"
}
Response 403 · application/json · csrf
{
  "error": "csrf token missing or invalid",
  "code": "csrf_token_missing_or_invalid"
}
Response 404 · application/json
{
  "error": "not found: 3f9c2b1e8a7d4c6b9e0f1a2b3c4d5e6f",
  "code": "not_found"
}
Response 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
Response 409 · application/json · delegation_revoked
{
  "error": "delegation revoked: the station sign-in is already revoked",
  "code": "delegation_revoked"
}
Response 409 · application/json · idempotency_key_in_use
{
  "error": "idempotency key in use: retry later",
  "code": "idempotency_key_in_use"
}
Response 409 · application/json · idempotency_key_used
{
  "error": "idempotency key used: the response is too large to replay",
  "code": "idempotency_key_used"
}
Response 422 · application/json
{
  "error": "idempotency key mismatch: the key was used with another request",
  "code": "idempotency_key_mismatch"
}
Response 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}