DocsReferenceAPI reference
HID keyboard and mouse
Send keyboard, mouse and media input to the connected computer over Wi-Fi: arm first (a lease), then send actions or a timeline; the BOOT button and disarm stop it at any time. Also timelines on the microSD card, the monitor screen and the USB mode
GET /v1/hid#
HID state: lease left, queue, held keys, LEDs (Num / Caps / Scroll)
Read-only; changes nothing. To wait for a batch, sleep until its planned end, then check that done_seq is at least the batch's seq
Reply#
HID state
Overall state of HID output
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
usb | string | Yes | hid serial | USB mode (POST /v1/usb) | |
mounted | boolean | Yes | The computer has enumerated the device (plugged in, awake; always false in serial mode) | ||
armed | boolean | Yes | The network source is armed | ||
armed_left_s | integer | Yes | ≥ 0 | Seconds left on the lease; 0 when disarmed | |
app_allowed | boolean | Yes | The app source is open (the running app has the hid permission) | ||
app_paused | boolean | Yes | An emergency stop paused the app source; a press of BOOT resumes it | ||
active | boolean | Yes | Output in progress (turns false 300 ms after the queue empties) | ||
queue | integer | Yes | ≥ 0 | Items waiting in the queue | |
queue_max | integer | Yes | ≥ 0 | Queue capacity | |
sent | integer | Yes | ≥ 0 | Items executed since boot (text counts per character) | |
last_seq | integer | Yes | ≥ 0 | Sequence number of the most recently queued batch | |
done_seq | integer | Yes | ≥ 0 | Every batch with seq up to this is finished or dropped | |
leds | object | Yes | Keyboard LEDs set by the computer | ||
num | boolean | Yes | Num Lock | ||
caps | boolean | Yes | Caps Lock | ||
scroll | boolean | Yes | Scroll Lock | ||
held | object | Yes | What the computer currently sees held | ||
keys | integer[] | Yes | each 0–255 | Held keys (usage codes, modifiers 0xE0–0xE7 included; see x-codes of KeyName) | |
buttons | integer | Yes | 0–31 | Held mouse button bits (see x-bits of MouseButton) | |
consumer | integer | Yes | 0–1023 | Held consumer usage code, 0 = none | |
batch | object | null | Yes | Batch being executed; null when idle | ||
seq | integer | Yes | ≥ 0 | Batch sequence number | |
tag | string | null | Yes | Batch tag; null if none | ||
started_ms | integer | Yes | ≥ 0 | Device uptime in ms when it started | |
done | integer | Yes | ≥ 0 | Items executed | |
count | integer | Yes | ≥ 0 | Items in the batch | |
stopped | object | null | Yes | The most recent stop; null if none | ||
why | string | Yes | boot host lease usb | boot = BOOT emergency stop, host = host disarm, lease = lease expired, usb = USB disconnected | |
ms | integer | Yes | ≥ 0 | Device uptime in ms when it stopped |
Error codes#
For errors any endpoint can return, see Common errors.
POST /v1/hid#
Send keyboard and mouse actions (keys go to the foreground window)
Queues a batch of actions and replies at once, without waiting for execution. Frames are at least 8 ms apart: tap, click and media take two frames each (press, release), text two per character. The whole batch is checked first; if one action is invalid the reply is 400 bad_action and nothing is sent. Arm first with POST /v1/hid/arm. This format is frozen and gets no new actions: new features go into timelines (POST /v1/hid/timeline), and host tools convert actions with stick.hidtl.from_actions
Request body#
application/json
A batch of actions. Only actions and tag are accepted at the top level; the former wait was removed (sending it returns 400 bad_args). To wait for completion, check done_seq in GET /v1/hid
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
actions | object[] | Yes | 1–512 items | Actions, executed in order, 1–512. The whole batch is checked first: if one is invalid, none is queued | |
| Tap a key | object | Press and release (two frames). With mods, the modifiers apply to the press: write a shortcut as {"tap":"A","mods":["alt"]} | |||
tap | string | Yes | Standard 87-key set / Extended keys | Key name | |
mods | string[] | Modifier name | Modifiers pressed together with this key, e.g. ["ctrl","shift"] | ||
| Hold a key | object | Press without releasing; release later with up. At most 6 non-modifier keys can be held at once; extra ones are ignored | |||
down | string | Yes | Standard 87-key set / Extended keys | Key name | |
mods | string[] | Modifier name | Modifiers pressed together with this key, e.g. ["ctrl","shift"] | ||
| Release a key | object | Release one key; "all" releases every key | |||
up | string | Yes | Standard 87-key set / Extended keys / all; case-insensitive | Key name, or all | |
| Type text | object | Types character by character with the US layout: one press frame and one release frame per character, adding Shift where needed. Counts one queue item per character | |||
text | string | Yes | pattern ^[ -~\t\n]+$ | length 1–256 | Text to type: printable ASCII plus \n and \t, US layout, 1–256 characters. Non-ASCII text (such as Chinese) cannot be typed |
| Move the mouse | object | Relative move [dx, dy]; right and down are positive | |||
move | integer[] | Yes | 2 items; each -2000 – 2000 | [dx, dy] | |
| Click a mouse button | object | Press and release | |||
click | string | Yes | Mouse button | Mouse button | |
| Press a mouse button | object | Press without releasing (for dragging); release later with release | |||
press | string | Yes | Mouse button | Mouse button | |
| Release a mouse button | object | Release a held mouse button | |||
release | string | Yes | Mouse button | Mouse button | |
| Vertical wheel | object | Positive scrolls up, negative scrolls down | |||
wheel | integer | Yes | -127 – 127 | Wheel steps, ±127 | |
| Horizontal wheel | object | Positive scrolls right, negative scrolls left | |||
hwheel | integer | Yes | -127 – 127 | Wheel steps, ±127 | |
| Media key | object | Click a media key once (press and release) | |||
media | string | Yes | Media key name | Media key name | |
| Pause | object | Wait some milliseconds before the next action (sends nothing) | |||
wait | integer | Yes | 0–5000 | Pause in milliseconds, 0–5000 | |
tag | string | pattern ^[A-Za-z0-9_.:-]{1,32}$ | length 1–32 | Batch tag: 1–32 of A-Z a-z 0-9 _ . : -. For matching only (batch in GET /v1/hid, the source on the monitor screen); does not affect execution |
Examples#
Shortcut Alt+A#
A shortcut is tap plus mods, not {"key":"alt+a"}
{"actions": [{"tap": "A", "mods": ["alt"]}]}Copy, then paste#
{
"actions": [{"tap": "C", "mods": ["ctrl"]}, {"tap": "V", "mods": ["ctrl"]}]
}Type text#
\n is Enter; ASCII only
{"actions": [{"text": "Hello, Keyling!\n"}]}Hold and release#
Hold left Shift, press Right three times to select three characters, then release
{
"actions": [
{"down": "LSHIFT"},
{"tap": "RIGHT"},
{"tap": "RIGHT"},
{"tap": "RIGHT"},
{"up": "LSHIFT"}
]
}Release all keys#
{"actions": [{"up": "all"}]}Move the mouse and click#
Right 120, up 40, then a left click
{"actions": [{"move": [120, -40]}, {"click": "left"}]}Drag#
Hold the left button, move right 200, then release
{"actions": [{"press": "left"}, {"move": [200, 0]}, {"release": "left"}]}Scroll#
Scroll down 3 steps, then right 2 steps
{"actions": [{"wheel": -3}, {"hwheel": 2}]}Media keys#
Volume up twice
{"actions": [{"media": "volume_up"}, {"media": "volume_up"}]}Pause#
Win+R opens Run, wait 0.5 s for the dialog, then type notepad and Enter; tag is for matching
{
"actions": [{"tap": "R", "mods": ["gui"]}, {"wait": 500}, {"text": "notepad\n"}],
"tag": "open-notepad"
}Reply#
Queued
The whole batch is queued (not yet executed)
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
seq | integer | Yes | ≥ 0 | Batch sequence number; the batch is finished (or dropped) once done_seq in GET /v1/hid is at least this | |
queued | integer | Yes | ≥ 0 | Queue items taken (text counts per character, timelines per record) |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_action | The body is not {"actions":[...]}, actions is empty, or an action is wrong (message names which one and why). Each action takes exactly one form: write a shortcut as {"tap":"A","mods":["alt"]}, not {"key":"alt+a"}. Nothing was queued; fix it and resend. See the example “Shortcut Alt+A” for the correct form |
400 | bad_args | wait was given (removed: check done_seq in GET /v1/hid to wait for completion), or tag is not 1–32 of A-Z a-z 0-9 _ . : - |
403 | hid_locked | Not armed, or the lease expired: POST /v1/hid/arm first |
503 | not_mounted | The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid |
429 | queue_full | More than 512 actions at once, or the queue cannot fit the batch (4096 items, text counts per character). Send in batches or wait for done_seq to catch up; use a timeline for long sequences |
For errors any endpoint can return, see Common errors.
POST /v1/hid/arm#
Arm HID output (lease; disarms and releases all keys on expiry). Call again to renew
Output from the network source (host, web app, agent) must be armed first. The lease lasts seconds (1–600, default 60); calling again renews it and replaces the time left. On expiry the device disarms: it drops queued network-source items, releases all keys, and GET /v1/hid reports stopped.why = lease. Hosts running long sequences renew the lease themselves; if the host crashes or loses the network, the device stops and releases within one lease
Request body#
application/json · optional
The body is optional (defaults to 60 s)
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
seconds | integer | default 60 | 1–600 | Lease in seconds, 1–600 |
Examples#
Arm for 60 s#
{"seconds": 60}Renew to 300 s#
Calling while armed renews: the time left becomes 300 s
{"seconds": 300}Omit seconds (60 s)#
{}Reply#
Armed
The lease started or was renewed
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
armed_left_s | integer | Yes | 1–600 | Seconds left on the lease |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_seconds | seconds is not an integer in 1–600, or the body is not a JSON object. Use {"seconds":60}. See the example “Arm for 60 s” for the correct form |
For errors any endpoint can return, see Common errors.
POST /v1/hid/disarm#
Emergency stop and disarm
Emergency stop: clears the queue (network and app sources), releases all keys and mouse buttons, disarms, and pauses the app source (a press of BOOT or restarting the app resumes it). stopped.why = host. Takes effect at once without waiting for the queue (about 20 ms measured). Calling it while idle is a normal wrap-up; the screen shows no stop panel
Reply#
Stopped and disarmed
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
For errors any endpoint can return, see Common errors.
POST /v1/hid/timeline#
Timeline (6-byte records, executed at their scheduled times)
The only execution format; new features go here only. The upper layer decides what to send in each frame and when; the device executes frames on their scheduled times: a record runs at the previous record's scheduled time plus dt, at least 4 ms after the previous frame; when more than 20 ms behind schedule it re-schedules from now instead of bursting to catch up. A batch is 1–4096 records, read whole and checked record by record; it is queued only if all are valid. Release the keys you press (or end with release_all). Signing is as usual; X-Stick-Sha256 is the hash of the binary body. Host: stick.hidtl.encode / from_actions, stick hid-play
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
tag | string | pattern ^[A-Za-z0-9_.:-]{1,32}$ | length 1–32 | Batch tag |
Request body#
application/octet-stream
Timeline: 6-byte records back to back, no header, 1–4096 records. Each is little-endian u16 dt, u8 op, u8 a, i8 b, i8 c: dt is milliseconds after the previous record (0–5000), op is listed in x-ops, and unused fields must be 0. Frames are at least 4 ms apart (the device delays shorter gaps)
Op codes
| Op | Code | Description |
|---|---|---|
nop | 0 | Sends nothing; only takes time (dt). a b c are 0 |
key_down | 1 | Key down: a = keyboard usage code (x-codes of KeyName, modifiers 0xE0–0xE7 included), b = modifier bits (read as u8, x-bits of ModName) |
key_up | 2 | Key up: a = usage code, 0 releases all keys |
move | 3 | Relative mouse move: b = dx, c = dy (±127) |
btn_down | 4 | Mouse button down: a = button bits (1–0x1F, x-bits of MouseButton) |
btn_up | 5 | Mouse button up: a = button bits |
wheel | 6 | Wheel: b = vertical (positive scrolls up), c = horizontal (positive scrolls right), ±127 |
release_all | 7 | Release all keys, mouse buttons and media keys (one keyboard, mouse and consumer frame each; takes 8 ms) |
consumer | 8 | Media key: a = low 8 bits, b (read as u8) = high 8 bits of the consumer usage code 0–0x3FF (x-codes of MediaName); 0 releases. Held until the next consumer record |
abs_x | 9 | Absolute pointer X: a = low 8 bits, b (read as u8) = high 8 bits, 0–32767; sends nothing until the next moveto |
moveto | 10 | Absolute pointer Y (encoded like abs_x); sends one frame moving to (X, Y). 0–32767 spans the primary display |
Examples#
Shortcut Alt+A#
Press A (modifier bits 0x04 = alt), release 30 ms later
000001040400 1e0002040000| dt | op | a | b | c |
|---|---|---|---|---|
0 | key_down | 4 | 4 | 0 |
30 | key_up | 4 | 0 | 0 |
Click the center of the primary display#
X and Y are both 16384 (0x4000); left button bit 1
000009004000 00000a004000 140004010000 280005010000| dt | op | a | b | c |
|---|---|---|---|---|
0 | abs_x | 0 | 64 | 0 |
0 | moveto | 0 | 64 | 0 |
20 | btn_down | 1 | 0 | 0 |
40 | btn_up | 1 | 0 | 0 |
Media key#
Volume up (consumer 0xE9), released 30 ms later
000008e90000 1e0008000000| dt | op | a | b | c |
|---|---|---|---|---|
0 | consumer | 233 | 0 | 0 |
30 | consumer | 0 | 0 | 0 |
Release everything#
Releases all keys, mouse buttons and media keys (what stick hid-release sends)
000007000000| dt | op | a | b | c |
|---|---|---|---|---|
0 | release_all | 0 | 0 | 0 |
Reply#
Queued
The whole batch is queued (not yet executed)
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
seq | integer | Yes | ≥ 0 | Batch sequence number; the batch is finished (or dropped) once done_seq in GET /v1/hid is at least this | |
queued | integer | Yes | ≥ 0 | Queue items taken (text counts per character, timelines per record) |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_action | The body length is 0 or not a multiple of 6, or a record is invalid (message gives the record number and reason). Nothing was queued; check on the host with stick.hidtl.check. See the example “Shortcut Alt+A” for the correct form |
400 | bad_args | wait was given (removed: check done_seq in GET /v1/hid to wait for completion), or tag is not 1–32 of A-Z a-z 0-9 _ . : - |
413 | too_large | More than 4096 records (24576 bytes). Send in batches, or put it on the microSD card and use POST /v1/hid/play_file |
403 | hid_locked | Not armed, or the lease expired: POST /v1/hid/arm first |
503 | not_mounted | The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid |
429 | queue_full | The queue cannot fit the batch (4096 items). Wait for done_seq to catch up |
For errors any endpoint can return, see Common errors.
POST /v1/hid/play_file#
Stream a timeline file from the microSD card
Streams a timeline file from the microSD card; suited to large macros. The file holds the same records as the POST /v1/hid/timeline body (no header), from 1 record to 16 MB. The whole file is validated first (if that takes over 1 s the reply is state=checking; poll GET until playing or stopped), then fed to the queue in batches. Arm first and keep renewing the lease for long files. One file plays at a time
Request body#
application/json
Path of the timeline file on the card and the batch tag
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 2–160; ≤ 160 bytes | File path on the card, starting with / from the card root, ≤ 160 bytes, same rules as /v1/sd, e.g. /stick/macros/a.tl |
tag | string | null | pattern ^[A-Za-z0-9_.:-]{1,32}$ | Batch tag; sdplay when omitted or null |
Examples#
Play a file#
{"path": "/stick/macros/a.tl"}With a batch tag#
tag shows on the monitor screen and in batch of GET /v1/hid
{"path": "/stick/macros/a.tl", "tag": "nightly"}Reply#
Playing, or still validating
Validated and feeding, or a large file is still being checked
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
| Playing | object | The whole file passed validation and is being fed to the queue | |||
ok | boolean | Yes | true | Always true | |
records | integer | Yes | ≥ 0 | Number of records | |
duration_ms | integer | Yes | ≥ 0 | Estimated duration in ms | |
| Checking | object | Returned when validation takes over 1 s; poll GET /v1/hid/play_file until it becomes playing or stopped | |||
ok | boolean | Yes | true | Always true | |
state | string | Yes | checking | Validating the whole file | |
records | integer | Yes | ≥ 0 | Number of records |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_args | path is missing, or tag is invalid. Write {"path":"/stick/macros/a.tl"}. See the example “Play a file” for the correct form |
400 | bad_path | Invalid path: it must start with /, be ≤ 160 bytes, and contain no .. // \ : * ? " < > | or control characters. See the example “Play a file” for the correct form |
404 | not_found | No such file on the card. Upload it with stick sd put |
409 | is_dir | This is a folder; give a file path |
400 | bad_action | The file is empty, not a multiple of 6 bytes, over 16 MB, or has an invalid record (message says why) |
409 | busy | Another file is playing. POST /v1/hid/play_file/stop first |
403 | hid_locked | Not armed, or the lease expired: POST /v1/hid/arm first |
503 | not_mounted | The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid |
503 | no_card | No card, or the card cannot be mounted (not FAT) |
503 | sd_busy | The card is busy with another request. Try again later |
503 | no_mem | The playback task did not start (out of memory). Restart the device |
For errors any endpoint can return, see Common errors.
GET /v1/hid/play_file#
Playback state of the card timeline
Progress and outcome of the most recent playback. state is done when finished, or stopped with why when it stopped part way
Reply#
Playback state
State of the most recent playback
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
state | string | Yes | idle checking playing done stopped | idle = nothing played since boot, checking = validating the file, playing, done = finished, stopped = stopped part way | |
path | string | null | Yes | Path on the card | ||
src | string | null | Yes | net app null | Who started it: net = host, app = an app | |
tag | string | null | Yes | Batch tag | ||
records | integer | Yes | ≥ 0 | Number of records | |
sent | integer | Yes | ≥ 0 | Records handed to the HID queue | |
done | integer | Yes | ≥ 0 | Records executed (counted per batch, at most one batch behind) | |
duration_ms | integer | Yes | ≥ 0 | Estimated duration in ms | |
elapsed_ms | integer | Yes | ≥ 0 | Milliseconds since feeding started | |
why | string | null | Yes | stop flushed locked not_mounted sd_read file_changed bad_action null | Why it stopped: stop = host stop, flushed = queue cleared by an emergency stop or lease expiry, locked = output gate closed, not_mounted = computer disconnected, sd_read = card read error, file_changed = file modified, bad_action = invalid record | |
message | string | null | Yes | Detail; for bad_action, the record number and reason |
Error codes#
For errors any endpoint can return, see Common errors.
POST /v1/hid/play_file/stop#
Stop playback
Stops playback: drops what has not run and releases everything, without disarming (the lease continues). Succeeds even when nothing is playing
Reply#
Stopped
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
For errors any endpoint can return, see Common errors.
GET /v1/monitor#
Monitor screen state (right side: name, mode, step, progress)
Whether the monitor screen is shown, who set the status on its right side, and how long it has left
Reply#
Monitor screen state
Whether the monitor screen is shown and its status
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
visible | boolean | Yes | The monitor screen is shown | ||
owner | string | null | Yes | app host null | Who set the status: app (monitor.set) or host; null when unset | |
ttl_s | integer | null | Yes | ≥ 1 | Seconds left on a host-set status; null for app-set or unset | |
status | object | Yes | Current status; null when unset | ||
| Monitor screen status | object | What the right side of the monitor screen shows | |||
name | string | Yes | Name on the left of the status bar; device ID when empty | ||
mode | string | Yes | Mode in the pill, e.g. once or LOOP | ||
source | string | Yes | Source to the right of the pill | ||
title | string | Yes | Large title; follows state when empty | ||
line1 | string | Yes | First line | ||
line2 | string | Yes | Second line (below the progress bar) | ||
state | string | Yes | ready running stopped error | State: ready, running, stopped, error | |
progress | integer | null | Yes | 0–100 | Progress 0–100; null hides the bar | |
| #2 | null |
Error codes#
For errors any endpoint can return, see Common errors.
POST /v1/monitor#
Set the monitor screen state (replaces it)
Sets the status on the right side of the monitor screen (replaces it; every field is optional). A host-set status carries ttl_s (default 60 s) and clears itself on expiry; between this and an app's monitor.set, the later one wins. {"clear":true} clears it. Only changes the screen; sends no input
Request body#
application/json
Replaces the whole status; every field is optional. {"clear":true} clears it. Lengths are UTF-8 bytes
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
name | string | ≤ 48 bytes | Status bar name, ≤ 48 bytes | ||
mode | string | ≤ 12 bytes | Mode in the pill, ≤ 12 bytes | ||
source | string | ≤ 24 bytes | Source, ≤ 24 bytes | ||
title | string | ≤ 48 bytes | Large title, ≤ 48 bytes; follows state when omitted | ||
line1 | string | ≤ 48 bytes | First line, ≤ 48 bytes | ||
line2 | string | ≤ 48 bytes | Second line, ≤ 48 bytes | ||
state | string | ready running stopped error; default running | State, running when omitted; stopped / error keep the stop panel shown | ||
progress | number | null | 0–100 | Progress 0–100 (rounded); null or omitted hides the bar | ||
ttl_s | integer | default 60 | 1–3600 | Seconds until it clears itself, 1–3600 | |
clear | boolean | true clears it (whoever set it); other fields are ignored |
Examples#
Running#
A one-off task at step 3, 43% done, clearing itself after 120 s. Chinese values: 填单 = fill in a form, 单次 = once, 第 3 步 / 共 7 步 = step 3 of 7
{
"name": "填单",
"mode": "单次",
"source": "Agent",
"state": "running",
"line1": "第 3 步 / 共 7 步",
"progress": 43,
"ttl_s": 120
}Error#
An error keeps the stop panel shown, with line1 / line2 below it. Chinese values: 找不到保存按钮 = Save button not found, 单击 BOOT 重试 = click BOOT to retry
{"name": "填单", "state": "error", "line1": "找不到保存按钮", "line2": "单击 BOOT 重试"}Clear#
{"clear": true}Reply#
Set
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_args | Unknown field, wrong type, too long or out of range (message says which). See the example “Running” for the correct form |
400 | bad_json | The body is not a JSON object. See the example “Running” for the correct form |
For errors any endpoint can return, see Common errors.
POST /v1/usb#
USB mode hid / serial; restarts after replying (no keyboard or mouse in serial)
Saves the USB mode and restarts about 0.5 s after replying. hid (default): keyboard, mouse, media keys and absolute pointer, with no USB serial; serial: no HID, keeps the USB serial console for debugging. The rescue firmware always uses serial
Request body#
application/json
USB mode to switch to
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
mode | string | Yes | hid serial | hid = keyboard and mouse (default), serial = USB serial console (no HID) |
Examples#
Keyboard and mouse#
{"mode": "hid"}USB serial#
After the restart there is no keyboard or mouse; switch back over Wi-Fi
{"mode": "serial"}Reply#
Saved; restarting
Saved; restarts about 0.5 s after replying
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
usb | string | Yes | hid serial | USB mode after the restart |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_mode | mode must be hid or serial. See the example “Keyboard and mouse” for the correct form |
500 | nvs | Saving failed. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
Name tables#
Standard 87-key set KeyName87#
Standard 87-key set (TKL: main block, F1–F12, PrtSc / ScrLk / Pause, 6 editing keys, arrows, 8 modifiers and Menu). Host tools and the SDK accept only these by default. Case-insensitive; the canonical spelling is listed. x-codes are USB keyboard usage codes (field a of timeline key_down / key_up)
A0x04B0x05C0x06D0x07E0x08F0x09G0x0AH0x0BI0x0CJ0x0DK0x0EL0x0FM0x10N0x11O0x12P0x13Q0x14R0x15S0x16T0x17U0x18V0x19W0x1AX0x1BY0x1CZ0x1D10x1E20x1F30x2040x2150x2260x2370x2480x2590x2600x27ENTER0x28ESC0x29BACKSPACE0x2ATAB0x2BSPACE0x2CMINUS0x2DEQUAL0x2ELBRACKET0x2FRBRACKET0x30BACKSLASH0x31SEMICOLON0x33QUOTE0x34GRAVE0x35COMMA0x36PERIOD0x37SLASH0x38CAPSLOCK0x39F10x3AF20x3BF30x3CF40x3DF50x3EF60x3FF70x40F80x41F90x42F100x43F110x44F120x45PRINTSCREEN0x46SCROLLLOCK0x47PAUSE0x48INSERT0x49HOME0x4APGUP0x4BDELETE0x4CEND0x4DPGDN0x4ERIGHT0x4FLEFT0x50DOWN0x51UP0x52MENU0x65LCTRL0xE0LSHIFT0xE1LALT0xE2LGUI0xE3RCTRL0xE4RSHIFT0xE5RALT0xE6RGUI0xE7
The number after each name is its usage code (hex).
Extended keys KeyNameExtended#
Extended keys: the device accepts them, but foreground programs usually ignore them; for self-tests and drills only. Host tools need --extended / extended=True and SDK plans need "keyset": "full"; the device and timelines make no distinction
| Name | Usage code |
|---|---|
NUMLOCK | 0x53 (83) |
F13 | 0x68 (104) |
F14 | 0x69 (105) |
F15 | 0x6A (106) |
F16 | 0x6B (107) |
F17 | 0x6C (108) |
F18 | 0x6D (109) |
F19 | 0x6E (110) |
F20 | 0x6F (111) |
F21 | 0x70 (112) |
F22 | 0x71 (113) |
F23 | 0x72 (114) |
F24 | 0x73 (115) |
Modifier name ModName#
Modifier name: ctrl shift alt gui are the left ones (gui = Windows / Command key), the r-prefixed ones are on the right. Case-insensitive; x-bits are modifier bits (field b of timeline key_down)
| Name | Bit |
|---|---|
ctrl | 0x01 (1) |
shift | 0x02 (2) |
alt | 0x04 (4) |
gui | 0x08 (8) |
rctrl | 0x10 (16) |
rshift | 0x20 (32) |
ralt | 0x40 (64) |
rgui | 0x80 (128) |
Mouse button MouseButton#
Mouse button
| Name | Bit |
|---|---|
left | 0x01 (1) |
right | 0x02 (2) |
middle | 0x04 (4) |
back | 0x08 (8) |
forward | 0x10 (16) |
Media key name MediaName#
Media key name
| Name | Usage code |
|---|---|
volume_up | 0xE9 (233) |
volume_down | 0xEA (234) |
mute | 0xE2 (226) |
play_pause | 0xCD (205) |
next | 0xB5 (181) |
prev | 0xB6 (182) |
stop | 0xB7 (183) |
brightness_up | 0x6F (111) |
brightness_down | 0x70 (112) |