# The API

Everything the page does, it does through this interface, and so can any other program:
a script, a monitoring system, a program of its own that shows a wall (the Desktop App is
one). The paths are under `/api/v1/`, and the `v1` is the version of the interface. This
chapter is what a wall promises such a program. A wall and the programs that talk to it are
upgraded at different times, so the promise is kept from one version of qKVM to the next;
[Clients and versions](https://qkvm.com/docs/clients-and-versions) says how a program keeps its side.

### The promise

- **What is promised** is what this chapter lists: the requests in the table below, who may
  ask each, what it takes, what it answers and with what kind of value in each field, and the
  codes it refuses with; the records a machine, how a machine is and an account are described
  as; the errors. The other requests under `/api/v1/` are the page's own and change with it
  (they are named at the end): a program written against them is written against one version
  of qKVM.
- **Within `v1`, requests, fields, states, codes and words are added; none is taken away or
  given another meaning.** A request keeps its method, its path and the role it takes; a
  field keeps its name and its kind (a text stays a text, and one that may be null is said to
  be so where it is described). A change that would break a program written against `v1`
  gets a path of its own (`/api/v2/`) beside this one.
- **A program leaves out what it does not know.** A field, a state, a code or a word of `can`
  it has not met is one that was added since: an answer with more in it than the program
  expected is not wrong. A request is sent with the fields its row names and no others.
- **What a wall offers is said, not guessed.** `GET /healthz` says the version of qKVM
  (`version`) and the versions of this interface it speaks (`api`); the list below says since
  which version each request, and each field added later, is promised; each machine's `can`
  says what it can be asked, and the wall's `live` the form of the live line.
- **The list.** `qkvm/api_v1.json`, in the source and in every installed copy, says all of
  this for a program: each promised request with who may ask it, what it takes, the kind of
  each field of what it answers, the codes it refuses with and since which version it is so;
  the records; the codes every request may answer with, and since which version those added
  later are promised (`codes_since`); and the page's own requests by name.
  qKVM's own tests fail when a request is added, taken away or changed without the list and
  this chapter changing with it.
- **Every answer under `/api/`** carries `Cache-Control: no-store`. Every answer is JSON
  (`application/json`) but a picture and an export's file, and every refusal is
  `{"code": "...", "message": "..."}` (below), with more beside them only where its row says
  so (`by`, `unknown`, `mounted`).
- **If a `/api/v2/` ever comes**, it comes beside `/api/v1/`, which is served on as it is: for
  at least twelve months after the first release that has `v2`, and through at least two
  minor releases after it, whichever is longer. From that release on, every `v1` answer carries
  `Deprecation` and `Sunset` headers, and the day `v1` ends is said here and in that release's
  changelog. `v1` goes only in a minor release, never in a fix release.
- **A wall can be held to all of this** by a program, reading only:
  [Checking a wall](https://qkvm.com/docs/clients-and-versions#checking-a-wall).

### Who may

Three roles, each including the ones below it: admin, operator, viewer. Three ways in:

- **A person**, with an account: `POST /api/v1/login`, which answers with the cookie
  `qkvm_session` (HttpOnly, SameSite=Strict, Secure over HTTPS), to be sent with every
  request. Every request that changes something (anything but GET) then has to carry the
  header `X-QKVM: 1`, and no `Origin` of another host; without it: 403 `forbidden`.
- **A script**, with a token an admin made (see above): `Authorization: Bearer qkvm_...`
  with every request, no cookie and no `X-QKVM` header. It is a viewer or an operator, never
  an admin, and has no account of its own to change or to sign out of.
- **A wall screen**, with its link: `POST /api/v1/display` with the key behind `#key=`,
  which answers with the cookie of a viewer that is not a person (`"token": true`).

Bodies are JSON with a `Content-Length` (sent chunked: 411 `length_required`), at most 64
KiB (413 `too_large`), except the two that carry a file. A field that is wrong is answered
422 `invalid`, and the message names the field and the rule, never the value. A field the
request does not need is left out.

### Errors

Every refusal is `{"code": "...", "message": "..."}` with a status that fits. `code` is one
word, for a program; `message` is a sentence fit to show to a person. Every code the wall
answers with is listed in `words.json` (see [Clients and versions](https://qkvm.com/docs/clients-and-versions))
with the statuses it comes with; the ones the requests below answer:

| Status | Codes | Whose fault |
|---|---|---|
| 400, 408 | `disconnected` (the body was not sent in full), `timeout` (it took too long to arrive) | the request |
| 401 | `unauthorized` (sign in first; in the middle of things: the session ended, sign in again and do not loop), `bad_password`, `bad_code`, `code_required`, `bad_key`, `bad_recovery` | the session |
| 403 | `forbidden` (the header), `not_allowed` (the role, or a token), `totp_required` (set the second step up first), `suspended`, `stopped` (whoever asked lost the right while it was under way) | |
| 404 | `not_found` (also: a machine this account was not given; an address nothing is served at), `no_picture`, `no_console`, `no_live` (no live picture of this machine), `no_virtual_media` (no `media` in its `can`) | |
| 405 | `method_not_allowed`: the address is served, by another method, which `Allow` names. Only an admin meets it, and an address nothing is served at: to anybody else either is 403 `not_allowed` | the request |
| 409 | `busy` (something else is being done to that machine), `changed`, `moved` (a change of a machine's virtual media picked from a list of another machine: its tile was edited to another address, or another machine, since), `machine_changed` (an action or a live picture asked for the machine a tile was at when it was looked at, its `target`, and an edit has put another machine under the tile since: nothing was sent; since 0.4.0), `input_changed` (keys or text asked for the computer on one input of a KVM with several, its `input`, and the KVM, asked right before they were to go, showed another on screen or did not say which: nothing was sent; since 0.4.0), `duplicate` (an image of that name is there already), `no_text`, `in_use`, `console_held`, `enabled`, `not_enabled`, `not_started`, `not_initialized`, `no_second_step`, `no_password` (the account has no password here: it is signed in by the identity proxy), `same_host` (a device's page on a host name qKVM is looked at under), `unknown_kind` (a tile of a kind of machine this version does not know, kept from a later version: nothing is sent to it; it can be removed) | the state of things |
| 411, 413 | `length_required` (a body sent without its length), `too_large` (a body over 64 KiB, a file over what a file may be, an image over 16 GB) | the request |
| 422 | `invalid`, `name_required`; for a file: `not_a_file`, `damaged`, `newer`, `passphrase_needed`, `wrong_passphrase`, `too_large` | the request |
| 429 | `rate_limited`, with `Retry-After` in seconds, which is meant; `busy` (too many passwords being checked at once: try again shortly) | |
| 500, 501 | `internal` (the details are in the wall's log); `missing_driver` (a JetKVM, where the Python that runs qKVM lacks the aiortc package qKVM is installed with) | the wall's |
| 502 | the device's: `unreachable`, `dropped`, `auth_failed`, `no_password`, `not_set_up`, `cert_mismatch`, `cert_invalid`, `plain_only`, `https_only` (a KVM whose plain address sends everybody on to HTTPS at the same host, which is said and not followed; 422 from an add or an edit), `another_machine` (another machine answers at the address than the one the tile was added for, a PC with Intel AMT by its PlatformGUID, a JetKVM by its own number (which it says once signed in), a server by its UUID and its controller's, or has its guest's number on its Proxmox, by the guest's SMBIOS UUID: nothing was sent; 422 from an edit), `bad_response`, `action_failed`, `console_time_up` | the device |
| 503 | `no_stream` (not yet: ask again), `no_sign_in` (the device answers, and does not sign qKVM in), `locked` (qKVM cannot open the saved passwords just now), `busy` (no memory to check a password with), `no_video` (no picture can be made on the computer qKVM runs on: no video worker can start there, and the message says why; the same for every machine whose picture qKVM makes itself, and `GET /healthz` says `"video": "unavailable"` meanwhile. A worker that only takes long to start is `no_stream` until three in a row do) | |
| 504 | `timeout`: no answer from the device | |
| 507 | `not_saved`: the change could not be written down (a full disk), and was taken back | the wall's disk |
| 507 | `no_space`: an image larger than the space free on the device's own storage | the device's |

After an action, `unreachable` and `no_stream` mean that nothing was sent; `timeout` and `dropped` mean
that the request went out and its answer did not come, or came broken: **it may have been done**, so do
not offer a blind retry of a power button for either. Every request may answer, beside what its row
names: `unauthorized`, `not_allowed`, `forbidden` and `totp_required` (who may); `invalid`, `too_large`,
`length_required`, `disconnected` and `timeout` (400, 408: the body did not arrive in full, or in time)
(the request); `internal` (the wall's); `rate_limited` and `busy` (429, 503) wherever a password is checked;
`no_password` (409) wherever one's own password is asked for of an account that has none here; `not_saved`
wherever something is written down; `locked`; and the device's own wherever a device is asked, `in_use`
(409), `missing_driver` (501) and `no_video` (503) among them.

### The requests

`*` marks what a request must have. "A person": not a token.

| Request | Who | Body | Answers |
|---|---|---|---|
| `GET /healthz` | nobody | | `status` ("ok"), `version`, `api` (the versions spoken: `["v1"]`), `page` (a mark of the page's own files, of no use to another program), `locked` (true: restarted with `--locked-start` and nobody has signed in since, so it reaches no device); from 0.4.0, `video` ("unavailable", there only then: no picture can be made on this computer, as `no_video` says on the tiles, with why). Never refuses |
| `GET /api/v1/session` | nobody | | `initialized` (false: nobody has set this wall up, which is done on its page), `authenticated`, `user` (the account, below, or null), `ask_name` (true: more than one account, and signing in needs the name), `recovery` (a recovery key exists), `recovery_created` (to an admin: when, in seconds since 1970; otherwise null), `setup_code_required`, `min_password`, `unlocks_at_start`. Started with `--sso-header`: `sso` (`on`, `name`, `known`), and whoever the proxy signed in is signed in here by this answer, cookie included |
| `POST /api/v1/login` | nobody | `password`*, `name` (where `ask_name`), `code` (where asked for), `remember` (30 days) | `ok`, `user`, and the cookie. 401 `bad_password`; 401 `code_required`: the password was right and the account has a second step, send the same request again with `code`; 401 `bad_code`; 403 `suspended`; 409 `not_initialized`; 409 `no_second_step` (the key of the account's second step does not open any more: `qkvm --disable-2fa` where qKVM runs); 422 `name_required`; 429 `rate_limited` |
| `POST /api/v1/logout` | viewer, a person | `scope`: "this" (default), "others" (the account's other sessions), "all" | `ok`; the cookie is cleared, except for "others". 507 `not_saved`: signed out all the same, and a restart may undo it |
| `POST /api/v1/password` | viewer, a person | `current`*, `new`* (10 to 256 characters) | `ok`; the account's other sessions end. 401 `bad_password`; 409 `no_password`; 409 `changed` (the account was changed while its password was checked: nothing was done) |
| `POST /api/v1/totp/begin` | viewer, a person | `password`* | `secret` (the key, in groups of four), `uri` (`otpauth://...`, for a QR code), `qr` (that code drawn, a text per row, "1" for a dark module). 409 `enabled`; 401 `bad_password` |
| `POST /api/v1/totp/enable` | viewer, a person | `code`* (from the app, for the key just shown) | `ok`, `user`, `recovery_codes` (ten one-time codes, shown this once); the account's other sessions end. 409 `not_started`; 401 `bad_code` |
| `POST /api/v1/totp/codes` | viewer, a person | `password`* | `ok`, `user`, `recovery_codes` (ten new ones; the old stop working). 409 `not_enabled`; 401 `bad_password`; 409 `changed` (as for `/password`) |
| `POST /api/v1/totp/disable` | viewer, a person | `password`* | `ok`, `user`. 401 `bad_password`; 409 `changed` (as for `/password`) |
| `POST /api/v1/recover` | nobody | `recovery_key`*, `new_password`*, `name` (where there are several accounts) | `ok`; every session of that account ends. 401 `bad_recovery`; 409 `not_initialized`; 422 `name_required`; 429 `rate_limited` |
| `POST /api/v1/display` | nobody | `key`* | `ok`, `user` (`token` true), `expires` (when the link runs out, in seconds since 1970; null: when it is taken back), `expires_in` (how many seconds that is from now, by the wall's clock: a screen counts those, whatever its own clock says; null as for `expires`), and the cookie. 401 `bad_key`: the link was taken back or has run out |
| `GET /api/v1/about` | viewer | | `version`, `licence`; to an admin also what it runs on: `python` (its version), `system`, `libraries` (each `name`, `version`, `licence`) |
| `GET /api/v1/wall` | viewer | | `interval` (seconds between two pictures of a tile, as set for this wall), `live` (the form of the live line this qKVM speaks, as a number: 2; a program that speaks another form asks for no live picture, see [Live view and control](https://qkvm.com/docs/live-view-and-control)), `devices` (the machines this account may see, each as below). Never waits for a device |
| `GET /api/v1/status` | viewer | | by device `id`, how each is (below), from what is known: it waits for no device, except up to a second and a half for one's very first look |
| `GET /api/v1/devices/{id}/history?what=summary&since=&until=&limit=&every=` | viewer | | what the wall saw of the machine, kept beside the settings (the chapter [History](https://qkvm.com/docs/history)). `what`: "summary" (default), "states", "samples" or "events"; `since` and `until` in seconds since 1970 (left out: the last week, for samples the last day); `limit` 1 to 5000 (1000 left out); `every` 0 to 86400: samples averaged over spans of that many seconds. A summary: `since`, `until`, `first_seen`, `last_seen` (seconds since 1970, or null), `state` and `power` ("on", "off", or null) as last seen, `watched`, `online`, `answering` (seconds of the window), `share`, `answering_share` (online, and answering, over watched; null where nothing was seen), `changes`, `events` (how many in the window), `sensors` (the names of its readings of the last day). The rest: `since`, `until`, `rows` (oldest first; a state `t`, `state`, `code`; an event `t`, `kind` ("pressed": a power button pressed from the wall, "power": a change of power state seen), `what`, `ok` (null: nobody heard how it went), `note`; a sample `t`, `sensor`, `unit`, `value`), `more` (the page was cut: narrow the window), and for samples `every`; with `every` given, `series` in place of `rows`, one per sensor: `sensor`, `unit`, `points` of `[t, average, min, max]` (a sensor whose series does not fit whole is left out). 404 `not_found`; 503 `busy` (three reads at once are answered, from everybody together, and one at a time of each account or token, whose next waits its turn for eight seconds at the most and, after a read, as long again as that read took; `Retry-After` says when); 503 `history_unavailable` (the file is being opened or replaced, or brought up to date for longer than three seconds, or the read took too long) |
| `GET /api/v1/devices/{id}/snapshot?w=640&age=1` | viewer | | the screen as `image/jpeg` or `image/png`, with `X-KVM-Signal` 1 or 0 (0: a placeholder, the computer shows nothing) and `Cache-Control: no-store`. A still kept between sessions (a PC with Intel AMT whose tile is only shown) carries `X-KVM-Still: 1` and `X-KVM-Age: <seconds>`, how old the still is. `w`: the width wanted, 1 to 16384 (the source's own is never exceeded); `age`: how old, in seconds, the frame may be (0 to 3600; viewers asking within that window share one frame); `target` (since 0.4.0: the machine's `target` as the client has the tile; left out or empty, it is not asked). 404 `not_found`; 404 `no_picture` (a server whose controller gives none); 503 `no_stream` (not yet: ask again); 409 `machine_changed` (the tile is at another machine than `target` names: nothing was asked of either, and the wall is to be fetched again); 409 `in_use` (a JetKVM whose one viewer is somebody else; a PC with Intel AMT whose KVM another viewer has, since 0.4.0); the device's |
| `POST /api/v1/devices/{id}/live?target=...` | viewer | `{}`; `target` (since 0.4.0: the machine's `target` as the view that opens the line shows it; left out, it is not asked) | `v` (the form of the live line this qKVM speaks: 2), `ticket` (a pass for one live line to this machine, good for half a minute and for one use: 16 to 200 letters, digits, `-` or `_`; it is in no log, and is not to be kept). The pass is for the machine the tile is at as it is given: once an edit of the tile has put another connection in its place (another address, another machine, or only another name), it opens no line, which is told `bye` `gone`, as a line open by then is. A viewer, a wall screen and a token may ask, and may watch; taking keyboard and mouse over the line takes an operator or an admin, by cookie or by token. 404 `not_found`; 404 `no_live` (a server whose console is not read: `live` is not in its `can`); 409 `machine_changed` (the tile is at another machine than `target` names: no pass is given); 429 `busy` (this account, token or wall screen has 32 live lines open, the passes it has not used counted with them; or the wall 256 passes out: `Retry-After`); 503 `locked` |
| a WebSocket at `/api/v1/devices/{id}/live` (`GET`, upgraded) | by the pass | the first message, text: `{"t": "hello", "v": 2, "ticket": "...", "video": ["h264", "jpeg"], "max_w": 1920, "max_fps": 30}` | the live line: the machine's picture down, keyboard and mouse up, with the messages [Live view and control](https://qkvm.com/docs/live-view-and-control) lists. It carries no cookie, and is asked for from the address the pass was given to. A line whose first message is not a pass this qKVM gave for this machine is told `{"t": "bye", "code": "no_pass", "message": ...}` and closed; one from a page of another host, or for a host this wall does not answer to, is refused 403 before anything is read |
| `GET /api/v1/actions` | operator | | `actions`: each `id`, `name`, `kind` ("keys" or "text"), `keys`, `enter`, `danger`, `changed` (how often it was edited). Never the text a saved action types |
| `GET /api/v1/devices/{id}/wol?target=...` | operator | `target` (since 0.4.0, in the address: the machine's `target` as the menu that lists was opened for it; left out or empty, it is not asked) | `targets`: each `mac`, `name` (what the device calls it, which a KVM fills with the address where it has no name; empty where it has nothing). A machine without `wol` in `can` answers an empty list. 404 `not_found`; 409 `machine_changed` (the tile is at another machine than `target` names: nothing was asked of it); the device's |
| `POST /api/v1/devices/{id}/actions` | operator | `action`*, and what that one needs (the table below); `batch` (any id of letters, digits and "-", up to forty: ties several requests together as one act in the activity log); `target` (since 0.4.0: the machine's `target` as the person saw it when they were asked, which [Doing something](https://qkvm.com/docs/the-api#doing-something) says more of; left out, it is not asked); `input` (since 0.4.0: on a KVM with several inputs, the status's `ports.active` as the person saw it, for keys, text, `ctrl_alt_del` and a saved action; left out, it is not asked); `one_input` (since 0.4.0: `true` instead of `input`, for the same actions, where the status said neither `several_inputs` nor `ports`; left out, it is not asked) | `ok`, `note` (null; or "already on", "already off" for a server that was so; or "pressed, but the computer is still off", "held, but the computer is still on", "pressed; its board has not said since", "pressed; not seen: its connection ended" (the tile was edited or removed, or the wall locked itself; and "held; ..." of the same) for a KVM's power button whose change its board did not show: it was pressed). 404 `not_found` (also: the saved action is gone); 409 `busy` (with `by`, the name of whoever has the machine's keyboard and mouse over a live line, where that is why: an account's, or a token's with "(token)"; to an admin in person the message adds that they can take them over in the live view: an action never takes over by itself); 409 `conflict` (it waited for the last holder of the keyboard to be let go of, and meanwhile the tile was changed or taken off the wall: nothing was sent); 409 `changed` (the saved action was edited since it was listed); 409 `machine_changed` (the tile is at another machine than `target` names: nothing was sent); 409 `input_changed` (keys or text, and the KVM, asked right before they were to go, shows another input than `input` on screen, or does not say which; or a machine that has no inputs to choose from; or, with `one_input`, a KVM qKVM knows has several inputs, or may have several where its inputs are not known at the moment (the status's `several_inputs` without `ports`), or whose switch, asked right before they were to go, answers anything but kvmd's own word that it has none within two seconds of a connection; with `input` too, where its switch says it is not in step; or where they could not leave within half a second of that answer: nothing was sent); 409 `no_text`; 403 `not_allowed` (a token and a saved text); 403 `stopped`; 422 `invalid` (also: an action this machine cannot do; `input` and `one_input` both); 502 `action_failed` (the device refused); 504 `timeout` and 502 `dropped` (it may have been done); the device's. Every action is written to the activity log with the account; keys and text with the input they named (`input`, counted from 1 there) or `one_input` (since 0.4.0), and one refused for its input before anything went, as the KVM's own refusal is (`action_failed`, in its words). Never the text that was typed |
| `PUT /api/v1/devices/{id}/view` | operator, a person | `view`*: "health", "stills" or "live"; `target` (since 0.4.0: the PC's `target` as the person saw it, as for an action; left out, it is not asked) | which of its three views a PC with Intel AMT is in (see [Intel AMT](https://qkvm.com/docs/intel-amt)): `ok`, `amt_view` (as it is now). In effect at once; each change is written to the activity log (`amt_view_changed`, with `view` and `was`), and one that changes nothing is not. 403 `not_allowed` (a token: it changes no setting of a tile); 404 `not_found`; 409 `machine_changed` (the tile is at another machine than `target` names, a PC or not: nothing was changed); 422 `invalid` (no PC with Intel AMT, where `target` names the machine it is at or none); 507 `not_saved` |
| `POST /api/v1/devices/{id}/console?target=...` | operator, a person | `{}` | `url`: a way into a server's own console, signed in, good for one use, for the browser of whoever asked; it is in no log, and is not to be kept. `target` (since 0.4.0, in the address: the machine's `target` as the person saw it, as for an action; left out, it is not asked). 403 `not_allowed` (a token); 404 `not_found`; 404 `no_console` (no such way in from this device); 409 `machine_changed` (the tile is at another machine than `target` names: nothing was asked of it); 409 `same_host` (the browser reaches the device by a host name qKVM is looked at under, the one this request came by or one in `allowed_hosts`: it would hand the device its sign-in to qKVM, and nothing is asked of the device); the device's |
| `GET /api/v1/devices/{id}/media?target=...` | admin, a person | `target` (since 0.4.0, in the address: the machine's `target` as the box that lists was opened for it; left out or empty, it is not asked) | what can be mounted on the machine, asked of it now: `images` (each `id`, the only thing a mount names, `name`, `where` (for a virtual machine on Proxmox, the storage; null on a KVM's own and a server's), `size` in bytes or null, `partial` (an upload of it was cut off: only to delete; a JetKVM's keeps its name with `.incomplete`), `sha256` (where qKVM carried it there and it is still that image, else null)), `unseen` (a sentence for each place whose images could not be listed, in the device's words: a storage the token may not read), `left_out` (how many entries were no image qKVM passes on to the device), `notes` (sentences of what stands against a change now: a KVM's File Sharing on, its drive offline or busy), `space` (a KVM's own storage: `free` and `size` in bytes; null elsewhere), `mounted` (what is in its drive now, as the status's `media` below, or null), `uploading` (an upload to it under way, as `GET .../media/upload` says it, or null), `listed` (the machine this list was made of: a mark of the address it is spoken to at and of what it is known by there, which a change sends back) and `offers`, by what the last look at the machine found: `drives` (what an image goes in as: "cd", read-only; "flash", a kvmd KVM's USB flash drive; "disk", a JetKVM's, read-only), `writable` (of `drives`: those an image may be mounted writable in, where that is chosen), `boot` (how it can be told to start from it: "once", "until_unmounted"; none on a KVM), `restart` (it can be restarted from here: a KVM with a power board too), `upload` (images are carried through qKVM to it), `delete` (images can be deleted from it), `drops_input` (a mount or an unmount drops its keyboard and mouse for a moment), `where` ("proxmox": the images are on the storages of its node; "device": on the KVM's own storage; "qkvm": a server's, in the folder qKVM serves them from); and for a server `served_from` (the wall's address as its controller reaches it, or null where there is none). 403 `not_allowed` (a token); 404 `not_found`; 404 `no_virtual_media`; 409 `machine_changed` (the tile is at another machine than `target` names: nothing was asked of it, and its list, whose `listed` a change would carry, is not handed out); 502 `another_machine`; the device's |
| `POST /api/v1/devices/{id}/media` | admin, a person | `image`* (an `id` as listed), `machine`* (the machine's name, as the confirmation named it), `listed` (`listed` of the `GET .../media` the image was picked from: the change is refused where the tile's machine is no longer that one, its tile edited to another address or another machine meanwhile; left out, as by a client before 0.3.2, it is not asked), `drive` (of the offer's `drives`; "cd", the default), `writable` (true: the machine may change what is on it; only for a drive of the offer's `writable`; false, the default), `boot` ("none", the default: its boot order is left as it is; "once": it is restarted now to start from the image, and its boot order is as before for every start after; "until_unmounted": it starts from the image from its next start until it is unmounted), `restart` (true: restart it now, with "until_unmounted"; "once" always restarts; on a machine that cannot be told to start from it, a KVM, with `boot` "none": its reset button, its power button where it is off, for its boot menu to find the drive). A restart of a virtual machine stops it at once and starts it again | the image is put in its drive, read-only: `ok`, `note` (null, or a sentence: a CD-ROM drive added where there was none, which a running guest has from its next start; how it starts), `mounted`. 409 `moved` (the tile's machine is not the one `listed` names any more: nothing was done, and nothing was asked of either machine); 409 `changed` (the machine is called otherwise now, the image is no longer listed, or its settings were changed on the device meanwhile: nothing was done); 409 `busy` (as for an action; with a restart also while somebody has its keyboard and mouse over a live line, with `by`); 409 `changed` also where another image is in a KVM's drive (unmount it first), or the image is not there whole; 409 `busy` where another image is in a server's drive; 409 `action_failed` (no CD-ROM drive and no place for one, a boot order the wall does not read; a KVM's File Sharing on, its drive offline; a KVM that did not mount it as asked, which has it taken out again; no address servers reach the wall at, a server's controller that takes HTTPS alone while the wall is reached over plain HTTP, another tool's boot override); 502 `action_failed` (a server's controller did not mount it: in its words); 422 `invalid` (a drive it has not got, writable where that is not offered, a way of starting it cannot do, a restart with `boot` "none" where it can be told to start from it, a restart where it has no power board); 504 `timeout` and 502 `dropped` (it may have been done); 502 `another_machine`; the device's. A refusal after the image was put in says so: `"mounted": true`. Every mount, and every start or restart from it, is in the activity log with the account, the machine, the image, the drive, and its SHA-256 where qKVM carried it there |
| `POST /api/v1/devices/{id}/media/unmount` | admin, a person | `image`* (`image` of `mounted`, as the confirmation named it), `machine`*, `listed` (as for a mount) | the drive is emptied, and the boot order put back where it was set to start from the image from here: `ok`, `note` ("nothing was mounted"; or what is left of the boot order), `mounted` (null). 409 `moved` (as for a mount); 409 `changed` (another image is in the drive now, or the machine is called otherwise: nothing was taken out); 409 `busy`; 502 `another_machine`; the device's. In the activity log as a mount is |
| `POST /api/v1/devices/{id}/media/upload?name=...&machine=...&listed=...` | admin, a person | the image itself as the body, its length said (`Content-Length`, 16 GB at the most); `name`* (what it is called on the device), `machine`* (as the confirmation named it), `listed` (as for a mount) | the image carried into the device's own storage (an offer with `upload`), streamed as it comes and hashed on its way, kept nowhere on the wall: `ok`, `image` (as `GET .../media` lists it: `id`, `name`, `where`, `size`, `partial`, `sha256`), `sha256`. 409 `moved` (as for a mount, before a byte is read); 409 `changed` (the machine is called otherwise); 409 `duplicate` (an image of that name is there); 409 `busy` (another upload to it under way, its drive busy); 411 `length_required`; 413 `too_large` (over 16 GB, refused before a byte is read); 422 `invalid` (a name of characters qKVM does not hand on, an empty body, a machine without uploads); 507 `no_space`; 400 `disconnected` (cut off, gone quiet for a minute) and 403 `stopped` (the account may no longer); the device's. What a refused or cut-off upload wrote is removed from the device, where it allows that; the answer says where it could not be. In the activity log with the account, the machine, the image, its size and its SHA-256 (one that failed: how much of it came) |
| `GET /api/v1/devices/{id}/media/upload` | admin, a person | | the upload under way to the machine: `uploading` (`name`, `size`, `sent` (bytes carried to the device so far), `by`, `at`), or null. Nothing is asked of the device for it |
| `POST /api/v1/devices/{id}/media/delete` | admin, a person | `image`* (an `id` as listed), `machine`*, `listed` (as for a mount) | the image deleted from the device's own storage (an offer with `delete`): `ok`, `note` (null; "it was not on the KVM any more"). 409 `moved` (as for a mount); 409 `busy` (it is mounted, or being uploaded); 409 `changed`; 422 `invalid`; the device's. In the activity log as a mount is |
| `PUT /api/v1/wall/order` | admin | `ids`* (device ids, first to last; the rest keep their order after them) | `ok`, `ids` (the whole order, as it is now, for every browser). 507 `not_saved` |
| `POST /api/v1/devices/remove` | admin | `ids`* (1 to 5000 device ids, within the 64 KiB a body may have; one given twice is one machine) | takes every one of them off the wall, or none: `ok`, `removed` (their ids, in the wall's order). Each one's saved password and history go with it, and each gets a line of its own in the activity log (`device_removed`), as one removed on its own does. An action on its way to one of them is answered as one cut off by an edit of the tile (it may have been done), and a live line to one is told `gone`, the keys it held let go of first. 404 `not_found` with `unknown` (the ids that are not on the wall: nothing was removed); 507 `not_saved` (nothing was removed, and nothing on them was cut off) |
| `GET /api/v1/tokens` | admin | | `tokens`: each `id`, `name`, `kind` ("api" or "display"), `role`, `devices` (ids, or null for all), `groups`, `created`, `expires` (null: never), `used` (null: not yet). Never the token itself |
| `POST /api/v1/tokens` | admin | `name`*, `kind` ("api" default, "display"), `role` ("viewer" default, "operator"; never admin), `devices`, `groups`, `days` (1 to 3650; left out: until taken back) | 201 `token` (shown this once), `record` (as listed). 507 `not_saved` |
| `DELETE /api/v1/tokens/{id}` | admin | | `ok`; a screen showing with it goes dark. 404 `not_found` |
| `POST /api/v1/export` | admin, a person | `password`* (the account's own, again), `parts`* (of "devices", "actions", "alerts", "wall", and since 0.4.0 "signin": signing in through an identity provider, its client secret only in an encrypted file), `passphrase` (10 characters or more: an encrypted file with the passwords in it; empty: a plain file without them) | the file as `application/json` with a `Content-Disposition` name (`qkvm-<date>.qkvm` or `.json`), and the header `X-QKVM-Not-Opened`: how many saved passwords or texts are not in it because they do not open any more. 401 `bad_password`; 422 `invalid`, `too_large` (more in the wall than a file holds); 503 `locked` |
| `POST /api/v1/import/read` | admin, a person | `file`* (its text), `passphrase` (of an encrypted one) | what the file holds, changing nothing: `encrypted`, `secrets` (a plain file with passwords in it), `made` (seconds since 1970, 0 where it does not say), `program` (the version that wrote it), `devices` (null where the file has no such part; else each `name`, `host`, `kind`, `group`, `password` (whether one is in the file), `tls`, `open_url`, `new` (this wall would take it), `same_as` (the name of the tile here that is the same device, or empty)), `actions` (null, or each `name`, `kind`, `keys`, `text` (of the new ones; what a button will type is read before it is taken), `enter`, `danger`, `new`), `alerts` (null, or `enabled`, `address` (the file names one), `host` (of that address), `format`, `kinds`, `destinations` (each `kind`, `name`, `host`, `private`; the first is the one `address`, `host` and `format` speak of)), `wall` (null, or `interval`, `update_check`), `signin` (since 0.4.0, there where the file has it: `enabled`, `name`, `issuer`, `client_id`, `password` (whether the client secret is in the file), `roles` (each `group` and the `role` it gives), `anyone`, `domain`, `private`), `left_out` (a sentence for each entry that did not pass). 422 `not_a_file`, `damaged`, `newer`, `passphrase_needed`, `wrong_passphrase`, `too_large` |
| `POST /api/v1/import` | admin, a person | `file`*, `passphrase`, `take` (which parts, of the five; left out: the file is read and nothing is taken) | what was taken: `devices`, `actions` (how many were added), `alerts`, `wall` (whether they were replaced), `signin` (since 0.4.0, there where it was taken: true; it is taken in switched off), `left_out`. 422 `not_a_file`, `damaged`, `newer`, `passphrase_needed`, `wrong_passphrase`, `too_large`; 503 `locked`; 507 `not_saved` |
| `GET /api/v1/audit?device=&limit=` | admin | | what the activity log says of one machine (the chapter [Activity log](https://qkvm.com/docs/activity-log)): `device`* (its `id`; entries written before 0.2.0 named it only, and are found by the name it has now), `limit` (1 to 500, 100 left out; a number beyond either end is taken as that end). `entries` (newest first, at most `limit` of them), `more` (there are older ones than the last), `missing` (null; or `count`, `since` and `why`: entries the wall could not write, and so the log is not whole). Each entry: `time` (seconds since 1970), `event` (a word for what happened: `device_added`, `action`, `action_failed`, `alert`, `live_opened` and the rest; one not met is one added since), `user` (who did it: an account's name, or a token's followed by " (token)"; left out where the wall did it by itself, as an alert), `device` and `device_id` (the machine by its name at the time, and by its id: since 0.2.0); where its event has them, `action` (the action's name, as `POST .../actions` takes it), `error` and `note` (sentences: why it failed, and what else is to be known), `state` and `was` (an alert: the state the machine went into and the one it came from); and an alert of a [watched screen](https://qkvm.com/docs/alerts#watching-a-screen) `watch` (`no_signal` or `unchanged`), `minutes`, `back` (true: it is over) and, where its picture was kept, `picture` (the stamp to ask for it by, below: digits) and `picture_at` (when the wall had that picture, in seconds since 1970). Whatever else an entry holds is as its event writes it. 503 `activity_unavailable` (the log could not be read in time: ask again in a moment); 503 `busy` (read in turns, as the history is: `Retry-After` says when). Without `device` (the whole log), with the log's other parameters, and its download, it is the page's own |
| `GET /api/v1/devices/{id}/alert-picture/{stamp}` | admin | | the picture a screen alert of the machine kept, by the `picture` of the alert's entry (above): `image/jpeg` or `image/png`, with `Cache-Control: no-store`. Only the last alert's picture of each machine is kept, for 30 days, and it goes when the machine leaves the wall. 404 `not_found`; 404 `no_picture` (no longer kept, or never of this machine) |
| `GET /api/v1/alerts` | admin | | how the wall tells of trouble (the chapter [Alerts](https://qkvm.com/docs/alerts)): `enabled`, `has_webhook` (an address to send to is saved; it is never shown), `format` ("auto", "json", "ntfy", "slack", "discord"), `offline`, `no_signal`, `problem`, `recovered` (which changes are told), `link` (the wall's own address, for an alert to point at; empty: none), `paused_until` (seconds since 1970 while alerts are paused; else null), `last_sent` (when an alert last went out, or null), `last_error` (why the last one did not, a sentence, or null) |
| `PUT /api/v1/alerts` | admin | `enabled`*, `webhook` (the address; left out or empty: the saved one is kept), `forget_webhook` (true: the saved one goes), `format`, `offline`, `no_signal`, `problem`, `recovered` (each true where left out), `link` (left out: as it is; empty: none), `private` (since 0.4.0: whether the address may be a private one; left out or null: as it is) | as `GET /api/v1/alerts` answers, as saved. 422 `invalid` (an address alerts are not sent to, a link that is no address of a wall: nothing was changed); 507 `not_saved` |
| `POST /api/v1/alerts/pause` | admin | `minutes`* (0 to 10080; 0: send again from now) | as `GET /api/v1/alerts` answers. 507 `not_saved` |
| `POST /api/v1/alerts/test` | admin | | a test alert, sent at once and tried once, to the saved address: as `GET /api/v1/alerts` answers. 409 `no_webhook` (no address is saved); 502 `not_delivered` (the message says what the other end answered) |

### A machine, as the wall lists it

In `devices` of `GET /api/v1/wall`:

| Field | Is |
|---|---|
| `id` | eight hexadecimal digits: what every other request names the machine by |
| `name`, `host`, `group` | as shown on its tile; `host` is the name or address and port the wall talks to |
| `kind` | `kvmd` (GL.iNet Comet, PiKVM and alike), `jetkvm`, `redfish` (a server's controller), `amt` (a business PC's Intel AMT engine), `vnc` (a VNC server), `proxmox` (a virtual machine on Proxmox VE) |
| `picture` | false: a server, whose tile shows how it is doing where a KVM's shows a screen (it may still have a picture: `screen` in `can`) |
| `open_url` | where a browser reaches the machine's own page |
| `same_as` | other tiles that are the same machine under another address: each `id`, `name`, `host` |
| `can` | what this tile can be asked, as words (below) |
| `amt_view` | a PC with Intel AMT's only: which of its three views its tile is in, `health`, `stills` or `live` (`PUT .../view` changes it) |
| `target` | the machine the tile is at (0.4.0): 32 hexadecimal digits, a mark of the address it is spoken to at and of what it is known by there, which an action and a live picture send back. It changes where an edit puts another machine under the tile, and where what qKVM knows of the machine grows (its certificate or its number first remembered); not with a new name or group. Nothing secret is in it, and nothing can be read out of it |
| `open_in` | to an operator and an admin, where the machine has any (0.4.0): where else it is opened, by kind, `meshcentral` (the https address of its page on a MeshCentral), `rustdesk` (its RustDesk ID), `rdp` (its Remote Desktop host, and port where it is not 3389), as [Open in](https://qkvm.com/docs/using-it#open-in) says. Plain links: nothing secret is in them |
| to an admin only | `url`, `custom_open_url`, `username`, `tls` (`pinned`, `system`, `insecure`), `fingerprint`, `has_password`, `alerts`, `fingerbot_strength` (how hard a Fingerbot paired with the KVM presses: `firm` or `light`), `no_signal_minutes` and `unchanged_minutes` (its screen watched: [Watching a screen](https://qkvm.com/docs/alerts#watching-a-screen); 0 is off). The password is never sent to anybody |

**`can`** says what this machine can be asked: from its driver, and from what the wall last
found at the device (a power board, several inputs, a light). It is in the wall's answer
and in the status, and the status's is the fresher: a client that acts goes by that one,
and by the wall's until there is a status. No client has to guess it from the kind of
device, and none should: a server whose controller is not AMI's has a power button and no
keyboard, and a KVM without a power board has no power button either. Each word opens these requests:

| Word | Opens |
|---|---|
| `screen` | a picture: `GET .../snapshot` (a server: as long as its controller is not known to give none, which asking finds out; a PC with Intel AMT: where its KVM may be used; a virtual machine on Proxmox: while it runs; the status's `screen` says the same) |
| `keys` | `keys`, `ctrl_alt_del`, and a saved action that presses keys (a server: once its console is known to be AMI's, and while nobody at the controller's own console has it; or OpenBMC's, while its screen can be had) |
| `text` | `text`, and a saved action that types |
| `jiggler` | `jiggler_on`, `jiggler_off` |
| `power` | the power button: `atx_power`, `atx_power_long` (a KVM with a power board; a server; a virtual machine on Proxmox, where holding it stops the machine at once) |
| `reset` | the reset button: `atx_reset` |
| `fingerbot` | the power button pressed by a Fingerbot paired with the KVM: `fingerbot_power`, `fingerbot_power_long` (beside `power`, where the KVM has a power board as well) |
| `power_state` | switching on, or asking to shut down, by what is wanted: `power_on`, `power_off` (a server, which knows whether it is on; a PC with Intel AMT; a virtual machine on Proxmox) |
| `bios_setup` | `bios_setup`: start into the BIOS setup once, then switch on or restart (a PC with Intel AMT whose engine offers it; a server over Redfish whose controller allows the "BiosSetup" boot override); one machine at a time, not a bulk run |
| `wol` | `wol`, and `GET .../wol` for what the KVM has saved to wake |
| `ports` | `port` (the status's `ports` says which inputs there are and which is on screen) |
| `reboot` | `reboot`: the KVM itself, or a server's controller |
| `resume` | `resume`: a JetKVM that stepped aside for whoever opened its own page is taken up again |
| `locator` | `locate_on`, `locate_off`: a server's light to find it by |
| `console` | `POST .../console`: a signed-in way into a server's own console |
| `live` | the live picture: `POST .../live` for a pass, then the WebSocket at the same path (a KVM; a server whose console the wall reads, once that is known; a PC with Intel AMT whose KVM may be used; a virtual machine on Proxmox while it runs; a VNC server) |
| `control` | keyboard and mouse over that line: `control` with `on` true, and with `take` true to take them over (an admin in person) (a KVM; a PC with Intel AMT; a virtual machine on Proxmox; a VNC server; a server whose console is AMI's, as `keys`, or OpenBMC's) |
| `media` | virtual media: `GET .../media`, `POST .../media`, `POST .../media/unmount`, and where it is offered `.../media/upload` and `.../media/delete`, an admin's in person (a virtual machine on Proxmox; a KVM with the kvmd interface whose drive is switched on; a JetKVM) |

A word not in this list was added since: a client leaves out what it does not know. And
`can` is what the wall would send, not a promise that the machine takes it: a controller
set up without a reset of that kind still answers 502 `action_failed`.

### How a machine is

In `GET /api/v1/status`, by `id`. Any value may be null: a device that does not say is not
guessed at.

| Field | Is |
|---|---|
| `can` | as above, as of this look |
| `target` | since 0.4.0: the machine this status was found at, as the tile's `target` in the wall says it. Where it is not the `target` of the tile as a client has it, the tile was pointed at another machine since the client fetched the wall: that status is not of the machine it shows, and the wall is fetched again |
| `state` | `online`, `no_signal` (there, and its computer shows nothing; a server: switched off), `offline`, `auth` (it refuses the saved password), `error` (its certificate changed, it does not sign qKVM in, a server reports a critical fault, and the like: `error.code` says which), `busy` (a JetKVM whose one viewer is somebody else), `connecting` (nothing known yet) |
| `error` | null, or `code` and `message` (the message fit to show) |
| `last_seen_ago` | seconds since the device last answered; null: never |
| `video` | `signal` (true or false), `width`, `height`, `fps` |
| `usb` | `keyboard`, `mouse`: whether the computer sees them |
| `atx` | `enabled` (a power board, or a server), `power` (the computer is on; asleep counts as on; null where the board does not say, at this look), `hdd`; and on a KVM with the kvmd interface, only where the board is no witness of the power, `note`: `code` and `message` (left out otherwise, as before 0.3.2). `power_led_unwired`: the board says the power light is off while the screen shows a picture, so its power-LED wires are probably not connected (the page says neither *Power on* nor *Power off* then, and why); never on a KVM with several inputs, whose board may be another computer's |
| `fingerbot` | a KVM's: null, or, where a Fingerbot is paired with it, `battery` (percent; null until it was asked, which is once an hour) and `low` (below 25). Nothing of the computer's power comes from a Fingerbot |
| `health` | `temp` (the KVM's own, or a server's hottest processor, in degrees Celsius), `cpu`, `mem` (percent) |
| `about` | `model`, `version`, as the device says them |
| `ports` | null, or `active` (counted from 0) and `list` (each `name`, `signal`) for a KVM with several inputs |
| `several_inputs` | since 0.4.0, a KVM's: true where it has shown several inputs at the machine its tile is at, kept with the tile across restarts, locks and a certificate trusted anew, also while `ports` is null; let go of once its switch has said at every look for ten minutes that there is none, or when the tile is removed or pointed elsewhere (for an hour after that its switch is asked at every look); true also where qKVM cannot tell yet, until the KVM's switch answers (left out otherwise). Keys and text for it name their input ([Doing something](https://qkvm.com/docs/the-api#doing-something)) |
| `kind` | said by a JetKVM's and a server's status; a KVM's says neither this nor `picture` (the wall says both for every tile) |
| `picture` | said by a server's status: false |

Before the first look at a device there is only `can`, `target`, `state` (`connecting`), `error` and
`last_seen_ago`; while it cannot be reached, those with `error` filled in, and `kind` (and a server's
`picture`) where the status says them at all. A server adds
`screen` (a picture of its screen can be asked for), `console` (a signed-in way into its
console can be asked for) and `server`: `power` (the controller's own word: "On", "Off" and
others), `health` ("OK", "Warning", "Critical", or null), `processor`, `processors`,
`memory_gib`, `temperatures` (each `name`, `celsius`, `ok`), `fans` (each `name`, `reading`,
`unit`, `ok`), `unwell` (the names of the sensors it is not happy with), `locator` (the light:
true, false, or null where there is none), `no_screen` (null, or the sentence why its screen
is not shown where it could be), `rfb_console` (where the controller is OpenBMC with its KVM,
the path on it of the WebSocket that carries its console as VNC, `/kvm/0`, which is where the
wall takes that server's screen from; else null).

A business PC with Intel AMT (`kind` `amt`) is said as a server is, with no temperatures, fans
or light (empty, or null), `screen` true where its screen can be had through its KVM (and
`screen`, `keys`, `text`, `live` and `control` in its `can`), else false with `no_screen` saying
why, and one more record in `server`, `amt`: `power` (the engine's own number for the power
state, of which `server`'s `power` is the word, but for *Shutting down*, which `server`'s `power`
says from the moment the engine takes a shutdown of the wall's until the PC is seen off, while
the engine itself says nothing of it), `control` (how the engine was set up: "none",
"client", "admin", or null where it did not say), `kvm` ("enabled", "disabled", "mebx" where it
was switched off in the PC's MEBx, "absent" on vPro Essentials, which has none, or null),
`consent` (true where a KVM session needs the code the PC shows on its own screen, false, or
null), `listener` (true where the engine's redirection listener is on, which its KVM is reached
through; false, or null), `session_timeout` (the minutes after which the engine ends a KVM
session, 0 for never, or null), `make`, `model`, `serial` and `bios` as the engine says them,
`plain` (true where the wall reaches the engine over plain HTTP), `view` (its tile's view, as
`amt_view` above: in `health`, `screen` is false and `no_screen` says so, whatever the KVM is like),
and `shutdown` (since 0.4.0: what may be the matter where a shutdown of the wall's has not come
about three minutes after the engine took it; else null).

A virtual machine on Proxmox VE (`kind` `proxmox`) is said as a server is: `state` `online` while it
runs and `no_signal` while it is stopped, `atx.power` the same, no temperatures, fans or light,
`health.cpu` and `health.mem` (percent of what it was given, while it runs), `screen` true while
it runs and its console can be had (and `screen`, `keys`, `text`, `live` and `control` in its
`can`), else false, with `no_screen` saying why where it runs; in `server`, `power` ("Running",
"Paused", "Stopped"), `processor` ("vCPU"), `processors` and `memory_gib` as it was given them, and
one more record, `proxmox`: `node` (the node it is on, followed where it was moved), `vmid`,
`status` ("running" or "stopped", Proxmox's own word), `qmpstatus` (what QEMU says of it: "running",
"paused" and others) and `uptime` (seconds).

A machine with `media` in its `can` says `media`, what is in its virtual drive, to everybody who
sees it: null where nothing is (or nothing is known yet), else `drive` ("cd", "flash", "disk"), `image` (an
`id` as `GET .../media` lists it, or what the machine says is in it), `name`, `where`, `read_only`,
`first` (it starts from it first at its next start; null on a KVM, which cannot tell), `by` and `at`
(the account that mounted it from qKVM, and when, in seconds since 1970; null where that is not
known: put there on the device itself, or before qKVM was restarted), `sha256` (where qKVM carried
it there, and it is still that image; else null). A virtual machine on Proxmox says it as its
settings were last read: once a minute, and at every request of its virtual media; a KVM with the
kvmd interface as its line for events said it, or as it was asked within the last 30 seconds; a
JetKVM at every look; a server as its controller said it within the last 30 seconds, and at every
request of its virtual media (its `first` true where its boot override is "Cd", else null).

### An account

`user` in a sign-in and in the session: `id`, `name`, `role` (`admin`, `operator`, `viewer`),
`totp` (a second step is on), `must_enroll` (one is required and not set up: every request
but signing out and setting it up answers 403 `totp_required`), `sso` (signed in by the
identity proxy: there is nothing to sign out of here), `recovery_codes` (one-time codes
left), `token` (not a person: a wall screen opened with its link).

### Doing something

`POST /api/v1/devices/{id}/actions`, `{"action": "..."}` and what that one needs. The last
column says the word of `can` it takes. Any action may also say `"watching": true`: whoever
sends it has the machine's large view or live view open (a PC with Intel AMT then opens a
session to its screen before switching on, or starting into its BIOS setup, so the start shows
from the first moment). It is not heard with a `"batch"`: an entry of a bulk run comes from the
selection, not from a view.

| `action` | Does | Also give | Needs |
|---|---|---|---|
| `keys` | a key combination | `"keys": "MetaLeft,KeyL"` (names as browsers and kvmd spell them, up to eight) | `keys` |
| `ctrl_alt_del` | that one | | `keys` |
| `text` | type text | `"text": "...", "enter": true` (up to 2000 characters, US keyboard layout; on a JetKVM, the layout it says its computer uses, and 422 `invalid` before anything is typed for a character that layout cannot type) | `text` |
| `custom` | a saved action | `"custom_id": "..."`, and `"custom_changed"`: the action's `changed` as it was listed, refused with 409 `changed` if it was edited since, or edited or removed while it waited for what the last holder of the keyboard had down to be let go of (saved text is typed by people only: a token that types it could read it back off the screen) | `keys` or `text` |
| `atx_power`, `atx_power_long` | press the power button, hold it; answered once the button is let go, and where it must switch the computer on (or off) once that is seen; the KVM's refusal (a 4xx) is 502 `action_failed`, anything else that is not its yes 504 `timeout` or 502 `dropped` (it may have pressed), after which a press of the board's (or a Fingerbot's) is 409 `busy` for eight seconds and the button's hold | | `power` |
| `atx_reset` | press reset; an answer that is neither yes nor no as for the power button; on a KVM with the kvmd interface answered once its screen is seen to change, and where it is not within twenty seconds, done with a `"note"` that says it was pressed and the restart not seen (see *Power* under [Using it](https://qkvm.com/docs/using-it)) | | `reset` |
| `fingerbot_power`, `fingerbot_power_long` | a Fingerbot presses the power button for half a second, or holds it for eight, as hard as the machine's `fingerbot_strength` says; answered once the KVM has said the Fingerbot took the press and the press's own time is over (some three and eleven seconds); the KVM's refusal ("Failed to click") is 502 `action_failed`, anything else that is not its yes 504 `timeout` or 502 `dropped` (it may have pressed), after which a press is 409 `busy` for as long as that one can last; 422 `invalid` where the KVM said no Fingerbot is paired | | `fingerbot` |
| `power_on`, `power_off` | a server: switch on, or ask it to shut down; one that is so already is left alone and answers `"note": "already on"` or `"already off"` | | `power_state` |
| `bios_setup` | start into the BIOS setup once, then switch on (if off) or restart (if on); 422 `invalid` with a `"batch"` (one machine at a time); 409 `action_failed` where another boot override, or a boot option that destroys data, is already set | `"watching": true` (as for any action: see below) | `bios_setup` |
| `locate_on`, `locate_off` | a server's locator light | | `locator` |
| `reboot` | restart the KVM itself (for a server: its controller) | | `reboot` |
| `jiggler_on`, `jiggler_off` | keep the computer awake, or let it sleep | | `jiggler` |
| `wol` | Wake-on-LAN from the KVM | `"mac": "aa:bb:cc:dd:ee:ff"` | `wol` |
| `port` | show another input of a multi-port KVM | `"port": 0` | `ports` |
| `resume` | a JetKVM: take its picture back from whoever opened its own page | | `resume` |

The page asks before power, reset, a restart, and anything marked `danger`, and before
anything sent to several machines: a program should do no less. One thing at a time per
machine: while an action is on its way, a second one for the same machine is refused with
409 `busy`, whoever sends it.

**The machine it was asked for** (since 0.4.0). A tile keeps its `id` when an admin points
it at another machine, so an action sent by the id alone goes to whatever the tile is at
when it arrives. With `"target"`, the machine's `target` as the wall listed it when the
question was asked (taken then, for a menu's button that acts at a click when the menu was
drawn, and kept for as long as the question and a bulk run's turn take), it goes only to
that machine: where an edit has put another machine under the tile meanwhile, it is
refused with 409 `machine_changed`, and nothing is sent to either. The
page sends it with every action, and on that refusal says so, shows the wall anew and sends
nothing again by itself: a program should ask the person again too. Where what qKVM knows
of the machine grows meanwhile (its certificate or its number first remembered), the mark
changes as well, and the action is refused once. Left out, as by a script or a program
before 0.4.0, it is not asked: the action goes to the machine the tile is at.

**The computer on screen** (since 0.4.0). A KVM with several inputs types keys and text on
the computer on screen, so they go with `"input"`, the status's `ports.active` as the person
saw it (taken with `target`), by every action that sends keys: `keys`, `text`, `ctrl_alt_del`
and a saved action. Right before they go, after any signing in, qKVM asks the KVM itself which
input is on screen: not what its last look found. Where the KVM shows another, or does not say
(its switch does not answer), they are refused with 409 `input_changed`, and nothing is sent.
So a switch at the KVM's own buttons a moment before is no longer a way for them to reach the
other computer, and the keys must leave within half a second of its answer or they are refused
the same way (a KVM whose connections are all busy); a switch inside that half second still is. The
status says `several_inputs` of such a KVM, also while `ports` is null: the page sends `input`
with every keyboard action of it, and offers no keys, text or shortcuts while it cannot name
the input. Where the status says neither `several_inputs` nor `ports`, a keyboard action goes
with `"one_input": true` instead: the sender took the machine for one of a single input. It is
refused the same way, with 409 `input_changed` and nothing sent, where qKVM knows the KVM has
several inputs, or its switch, asked right before the keys go, answers anything but kvmd's own
word that it has none within two seconds (stock kvmd's empty switch, a GL.iNet KVM's
`UnavailableError`, its web server's 404); a machine
with no inputs to choose from (a JetKVM, a PC with Intel AMT, a server, Proxmox, VNC) takes it
as so. The page sends `input` or `one_input` with every keyboard action, never neither. Power,
reset, a Fingerbot and the rest are the KVM's own and are not bound to an input (its board
presses whatever it is wired to): neither is asked of them. Left out, as by a script or a
program before 0.4.0, they are not asked, and the keys go to whichever computer is on screen,
as before.

### Manners

- One viewer's worth of asking: the status no more often than `interval`, a picture per
  tile no more often than that, with `age` set to the interval. Asking for pictures is what
  keeps the wall connected to its devices; a program that stops asking lets a JetKVM's one
  viewer go back to whoever wants it.
- Do not ask in the background for a window nobody sees.
- 401 `unauthorized` in the middle of things means the session ended (signed out elsewhere,
  ended by an admin): sign in again, do not loop. `Retry-After` is meant.

### The page's own

These are under `/api/v1/` as well, take an admin (but for the first-run setup, which takes
nobody), and change with the page: `setup`; `devices` (adding, changing and removing one; a KVM
whose plain address sends everybody on to HTTPS at the same host is refused 422 `https_only`, with
`use`, that address, which the page offers and nothing takes by itself; but for an edit with
`force` that leaves its address, kind, certificate check, user name and password as they are,
saved as any other),
`devices/{id}/certificate` and `devices/{id}/trust` (since 0.4.0 with `target` as for an action, in the address and in the
body: 409 `machine_changed`, nothing shown or pinned, where the tile is at another machine by then), `devices/{id}/kvm` (switching a PC's Intel AMT
KVM on or off on its engine, `{"on": true}`, and since 0.4.0 `target` as for an action: 409 `machine_changed`, nothing
changed on either engine, where the tile is at another PC by then; 409 `busy` with `by` as for an action), `devices/{id}/open-in`
(a machine's "Open in" links, `PUT` with `meshcentral`, `rustdesk` and `rdp`, all at once: one left out or empty is
none of that kind; 422 `invalid` for one that is no such link, saying why; and since 0.4.0 `target` as for an action: 409
`machine_changed`, nothing saved, where the tile is at another machine by then), `discover` (with `notes`: why a
tailnet that is there was not asked); `netbird` (NetBird's management API, `{"url", "token", "private"}`, as
[Over Tailscale or NetBird](https://qkvm.com/docs/over-tailscale-or-netbird) says: its token is taken and never handed back); `proxmox` (`proxmox/guests`, `{"url",
"username", "password"}`: the virtual machines an API token may see on a Proxmox, to pick from when
adding them, and `named`, the one an address names by its ID); `actions` (saving one);
`users`; `security`; `recovery`; `oidc` (signing in through an identity provider, as
[Sign in with an identity provider](https://qkvm.com/docs/accounts#sign-in-with-an-identity-provider) says: `oidc` itself, its settings, whose client
secret is taken and never handed back; `oidc/logout`, which signs out every browser the provider signed in; and three that
take nobody, `oidc/offer` for the sign-in page's button, `oidc/begin` for its press, and `oidc/callback`, the way back from
the provider); `settings` (and `settings/media`, `{"folder", "address"}`: the folder of
images for servers and the wall's address as their controllers reach it); `backups` (their settings; `backups/key`,
which takes the admin's password and answers with a new backup key's recovery kit, that once and never again;
`backups/run`, "Back up now"; `backups/verify`, which reads the latest whole, as [Backups](https://qkvm.com/docs/backups) says); `alerts` beyond the four requests promised
above (`alerts/destinations`, `alerts/destinations/{id}` and under it `test`, `log` and `secret`, the places alerts go,
as [Alerts](https://qkvm.com/docs/alerts) says; every
address, key, token and password of one is taken and never handed back: a destination is shown by its host); `push` (the browsers told the alerts by Web
Push, which takes any account, for its own: `push`, `push/key`, `push/{id}`, `push/{id}/test`, as
[On a phone](https://qkvm.com/docs/alerts#on-a-phone) says); `audit` (the activity log beyond one machine's, which is promised
above: `q`, `kind`, `before`, `since`, `until` and `user`, the whole log without `device`, and
`audit/export` to download it, as the chapter [Activity log](https://qkvm.com/docs/activity-log) says); `metrics` (the token for
`/metrics`); `update`. And what two promised requests take beyond their rows: `big` of a picture
(`GET .../snapshot?big=1`: it is for the large view, and a PC with Intel AMT holds a session open
for it), and `take` sent to `import/read`, which is checked as for an import and not heard. A
program written against them is written against this version. Their codes are in `words.json` all
the same.
