Skip to content

Change a device

PATCH
/api/tenants/{tenant}/devices/{endpoint}/{device}
curl --request PATCH \
--url http://127.0.0.1:9090/api/tenants/acme/devices/office/CG0001 \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: 0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09' \
--header 'X-Request-Id: 4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7f' \
--data '{ "labels": { "floor": null, "site": "north" }, "status": "allowed" }'

Allows or blocks a device, gives it a new key or takes its key away, adopts the key it presents, or changes its own labels. Fields left out are not changed; the body is checked whole before anything changes.

A new key is kept and the package is asked for the commands that give it to the device: they are queued and returned in commands. Until the device presents the new key it is let in with the one it had.

A change to the labels is told to the device’s sync group, whose placement rules pick members by them.

The change is added to the audit trail.

tenant
required
string

The tenant’s id.

Example
acme
endpoint
required
string

The device’s endpoint.

Example
office
device
required
string

The device’s id.

Example
CG0001
X-Request-Id
string
<= 128 characters /^[A-Za-z0-9._:-]+$/

An id to follow the request by: answered back in X-Request-Id, and in the log, the audit trail and the events the request causes. 1 to 128 letters, digits, -, _, . or :; anything else is replaced by a new id.

Example
4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7f
Idempotency-Key
string
>= 1 characters <= 255 characters

Does the request once, however often it is sent with this key, for 24 hours: sent again with the same request, it is answered as it was the first time (Idempotent-Replayed: true); with another, 422; while the first runs still, 409.

Example
0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09
Media typeapplication/json

A change to a device: each field left out is not changed.

object
adopt_key

True makes a key the device presented its active key: how a device refused for presenting another key is let in again. For a device that presented a key while it was held (key_held), the first key it presented then, the one seen when deciding to allow it, never a later one; else the key it is presenting.

boolean
adopt_presented_key

True makes the key the device is presenting now its active key, whatever it was held with: the choice to make, knowingly, after a key_conflict_at.

boolean
external_ids

What other systems know the device by, merged in as labels is: a text sets a system’s id, null takes it away. At most 32 systems.

object | null
key

A string sets the key (1 to 128 characters, none of them control characters), null takes it away, leaving it out changes nothing.

string | null
labels

The device’s own labels, merged in as a JSON merge patch does: a value sets the label, null takes it away, a label left out stays. They are put over its endpoint’s labels; a sync group’s placement rules pick members by them. At most 64 labels; a name is 1 to 63 letters, digits, -, _, . or /, a value 1 to 63 letters, digits, -, _ or ..

object | null
metadata

Free-form data from other systems, merged in as a JSON merge patch. Kept as given (at most 16 KiB of JSON), never read by Connect.

object | null
status
One of:
null
Example
{
"labels": {
"floor": null,
"site": "north"
},
"status": "allowed"
}

Changed: the device as it is now, with its own labels, and the commands queued to give it its new key (none unless key was set).

Media typeapplication/json

A device and the commands queued for it by the change.

object
commands
required

The commands queued to give the device its new key; empty when the key did not change.

Array<object>

A command: one message the package builds for a device, queued, handed out and answered. Parameters the package marks sensitive are shown as <redacted N bytes>, and so is the payload that carries them.

object
action
required

The package command it is (its key among the package’s commands).

string
action_id

The action it is a step of, if it is one.

integer | null format: int64
completed_at

When it finished (answered, cancelled or skipped); null until then.

string | null format: date-time
created_at
required

When it was queued.

string format: date-time
expires_at

Not handed out by then, it never is.

string | null format: date-time
gate

A gate of its action: handed out on its own, and the steps after it wait for it to succeed.

boolean
id
required

The command’s id, unique across the gateway.

integer format: int64
lane
required

The lane it queues in.

string
Allowed values: urgent interactive sync bulk
params
required

Its parameters, by name, sensitive values redacted.

object
payload
required

What the device is handed, as text (“” when it is not text).

string
payload_base64

What the device is handed, base64-encoded, when it is not text.

string | null
result

What the device answered, as text; null until it answers.

string | null
result_base64

