Policies
A policy is how clients join a workspace. It has a PIN that clients present when they first start, decides whether they join at once or wait for you, and can cap how many join.
What a policy is
Think of a policy as a door into your workspace with its own key. Make one for each group of clients that belong together, like greenhouse or office sensors. Each client joins through one policy and stays listed under it in the console.
Open Policies in the console and choose New policy. You give it a name, say whether new clients are approved automatically, and optionally set a client limit. WBSKT makes the PIN for you.
| Setting | What it does |
|---|---|
| Name | Up to 100 characters. Shown in the explorer and on each of its clients. |
| Approve new clients automatically | On: a client with the PIN joins straight away. Off: it waits in Pending until someone approves it. |
| Client limit | The most approved clients the policy may hold. Leave it empty for no limit. |
| Enabled | A disabled policy turns new clients away. Clients already approved keep working. |
The PIN
The PIN is 12 letters and digits, like K7PX9MHT4RQ2. It leaves out characters that look alike (0 and O, 1, I and L, U), so it is easy to copy by hand, and case doesn't matter. The policy page hides it until you choose Show PIN, and Copy PIN puts it on your clipboard.
Anyone who has the PIN can add a client to the policy. Treat it like a password. If it leaks, choose Rotate PIN: the policy gets a new PIN, the old one stops working at once, and the clients that already joined are not affected, because after the first start a client signs in with its own secret, not the PIN.
Approving clients
With automatic approval off, each new client appears in the policy's Pending list. Approve it and it can connect. Reject it and it stays listed as Rejected and cannot sign in. Approve all approves every pending client at once, and you can select several to approve or reject together.
Approving is also how you bring back a client you revoked or rejected earlier. See client statuses.
The client limit
Only approved clients count towards the limit. Once the policy holds that many, a new client trying to join is turned away and keeps retrying, and approving a pending one is refused too. Make room by removing or revoking a client, or raise the limit.
You can't set the limit below the number of clients already approved: remove some first. Your plan has a client limit of its own, shared by every workspace in your account, and whichever limit is reached first applies. See plans and limits.
Turning a policy off, or deleting it
Disable stops the policy taking new clients and leaves everything else as it is. Enable turns it back on with the same PIN.
A policy can be deleted only when no client is enrolled through it, whatever their status: delete its clients first. Its history stays in the activity log, and any message templates saved to it stay in the workspace, no longer tied to a policy.
Templates
A template is a saved command, with a type and a payload, that you send from a client's page with one click. Templates saved to a policy show for every client in it. See templates.
The policy's activity
The policy page lists what happened to it: clients registering, being approved, rejected or revoked, the PIN being rotated, the policy being changed, turned off or on, and a client turned away because the policy or the plan was full. Everything there is also in the workspace's audit log.
What happens when…
- A client starts with a PIN that doesn't exist
- It is refused with
POLICY_NOT_FOUNDand the SDKs stop trying, since waiting won't fix a typo. Correct the PIN and start the client again. - A client starts while the policy is disabled
- It is refused with
POLICY_DISABLEDand keeps retrying on its normal schedule, so it joins on its own once you turn the policy on. - The policy is full
- New clients are refused with
POLICY_LIMIT_REACHEDand keep retrying. The policy's activity says so, at most once an hour so a retrying board doesn't flood it. - The account is at its plan's client limit
- On a policy with automatic approval, new clients are refused with
PLAN_CLIENT_LIMIT_REACHEDand keep retrying. On one without, they still join as Pending, and approving them is refused with the same code. - I rotate the PIN while boards are being set up
- Boards that already registered carry on. A board that hasn't registered yet is refused with
POLICY_NOT_FOUNDand stops; give it the new PIN. - I lower the limit below the clients already approved
- The change is refused with
POLICY_LIMIT_CONFLICT. Nothing is removed for you.
Rules and API
Endpoints
Under /api/v1/workspaces/{workspaceRef}/registration-policies. Reading needs policies.read, and every change needs policies.manage.
| Call | Does |
|---|---|
GET / | Lists policies, each with its approved and connected client counts. Filters: autoApproval, name. |
POST / | Creates one. The PIN is generated by the server, never supplied. |
PATCH /{policyRef} | Changes any of name, maxClients, autoApproval, isEnabled. A field left out keeps its value. removeMaxClients: true clears the limit. |
POST /{policyRef}/rotate-pin | Replaces the PIN and returns the policy with the new one. |
DELETE /{policyRef} | Deletes a policy with no clients. |
Errors
| Code | Status | When |
|---|---|---|
POLICY_NAME_REQUIRED | 400 | The name is blank once trimmed. |
POLICY_NAME_TOO_LONG | 400 | The name is over 100 characters. |
POLICY_LIMIT_INVALID | 400 | A limit below 1. |
POLICY_LIMIT_AMBIGUOUS | 400 | maxClients and removeMaxClients together. |
POLICY_LIMIT_CONFLICT | 400 | A limit below the clients already approved. |
POLICY_UPDATE_EMPTY | 400 | A change that names no field. |
POLICY_NOT_FOUND | 404 | No such policy in this workspace, or (on registration) no policy has that PIN. |
POLICY_HAS_CLIENTS | 409 | Deleting a policy that still has clients. The message gives the count. |
Rules worth knowing
- The PIN is 12 characters from
23456789ABCDEFGHJKMNPQRSTVWXYZ, about 59 bits, drawn from a secure random source. It is matched without case. - The policy limit counts clients with status Registered only. It is checked under a lock on the policy row, so two boards registering at the same instant can't both take the last place.
- A registration through a full policy is refused even when the policy needs approval, so Pending can't grow past the limit.
- The plan's client limit is checked only when a client becomes Registered: on registration through an auto-approve policy, or on approval.
- Policy changes are logged with what changed (
changes: [{field, before, after}]) and sent to every open console.