Companion Pairing and Command Receipts
Device proof, pairing a device into a project, provisioning its access point and recording a command outcome are separate steps. Start with Readers and Device Provisioning and a supported client release. The backend contracts below do not establish that every Companion build implements them. Deployment, broker/provider configuration and device recovery procedures stay with the platform owner.
Routes and identity
These routes use /api/v1 without team/project URL prefixes:
| POST path | Caller and purpose |
|---|---|
/device-pairing/challenge | Issue a short-lived App Attest challenge. |
/device-pairing/attest | Register an App Attest key when that deployment driver is enabled. |
/device-pairing/bootstrap | Prove device identity and receive per-device broker configuration/credentials. |
/device-pairing/claim | Authenticated caller with reader-create policy claims a code into a project. |
/companion/pairing-code | An unclaimed device requests an HTTP pairing-screen code. |
/companion/commands/{uuid}/response | Known device submits a receipt for its own command. |
Attest/bootstrap and command receipt use device-specific proof rather than an administrator bearer. Challenge issuance itself precedes that proof. The HTTP code request intentionally precedes a device credential; a code alone cannot claim a project. Claim requires authenticated project authority. Do not substitute a reader login, project key or attendee session for the wrong caller role, or assume removing auth:sanctum removes the device assertion check.
Device proof and bootstrap
Keep a stable per-install device_id string, up to 255 characters. It becomes the broker client ID/reader identifier; it is not the numeric reader ID. Select the client sequence for the deployment's configured driver:
Device-key driver: bootstrap supplies device_id, assertion and, on first contact, public_key in PEM form. The assertion is an ES256 JWT with sub exactly equal to device ID, positive iat/exp, lifetime no longer than 120 seconds and unique nonempty jti. The reviewed verifier permits at most 120 seconds of age and 30 seconds of future issue-time tolerance, subject also to JWT-library checks. Reused assertions are rejected. The stored key takes precedence after registration; sending a new public key is not a key-rotation command. This proof establishes key possession, not genuine-app provenance.
App Attest driver: obtain a fresh challenge, register the attestation with /attest when needed, then bootstrap with a fresh assertion, registered key_id and challenge. Attestation/assertion are base64 strings for the appropriate CBOR data, not a device-key JWT. Challenge response is direct JSON with challenge and expires_in (default 300 seconds, configurable). Consumed/expired/reused challenges fail; validation/proof failures can consume a challenge before the request completes, so obtain fresh proof for a retry. Successful attest returns {"registered":true}; disabled driver or already-claimed registration can return 409. Driver availability does not prove real-device attestation acceptance; confirm the supported deployment/client.
Bootstrap optionally accepts platform (up to 50 characters) and model (up to 100). Success returns direct broker configuration: broker_host, tls_port, tls_enabled, topic_prefix, client_id, mqtt_username, mqtt_password, pairing/status/command topics and command_response_url. Treat passwords and proof material as device secrets; use the returned supported connection settings and keep them out of logs, analytics and public app bundles.
Bootstrap is a write that can issue/rotate a per-device credential, not a health read. It normally operates on an unclaimed reader. The service has assertion-backed exceptions for a claimed device that has not received its claim and revoked-device re-entry; other claimed devices return 409. Revocation is not a permanent fleet ban in this flow. Do not invent a general reset procedure from these exceptions; use the supported owner/client recovery workflow and verify project/credential state separately.
HTTP code and project claim
For a supported pair-on-boot device, POST /companion/pairing-code with stable device ID and optional platform/model. This creates/updates an unclaimed reader and returns code plus expires_at. Codes are six-digit strings generated by the service; preserve leading zeros. Default lifetime is 600 seconds, configurable. Requesting a new code supersedes the previous one. Existing claimed/revoked records are rejected with 409 by this unauthenticated route.
A metadata-bearing code refresh replaces the unclaimed record's stored device-info map in the reviewed service. Do not assume existing proof metadata survives mixing onboarding paths; verify the intended supported client sequence. Code requests are not passive presence checks.
The authorized claim request uses a numeric project ID named experience_id, an optional same-project numeric access_point_id, and the displayed code. This synthetic example is not sent:
{
"experience_id": 123,
"access_point_id": 456,
"code": "001234"
}
Claim checks reader-create policy in the resolved project/team context. It can pair without an access point; claiming does not prove an operational scan assignment or connected device. A device need not currently be broker-connected for the claim service to proceed. Supplying an access point requires it to belong to the chosen project.
Read ok, not HTTP status alone. An invalid/expired code produces a generic HTTP 200 failure, for example:
{
"ok": false,
"message": "That code is not valid. Check the device screen and try again."
}
Successful claim returns HTTP 200 with ok: true, device_id and string experience_id. Policy denial is 403, wrong access point is 422 and redeem lockout is 429. Failed code lookup contributes to per-caller/IP lockout; the reviewed threshold is five failures with a 300-second cooldown. Reconcile a lost successful response through the authorized device listing rather than repeatedly redeeming a spent code.
Command receipts
POST /companion/commands/{uuid}/response uses the returned command response URL template and a command/batch UUID. It requires device ID and fresh assertion, with App Attest key/challenge when that driver applies. It never accepts first-contact public-key trust; the device must already have a stored key. Command lookup is scoped to rows belonging to that device identifier, including its historical reader records. The UUID alone is not authority to answer another device's command.
Required status is completed, failed, rejected or expired. Optional code is up to 100 characters and message up to 1000; persistence truncates the message to 255. Optional result is a JSON-encoded string, even in a JSON request; decoded scalar results are wrapped under value, while JSON null becomes null. With attachments use multipart: at most five files, each at most 10 MiB, with PNG/JPEG/plain text/JSON/ZIP MIME types. Repeat the multipart file field named attachments[] for each file.
The service settles a pending row, or accepts a timeout-to-expired acknowledgement. Repeating the same final status is a no-op: it does not replace result/attachments. A different outcome on a settled row returns 409. Use a fresh valid assertion/challenge for a transport retry—receipt replay does not bypass proof replay protection. A recorded receipt describes stored device-reported state, not independent proof that a physical operation succeeded. A completed unpair command can also change the reader's lifecycle; production recovery remains private.
Throttles and acceptance
Configured defaults apply per device/IP plus an IP backstop: challenge/attest/bootstrap share 10 per minute and 120 per IP; HTTP code requests use 3 and 60; command receipts use 30 and 240. Claim has its separate failed-redemption lockout plus outer API throttling. Honor 429 and the active deployment's limits.
In an approved test environment/client, validate real proof signatures and replay/expiry, driver mismatch, stored-key behavior, code refresh/expiry, authorized and refused project claims, credential delivery/broker connection and device-scoped receipts. Test same-status replay, conflicting settlement and attachment/privacy handling separately. These steps issue credentials and change records; this guide and its structural examples perform none of them.
The REST reference describes all six operations. Source reconciliation at platform 280cb4c498d70c7e5fcb722d479a9e296e63d31b and structural schema tests do not certify cryptography, broker/device readiness, policy isolation, concurrent code redemption or deployed acceptance.