The result, base64-encoded, when the device returned something that is not text.

string | null
result_code

The code the device answered with, as the package reads it; null until it answers.

integer | null format: int64
retry_at

Parked until then: the device answered “not yet, ask again”.

string | null format: date-time
sent_at

When it was handed to the device; null until then.

string | null format: date-time
status
required

Where a command stands: queued (waiting to be handed to the device), offered (written into a reply to the device, no result yet), succeeded, failed, unanswered (offered, then lost: the device answered a command handed out after it, and it had been handed out twice; a result that comes later still completes it), cancelled (taken back before it was handed out: its action was cancelled or expired), skipped (an earlier step of its action failed before it was handed out) or parked (waiting behind a gate of its action that has not passed, or asked to be sent again later: retry_at).

string
Allowed values: queued offered succeeded failed unanswered cancelled skipped parked
tries

How many times it has been handed to the device (more than once when the device answered “not yet, ask again”).

integer format: int32
device
required

The device as it is now.

object
device
required

The id the package identifies the device by: a serial number, a MAC address, a cloud id.

string
endpoint
required

The endpoint it belongs to.

string
first_seen

None for a device that was registered and has not called in yet.

string | null format: date-time
health

How its messages have gone, counted by every instance that serves it.

object
errors
required

Of those, the ones that failed: the package failed, no route matched, or what it changed could not be stored.

integer format: int64
last_error
One of:
null
messages
required

Messages that got past its key: taken in, or refused for its status.

integer format: int64
held
One of:
null
id
required

The device’s number in the register.

integer format: int64
info
required

Facts the package reported: firmware, IP, user counts, capabilities.

object
key
required

Where it stands with its key.

string
Allowed values: none pending active
key_conflict_at

When the device, while held, last presented a key other than the one it was held with: someone else may be calling under its name. Adopting takes the key it was held with all the same; adopt_presented_key takes the latest instead. Cleared when its key is set, adopted or taken away.

string | null format: date-time
key_held

The device presented a key while it was held (waiting to be allowed, with no key of its own), and the first such key is kept: adopting its key takes that one, the key it was held with, not a later one.

boolean
key_presented
required

What its latest message carried for a key.

string
Allowed values: none registered unregistered
key_refused_at

When a message was last refused for carrying the wrong key, or none.

string | null format: date-time
last_seen

When its latest message came, as the instances that serve it know; null until it calls in.

string | null format: date-time
params
required

Values captured from the endpoint’s path or topic template on the latest message it was let in on (its first, until then); used to address replies (e.g. MQTT reply topics).

object
key
additional properties
string
remote_ip
required

The address its latest message came from, of those it was let in on (its first message, until it is let in; “” until it calls in). A message refused for the device’s status or rate moves nothing.

string
status
required

Whether a device may talk to the gateway: pending (known, waiting for someone to allow or block it; its messages are refused meanwhile), allowed (its messages are taken in) or blocked (its messages are refused until someone allows it).

string
Allowed values: pending allowed blocked
external_ids

What other systems know the device by: system name to id.

object
key
additional properties
string
labels

The device’s own labels, by name: what a sync group’s placement rules pick members by, together with its endpoint’s labels (the device’s own win where both name one).

object
metadata

Free-form data from other systems, kept as given.

object
Example
{
"commands": [],
"device": {
"device": "CG0001",
"endpoint": "office",
"first_seen": "2026-01-15T08:00:00Z",
"health": {
"errors": 1,
"last_error": {
"at": "2026-01-15T07:58:00Z",
"reason": "line 3: '2026-13-01 08:00:00' is not a time",
"route": "attlog"
},
"messages": 1520
},
"id": 42,
"info": {
"firmware": "3.4.0",
"punches": 1830,
"users": 25
},
"key": "active",
"key_presented": "registered",
"key_refused_at": null,
"labels": {
"site": "north"
},
"last_seen": "2026-01-15T08:05:00Z",
"params": {},
"remote_ip": "192.0.2.10",
"status": "allowed"
}
}

