Commands
A command is a message WBSKT sends to a client, like switching a relay on. You can send one from the console, from the API, or from a workflow's Send to client step. A command to a client that is offline waits until it comes back.
Send one
Open the client and use Send command. If the client declared its commands (see capabilities), pick one and fill in the form. Otherwise switch to JSON, type a command type like relay.set, and write the payload.
The payload arrives on the board as the JSON you wrote, so {"on": true} arrives as an object, not as text. Text that isn't JSON, like lights on, arrives as a JSON string.
What happens to it
Each command gets an ID, and the client's activity shows it move through these steps:
| Step | Means |
|---|---|
| Sent | The client was connected and the command is on its way. |
| Queued | The client is offline. The command waits for it. |
| Delivered | WBSKT wrote it to the client's connection. |
| Acknowledged | Shown as Acked in the console. The client confirmed it arrived. The libraries do this for you, before your code acts on it. |
| Failed | It couldn't be delivered, or it expired first. The reason is shown. |
| Cancelled | Someone cancelled it while it was waiting. |
An acknowledgement means the command arrived, not that it worked. If the outcome matters, have the board send a message back, like relay.state, and react to that.
Commands for an offline client
A registered client that is offline gets its commands later. They wait in its queue and are delivered oldest first as soon as it connects. If it drops before a command is delivered, the command goes back in the queue.
- A command waits at most 24 hours. You can give it an earlier expiry when you send it.
- A client can have up to 100 commands waiting. Past that, new ones are refused until some are delivered or cancelled.
- The API lists what is waiting and cancels any of it (below).
- A command that expires, or whose client is revoked or deleted while it waits, ends as Failed with the reason.
The expiry travels with the command. A board that receives one after its expiry, say from its own late-arriving connection, refuses it instead of acting on it, and that shows as Failed too. Clients that are pending, rejected or revoked don't get a queue: commands to them are refused.
Templates
Save a command you send often as a template: a name, a type and a payload. You can save one straight from a message in a client's Activity. A template is either for the whole workspace or pinned to one policy. A client's Templates menu shows the workspace's templates and those of its own policy, and the policy page lists the ones pinned to it. A workspace can hold 200, each with its own name.
Firmware updates
A client whose library can update its own firmware says so when it connects (the ESP32 library can). You start an update through the API, with a link to the new image (it must be https), its SHA-256 and optionally the version; the console doesn't have a button for it yet. WBSKT sends the client a link, not the image.
The client reports how it goes: accepted, downloading (with progress when it can), and installed with the new version once the new firmware connects, or rejected or failed with the reason. While it restarts it shows as updating. If the new firmware can't reach WBSKT, the board goes back to its previous one.
- An update is a command: it waits for an offline client and always expires, after 24 hours unless you say sooner.
- Sending a newer update cancels any older one still waiting, so the board never installs an outdated image.
- The link is visible to anyone who can read the client. Use a link that expires, not one with a long-lived key in it.
What happens when…
- I send a command to an offline board
- It is queued and the answer says so, with when it expires. It is delivered the moment the board connects, before newer commands.
- The board comes back after the command expired
- It never gets it. The command ended as Failed when it expired: "The command expired before the client came back."
- The board drops in the middle of receiving it
- A command not delivered goes back in the queue. One that was delivered but not acknowledged is not sent again, so a board never acts twice on one command.
- A workflow sends to a board that is offline
- With Wait for acknowledgement on, the step waits for the board until its ack timeout, then leaves by timeout. With it off, the command is queued and the step carries on at once. A full queue or a client that isn't registered leaves by failed when waiting, and fails the step with
COMMAND_NOT_SENTwhen not. - I send to a client in another workspace
- It reads as not found. A command can only reach a client in the workspace it was sent from.
- I ping an offline board
- Refused with
CLIENT_OFFLINE. Pings are never queued.
Rules and API
Endpoints
Under /api/v1/workspaces/{workspaceRef}/clients/{clientRef}.
| Call | Permission | Does |
|---|---|---|
POST commands | clients.command | { type, payload, expiresAt? }. Answers { commandId, status: "sent" | "queued", expiresAt }. |
GET commands?status=queued | clients.read | What waits, oldest first: commandId, type, payload, queuedAt, expiresAt. |
DELETE commands/{commandId} | clients.command | Cancels a waiting command. |
POST ota | clients.firmware | { url, sha256, version?, size?, expiresAt? }. Sent like a command. |
GET comms | logs.read | The message history the Activity panel shows, filterable by direction=in|out. |
Templates live under /api/v1/workspaces/{workspaceRef}/message-templates (templates.read, templates.manage), optionally filtered by policyRefId.
Errors
| Code | Status | When |
|---|---|---|
COMMAND_TYPE_INVALID | 400 | A type that isn't 1 to 100 characters. |
COMMAND_TYPE_RESERVED | 400 | A type the platform keeps: capabilities, state.report, or anything starting sys. in any case. |
COMMAND_PAYLOAD_TOO_LARGE | 400 | A payload over 32,768 characters. |
COMMAND_EXPIRY_INVALID | 400 | An expiry in the past or more than 24 hours ahead. |
COMMAND_STATUS_INVALID | 400 | Listing commands with a status other than queued. |
OTA_URL_INVALID, OTA_SHA256_INVALID, OTA_VERSION_INVALID, OTA_SIZE_INVALID | 400 | A link that isn't https, a digest that isn't 64 hex digits, a version over 50 characters, a size that isn't a byte count. |
COMMAND_NOT_QUEUED | 404 | Cancelling one that was already delivered, expired or cancelled. |
COMMAND_QUEUE_FULL | 409 | The offline client already has 100 waiting. |
CLIENT_INACTIVE | 409 | The offline client is pending, rejected or revoked. |
OTA_NOT_SUPPORTED | 409 | The client's last capabilities don't list ota. |
TEMPLATE_NAME_TAKEN | 409 | Another template has that name, ignoring case. |
TEMPLATE_LIMIT_REACHED | 409 | The workspace already has 200 templates. |
On the wire
- A command reaches the client as
{ type, payload, commandId, expiresAt }. The client answerssys.ack { commandId }on arrival, orsys.ack { commandId, type, refused: "expired" }when it came too late. See the client protocol. - Acks for commands sent with an ID never count against the client's message budget.
- Firmware updates use
sys.ota.update, the one reserved type sent as a command, and progress comes back assys.ota.status. - Every route a command can take, the console, the API, a firmware update or a workflow, goes through one sender that checks the client belongs to the sender's workspace first.
- A gateway silent for 75 seconds has commands for its clients queued rather than sent, and they go out as soon as it is heard from again.