Not valid: a label value that is not text or null, a label name or value that is not acceptable, more than 64 labels, a key that is not acceptable or that the package cannot build the commands for, adopt_key for a device that has presented no key, or a device whose endpoint is not configured. A body that is not JSON is refused with 400, and one with an unknown field or a value of the wrong type with 422.

Media typeapplication/json

A refusal, and why.

object
error
required

Why the request was refused, in a sentence.

string
fields

For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.

Array<object>

What is wrong with one field of a request.

object
field
required

The parameter, as the request names it (values.volume for a setting inside values).

string
message
required

What is wrong with it.

string
request_id

The request’s id, as its X-Request-Id header gives it: what to quote when asking what happened to it.

string | null
Example
{
"error": "the device has not presented a key"
}

A login is configured and the request carries neither it nor an API token, or it carries a wrong login (WWW-Authenticate: Basic realm="Hour Advantage", no body). Or the request carries an API token that is not one (revoked, or never made), login or not (WWW-Authenticate: Bearer realm="Hour Advantage", error="invalid_token", the body the API token was refused).

Media typetext/plain
string
Example
the API token was refused
WWW-Authenticate
string

The scheme to answer with: Basic realm="Hour Advantage", or for a refused token Bearer realm="Hour Advantage", error="invalid_token".

The Host header does not name a loopback address while one is required (no login configured, or the API listens on loopback), or the Origin header does not match the Host: {"error": ...} says which. Or no login is configured and the request carries Forwarded, X-Forwarded-For or X-Real-IP (a proxy forwarded it): the plain text body says so. Or an API token asks for a route its scope does not reach: the plain text body says so.

A refusal, and why.

object
error
required

Why the request was refused, in a sentence.

string
fields

For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.

Array<object>

What is wrong with one field of a request.

object
field
required

The parameter, as the request names it (values.volume for a setting inside values).

string
message
required

What is wrong with it.

string
request_id

The request’s id, as its X-Request-Id header gives it: what to quote when asking what happened to it.

string | null
Example
{
"error": "the Host must name this machine (localhost or a loopback address); an API reached by other names needs the admin login"
}

The endpoint has no such device.

Media typeapplication/json

A refusal, and why.

object
error
required

Why the request was refused, in a sentence.

string
fields

For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.

Array<object>

What is wrong with one field of a request.

object
field
required

The parameter, as the request names it (values.volume for a setting inside values).

string
message
required

What is wrong with it.

string
request_id

The request’s id, as its X-Request-Id header gives it: what to quote when asking what happened to it.

string | null
Example
{
"error": "device not found"
}

More than 2 admin logins are being checked at once: send the request again after the Retry-After seconds. A request carrying the login that checked out last, or an API token, is not held up.

Media typetext/plain
string
Example
too many logins at once; try again
Retry-After
integer

Seconds to wait: 1.

Something went wrong in the gateway that asking again will not put right by itself; error says what.

Media typeapplication/json

A refusal, and why.

object
error
required

Why the request was refused, in a sentence.

string
fields

For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.

Array<object>

What is wrong with one field of a request.

object
field
required

The parameter, as the request names it (values.volume for a setting inside values).

string
message
required

What is wrong with it.

string
request_id

The request’s id, as its X-Request-Id header gives it: what to quote when asking what happened to it.

string | null
Example
{
"error": "db error: ERROR: permission denied for table settings"
}

The database cannot be used right now (not reachable, too busy, no connection free in time), or the instance is still starting: send the same request again shortly. An API token that cannot be checked for the same reason is answered 503 in plain text (the API token cannot be checked right now; try again shortly).

Media typeapplication/json

A refusal, and why.

object
error
required

Why the request was refused, in a sentence.

string
fields

For a request whose parameters do not fit (422): what is wrong with each field. Absent otherwise.

Array<object>

What is wrong with one field of a request.

object
field
required

The parameter, as the request names it (values.volume for a setting inside values).

string
message
required

What is wrong with it.

string
request_id

The request’s id, as its X-Request-Id header gives it: what to quote when asking what happened to it.

string | null
Example
{
"error": "the gateway is starting; try again shortly"
}