# SuanZu API > Rent GPU and CPU machines, and manage the machines you rent out, from your own code. - Base URL: https://suanzu.ai - OpenAPI 3.1 spec (full parameters, fields and examples): https://suanzu.ai/openapi.yaml - Docs: https://suanzu.ai/docs/api ## Authentication Create an API key in the console (Console → API keys) and send it on every request: `Authorization: Bearer sz_live_...`. Only this header is accepted; keys in the query string are ignored. Market endpoints also work without a key. A key has one or more scopes: | Scope | Allows | |---|---| | `renter:read` | Read your instances, balance, ledger, rent-balance deposits, compute task templates, instance tasks, tags, wallets and variables. | | `renter:write` | `renter:read` + rent, stop, change startup command, restart the container, get connection details, manage compute task templates, instance tasks, tags, wallets and variables. | | `host:read` | Read your machines, GPUs, messages, command results and progress, installable driver versions, tags, templates (and which machines use them), wallets and variables, history charts, fault history, groups, earnings, account, billing (also per day) and service-fee deposits. | | `host:write` | `host:read` + set prices (directly or from a template), list / unlist, rename, tag, set compute tasks, overclocking and auto-fan, manage templates (price, compute task, overclocking, auto-fan), tags, wallets and variables, pause / resume / restart compute tasks, fetch task logs. | | `host:exec` | `host:write` + reboot machines, upgrade the Agent, install NVIDIA drivers, open remote access (root shell on the machine) and change its password. | A key can be limited to some device groups and to an IP allowlist. A key without an allowlist works from any IP; with one, requests from other IPs get 403 `api_key_ip_denied`. Machines and groups outside the key's range behave as if they did not exist (404, or missing from lists). On groups shared with you by another account, your role in that group still applies, and the owner must allow API access for you. A key limited to device groups cannot change account-wide settings: account-wide templates (`group_id: null`), account-wide wallets and variables, and your tag library (403 `group_forbidden`); it can still read them and use them on its groups. **Keys see only your own account's money.** Balances, ledgers, billing and earnings are always your own account's. On groups shared with you by another account, a key never sees the owner's earnings, whatever your role: earnings fields are null (`summary.earnings`, `groups..earnings`), rental history has `show_income: false`, and `GET /api/v1/host/earnings` / `earnings/leases` with such a `group` return 404 `group_not_found`. Machine and status data in those groups is still returned by your role. **Multi-machine writes must stay in one group.** With an API key, a host request that names several machines (`price`, `price-template`, `listing`, `listing/precheck`, `tags`, `tasks/apply`, `tasks/restart`, `tasks/redownload`, `tasks/pause`, `tasks/resume`, `oc-template`, `oc/reapply`, `autofan-template`, `commands/reboot`, `commands/upgrade`) must only name machines in the same device group; otherwise the whole request is rejected with 400 `cross_group` and nothing is done. Ungrouped machines count as one group. Machines you cannot see do not count (they fail one by one with `machine_not_found`). ## Conventions - Amounts are decimal strings in USDT (for example `"0.053"`), never JSON numbers. - Times are UNIX seconds (integers). - IDs in responses are strings. Integer IDs (leases, ledger rows) are decimal strings, for example `"57"`. - Errors always look like `{"ok": false, "code": "...", "error": "..."}`. Branch on `code`; `error` is English text for humans and may change. - Every endpoint below can also return 500 `internal`; it is not listed on each endpoint. - Unknown query parameters, a query parameter sent twice, unknown body fields and out-of-range values are rejected with 400 `bad_request` on every endpoint; `error` names the parameter. (Only `gpu` and `cpu` of the market list may be repeated.) A body over the size limit gets 413 `body_too_large`. - A request that runs too long (5 seconds for GET, 30 seconds for other methods) gets 503 `request_timeout`. For a write this means the result is unknown: read the current state before you send it again. - A 200 on a write means the change is saved. Most settings then reach the machine with its next heartbeat. When you need to know that the machine actually applied something (a rental, a command, overclocking, compute tasks), poll the field named in "Async operations and polling" below. - GPU model names: market endpoints use short names (`CMP 50HX`, `RTX 4090`: the prefixes `NVIDIA `, `GeForce ` and `Tesla ` removed). Host endpoints use the full name the driver reports (`NVIDIA CMP 50HX`, `NVIDIA GeForce RTX 4090`) in `gpus[].name`, the `gpu` filter, `gpu_counts` and `/host/gpus`. Price template `prices.gpu` keys and overclocking template `models` keys use the GPU model name: `show_name` when the GPU has one (for example `CMP 170HX`, which the driver reports as `Graphics Device`), otherwise `name`. A generic driver name (`Graphics Device`, `NVIDIA Graphics Device`) is not accepted as a template key (400 `template_invalid`). ## Pagination | Style | Endpoints | Next page | |---|---|---| | `cursor` + `pageSize` (default 50, values above 200 count as 200) | `GET /api/v1/market/machines` | Pass `next` as `cursor` with the same filters and `sort`; `next` is empty on the last page | | `page` + `per_page` | Instances (default 50, history 20, max 1000), instance charges (default 20, max 50), host machines, machine messages and GPUs (default 50, max 1000) | `page` + 1 until `page` = `total_pages`. A page past the end returns the last page (machines, instances) or an empty list (charges) | | `page` + `page_size` (default 20, max 100) | Renter ledger, deposits, host ledger, earnings leases | `page` + 1 until you have `total` items | | `before` + `limit` (default 20, max 100) | `GET /api/v1/host/machines/{machine_id}/leases` | Pass `next_before` as `before`; null on the last page | | `limit` only (default 10, max 200) | `GET /api/v1/host/machines/{machine_id}/timeline` | No next page: ask for a larger `limit`. Only the newest 200 items can be read | `GET /api/v1/account/deposits/pending` is not paged (at most 50 items, newest first). ## Rate limits Each key has a per-minute budget for each rate-limit class (see `x-rate-limit-class` on every endpoint). Over the limit you get 429 `rate_limited` with a `Retry-After` header (seconds). | Class | Requests per minute per key | Used by | |---|---|---| | `read` | 120 | Market, host machine list / detail / tasks, GPUs, tags, preset images | | `read_pg` | 30 | Balances, ledgers, earnings, billing, instance list, checks, groups, precheck, command timeline and progress, driver versions, messages, templates, wallets and variables, history charts, fault history | | `write` | 30 | Writes: stop, prices, listing, names, tags, templates, task settings and control, task logs, overclocking, auto-fan, wallets and variables, reboot, Agent upgrade, driver install, remote open / close / password | | `order` | 10 | Rent a machine | | `remote` | 20 | Fetch connection details with passwords | `read_pg` and market requests also share a small server-wide concurrency pool; when it is busy you can get 429 `rate_limited` with `Retry-After: 1` even under your per-minute budget. Limits may change before release. ## Key errors Any request that carries an API key can fail before the endpoint runs: 401 `api_key_invalid`, 401 `api_key_expired` (create a new key), 403 `api_key_route_not_allowed` (this endpoint is not open to API keys), 403 `api_key_scope_denied`, 403 `api_key_ip_denied`, 429 `rate_limited`. A request without a key to an endpoint that needs one gets 401 `unauthorized`. ## Async operations and polling Machines report a heartbeat about every 15 seconds. A machine is `online` while its last heartbeat (`last_heartbeat_at`) is at most 120 seconds old; after that `connectivity` is `offline`, `status_reasons` has `offline` and the live values are null. Commands and settings normally reach a machine with its next heartbeat; while someone is viewing the machine or its group (the machine list with `group`, or the machine detail) it is woken within about a second. | Operation | Poll | Until | Interval | Typical / limit | On failure | |---|---|---|---|---|---| | Rent delivery | `GET /api/v1/renter/leases` (`tab=current`) | `phase` is `running` (`pulling` → `preparing` → `starting` → `running`) | 10 s | Image pull may take up to 1800 s after the order; preparing and starting together up to 300 s after the pull | The instance leaves the current tab and shows up in `tab=history` with `end_reason: delivery_failed` and a `fail_code`. Nothing is charged. `retry_code` (during delivery) names a step that failed once and is being retried | | Stop an instance | `GET /api/v1/renter/leases` (`tab=history`) | `phase` is `released` | 15 s | At least two machine rounds (about 30 s). No time limit: an offline machine stays `stopping` until it comes back | Billing ends when you stop, whatever the phase. `stopping` only means the machine has not confirmed the cleanup yet | | Startup command | `GET /api/v1/renter/leases` | `startup.rev` equals the returned `startup_rev` and `startup.state` is not `pending` | 10 s | Next heartbeat | `startup.state: failed` or `exited` with `exit_code`; read `GET .../container-log` | | Commands (`reboot`, `upgrade`, `task_restart`, `task_logs`) | `GET /api/v1/host/machines/{machine_id}/timeline` | The item with your `cmd_id` has `state` `ok` or `error` | 10-15 s | Picked up with the next heartbeat (about 15-20 s). An offline machine must come back and start it within 600 s (`expire_at`) | `state: error` with `note` (see the dictionary below); the reason is in `latest_title`, logs in `GET .../messages` (`payload_gz`) | | Reboot | Same as commands | `state: ok`, `note: rebooted` | 15 s | Done when the machine is back online with a newer `boot_time` | `note: timeout` when it is not back within 600 s after the reboot started | | Agent upgrade | Timeline, then `GET /api/v1/host/machines/{machine_id}` | `state: ok`, then `agent_version` shows the new version (next heartbeat after the install) | 15 s | Mostly download time; the download alone may take up to 1800 s | `state: error` with the reason in `latest_title` (for example `Upgrade failed (exit 1)`), or `note: timeout` when no result arrives by `expire_at` + 1800 s, or `interrupted` when the machine rebooted meanwhile | | Driver install | Timeline; progress in `GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress` | `state: ok`, `note: rebooted` (back online with the new `driver_version`) | 15 s (progress 5 s) | Download plus install, then one reboot. Limit: 120 min from the start to the reboot, 10 min to come back | `state: error`, the code in brackets in `latest_title` (`[driver_download_failed]`, `[driver_install_timeout]`, `[driver_reboot_timeout]`, `[driver_version_mismatch]`, …). Before the reboot the old driver stays; `[driver_reboot_required]` = the driver was installed but the time limit passed before the reboot, reboot the machine yourself | | Overclocking | `GET /api/v1/host/machines/{machine_id}` | `oc.applied_revision` equals `oc.revision`. The single-machine calls (`/machines/{machine_id}/oc…`, `/machines/{machine_id}/autofan`) return that `revision`; the batch calls (`/machines/oc-template`, `/machines/oc/reapply`, `/machines/autofan-template`) return only `results[]`, so read `oc.revision` after the call | 15 s | One or two heartbeats after the save. With `deferred: rented` only after the rental ends; with `deferred: offline` when the machine is back | `oc.rejected` (the whole config was refused), `oc.result[].results[].code` other than `ok` / `unchanged`, `oc.verify_error`. `applied_revision` null = the machine never reported | | Compute tasks | `GET /api/v1/host/machines/{machine_id}/tasks` (renter: `GET .../leases/{lease_id}/tasks`) | The `states[]` item with your `binding_id` has `state: running` and its `revision` equals the task's `revision` | 15 s | Next heartbeat plus the download of the program package | `state` `retrying`, `gpu_missing`, `unsupported`, `held`; `exits_1h` ≥ 3 means it keeps crashing. Read the task log (renter: `GET .../tasks/{binding_id}/log`) and `latest` | | Task stats (hash rate) | Same | `stats_at` is set and `stats[]` has your `binding_id` | 30 s | Usually 15-35 s after the task reaches `running`. HiveOS tasks (`kind: hive`) only; custom tasks report no stats | No stats while the task is not `running`; they disappear 1200 s after the machine stops reporting them | `syncing: true` on the task endpoints means the task list is still being written; read again after a few seconds. Stats and states belong to the task list the machine reported last: after a change, wait until `states[]` shows the new `revision`. ## Status and code dictionary **Machine `status`** (host endpoints; the "status" filter uses the same values): | `status` | Meaning | What you can do | What the platform does | |---|---|---|---| | `unpriced` | No price set, not listed, no problem | Set a price, then list | Nothing | | `unlisted` | Priced but not listed, no problem | List it | Nothing | | `available` | Listed and rentable | Rent-related changes apply to new rentals | Shows it on the market | | `noncompliant` | Not listed, and it has a problem (`status_reasons`) | Fix the problem; listing fails with `not_eligible` | Nothing | | `fault` | Listed, but it has a problem (`status_reasons`, offline included) | Fix it; it comes back by itself | Hides it from the market until the problem is gone (you keep the listing) | | `rented` | Has a rental that is not released yet (delivery and stopping included) | See "Rented machines" below | Stops the rental for problems marked `stop` | **`status_reasons` codes.** Columns: what happens when the problem shows up before listing / while listed / while rented. `reject` = listing or renting is refused; `hide` = hidden from the market (`fault`); `refresh` = the listed specs are updated, still rentable; `stop` = the rental is stopped and the machine unlisted; `notice` = you are only notified; `-` = not checked in that state. `GET .../checks` shows the same as `outcome`. | Code | Meaning | Not listed | Listed | Rented | |---|---|---|---|---| | `offline` | No heartbeat for 120 s | reject | hide | notice | | `offline_rented` | Rented machine offline for 600 s (billing stops at the last heartbeat) | - | - | stop | | `price_unset` | Listed without a price for its unit | reject | - | - | | `group_invalid` | Its device group was deleted | reject | hide | notice | | `gpu_dropped` | A GPU is not seen by the driver | reject | hide | stop | | `gpu_driver` | The driver cannot read a GPU | reject | hide | stop | | `gpu_ecc_uncorrected` | Uncorrected ECC errors | reject | hide | stop | | `gpu_probe_failed` | GPU data could not be read (2 rounds in a row) | reject | hide | stop | | `gpu_count_low` | Fewer GPUs than listed (or than `expected_gpu_count`) | reject | hide | stop | | `gpu_mixed` | More than one GPU model | reject | hide | notice | | `gpu_changed` | GPU model or memory changed since listing | - | hide | stop | | `driver_changed` | Driver or CUDA version changed since listing | - | hide | stop | | `cpu_changed` | CPU model or socket count changed | - | hide | stop | | `ram_low` | Less memory than listed | - | hide | stop | | `ram_more` | More memory than listed | - | refresh | - | | `disk_changed` | Disk size changed by more than 1%, or disk type changed | - | hide | stop | | `os_changed` | OS or kernel changed | - | refresh | stop | | `pcie_degraded` | A GPU runs at a lower PCIe generation or width than listed | - | refresh | stop | | `pcie_changed` | PCIe link changed, none lower | - | refresh | notice | | `pcie_unstable` | PCIe link changed 3 or more times in 24 hours | reject | hide | notice | | `docker_down` | Docker is not installed or not running | reject | hide | stop | | `nvidia_runtime_missing` | NVIDIA GPUs but no NVIDIA container runtime | reject | hide | stop | | `runc_outdated` | runc older than 1.2.8 or unknown | reject | hide | stop | | `nvidia_toolkit_outdated` | NVIDIA GPUs with an NVIDIA Container Toolkit older than 1.19.1 or unknown | reject | hide | notice | | `disk_low` | Less than 5 GiB free on the system disk | reject | hide | notice | | `collect_invalid` | CPU, memory or disk data cannot be read | reject | hide | notice | | `rent_env_unsupported` | Not a physical machine or VM (container, WSL) | reject | hide | notice | | `agent_outdated` | Agent older than 1.2.0 | reject | hide | notice | | `tools_missing` | The Agent tool package is still downloading | reject | hide | notice | | `identity_conflict` | Two machines report with the same identity | reject | hide | notice | | `owner_inactive` | The owner account has stopped renting out | reject | hide | notice | | `data_invalid` | The machine's data is broken | reject | hide | notice | | `oc_rental_tampered` | Overclocking was changed by something else during a rental | - | - | stop | | `rent_container_lost` | The renter's container is gone | - | - | stop | | `rent_isolation_failed` | Network isolation of the rental cannot be checked or restored | - | - | stop | A code not in this table is handled as `hide`. `CheckRow.result`: `pass`, `fail`, `na` (not applicable now), `pending` (changed this round, confirmed on the next one). `CheckRow.outcome` is set on every row and says what happens if the rule fails in the machine's current state (null = nothing). The `action` of `GET .../checks` is `ok`, `hide` or `stop`. **Instance `phase`:** `pulling` (downloading the image; `progress` 0-99), `preparing` (GPU and overclocking checks), `starting` (container starting), `running` (billed), `stopping` (ended, waiting for the machine to clean up), `released` (cleaned up). Only `running` can be used; stopping is allowed in every phase before `stopping`. **`end_reason`:** `renter` (you stopped it; cancelled during delivery has `fail_code: renter_cancel`, not charged), `balance_exhausted` (your balance could not pay the next minute), `offline_rented` (the machine was offline for 600 s), `verdict` (a hardware or driver problem marked `stop` above), `admin` (stopped by the platform), `delivery_failed` (see `fail_code`). **`fail_code`:** set by the platform: `pull_timeout`, `prepare_timeout`, `start_timeout`, `oc_failed`, `gpu_busy` (the host was using the machine; it is unlisted), `agent_outdated`, `renter_cancel`; reported by the machine: `pull_failed`, `disk_insufficient`, `image_too_large`, `image_no_shell`, `start_failed`, `gpu_mismatch`, `network_isolation_failed`, `rent_job_failed`. Other lowercase codes may appear. **Command `state` / `note`** (timeline): `pending` (not started yet), `running` (started, no result yet), `ok`, `error`. `note` on finished commands: `rebooted` (reboot done), `powered_off`, `expired` (never started within 600 s), `timeout` (started, no result in time), `interrupted` (the machine rebooted while it ran), `not_delivered` (never sent, safe to send again), `rebooted_no_gpu` / `rebooted_gpu_unreadable` (driver install done but the machine has no NVIDIA GPU / no GPU can be read, so the version was not checked); null otherwise, also for an `error` reported by the machine (the reason is in `latest_title`). **Compute task `state`** (`states[].state`): `running` (the program runs), `preparing` (downloading or starting), `retrying` (the program exited or preparing failed; it is restarted with back-off up to 60 s), `gpu_missing` (its GPUs are gone), `paused`, `held` (held on the machine itself, for example while GPUs initialize after boot or a driver is installed; see `reason`), `overheat` (stopped by fan control), `yielded` (the machine is rented, host tasks give way), `unsupported` (the machine lacks a tool, `missing`), `stopped` (removed). **A task runs when `state` is `running` and its `revision` equals the task's `revision`.** `started_at` is when the current run started; `exits_1h` counts exits in the last hour. ## Retries and batch operations | Kind | Endpoints | On timeout or 5xx | |---|---|---| | Safe to repeat (same body, same result) | Prices, applying price templates, changing templates and tags (`PUT` / `PATCH`), listing, precheck, tags, `PUT .../tasks`, `tasks/apply` (`replace`, `clear`; `add` skips tasks already there), task pause / resume, `oc/manual-only`, rename, wallets / variables `PUT`, `PUT .../startup`, stop an instance, rent with the same `Idempotency-Key` | Send it again | | Repeat with care | `PUT .../oc`, `oc-template`, `oc/reapply`, `PUT .../autofan`, `autofan-template` | Each call raises `revision` and makes the machine apply the values again (same values, no harm). Read `oc.revision` first | | Do not repeat blindly | `commands/reboot`, `commands/upgrade`, `commands/driver_install`, `commands/task_restart`, `commands/task_logs`, `tasks/restart`, `tasks/redownload`, `startup/restart`, `rebuild`, renter task `restart` / `reinstall`, password changes, creating templates, wallets / variables or tags | Read the result first: commands in the timeline (your `cmd_id`, or the newest item of that `type` with `issued_by_mine`), the rest in the matching list. 503 `command_push_failed` is the exception: nothing was sent, send again | - 429 `rate_limited`: wait `Retry-After` seconds (the start of the next minute for the per-minute budget, 1 s when the shared pool is busy), plus a random 0-1000 ms so parallel workers do not retry together. - 503 `device_index_rebuilding` or `request_timeout` on a read: back off 2, 4, 8, 16 s and give up after 5 tries. 503 `request_timeout` on a write: read the state first (see above). - Rent with a new `Idempotency-Key` for each order and reuse it when you retry that order: the key is kept for good, the same key with the same body returns the same order, a different body 422 `idempotency_mismatch`. - Multi-machine writes with an API key: split `machine_ids` by `group_id` (from `GET /api/v1/host/machines`) and send one request per group; otherwise the request fails with 400 `cross_group`. Per request at most: 500 machines for `price`, `price-template`, `listing`, `listing/precheck`, `tasks/apply`, `tasks/restart`, `tasks/redownload`, `tasks/pause`, `tasks/resume`, `oc-template`, `oc/reapply`, `autofan-template`; 1000 for `tags`; 100 (after removing duplicates) for `commands/reboot` and `commands/upgrade`; exactly 1 for `commands/task_restart`, `commands/task_logs` and `commands/driver_install`. Results are per machine: always check `results[]` (or `rejected[]`), a 200 does not mean every machine was done. - Only one big command (reboot, shutdown, Agent upgrade, network change, driver install) can be open per machine; another is rejected with `command_pending` until the first one ends. Compute-task commands are not blocked by it and do not block it. ## Business rules - **Prices and commission.** The price a host sets (`price_per_gpu_hr` / `price_per_cpu_hr`) is what the host earns. The market and renters see that price plus the platform commission: unit price × (1 + commission), rounded up to 3 decimal places, times the GPU (or CPU socket) count. The commission rate is set by the platform. Both prices are fixed when an order is placed; later price changes apply to new rentals only. - **Billing.** Rent is charged every minute from when the image is ready (`billing_from`) until you stop, only for time the machine is online, rounded up to the cent on the running total. Ordering needs at least one hour of rent in your balance. There is no grace period: when your balance cannot pay the next minute, all your instances are stopped with `end_reason: balance_exhausted` (you are notified when less than 120 and 30 minutes are left). - **No rental duration.** An order has no duration; an instance runs until you stop it (`POST .../stop`), your balance runs out, or the platform stops it. Stop it from your code when you are done. - **Deposits.** The API cannot create deposit addresses or move money; deposit in the console. Use `GET /api/v1/account/deposits/pending` to see an incoming deposit and `GET /api/v1/account/deposits` / `GET /api/v1/renter/account` to see it credited. Withdrawals and balance transfers are not available to API keys. - **Agent version.** The current stable Agent version is the plain text at `https://down.suanzu.ai/VERSION` (public, no key), always `MAJOR.MINOR.PATCH`. `commands/upgrade` installs exactly that version, whatever the machine runs now: a newer release or beta is replaced by it (`1.5.8-beta.2` becomes `1.5.7`), and a machine already on it gets it installed again. So send it only to the machines you want on the stable version. Compare as semantic versions: `MAJOR`, `MINOR` and `PATCH` one by one as numbers; a `-beta.N` version is below the same version without it and above the release before it (`1.5.7` < `1.5.8-beta.2` < `1.5.8`). `agent_version` null = not reported yet. - **Host service fees.** Your host account is overdue when `earn_balance` is below 0. Service-fee credit and gift credit pay service fees first, and new deposits, transfers received and gifts are applied to the debt automatically. While overdue, `GET /api/v1/host/account` has `overdue_since` and `freeze_at` (= `overdue_since` + 3 days). If it is still overdue then, the account is restricted (`restricted: true`): compute task, overclocking and wallet / variable changes fail with `account_overdue_restricted` until you top up. - **Rented machines.** While a machine has a rental (`status: rented`, delivery and stopping included): `commands/reboot`, `commands/upgrade`, `commands/driver_install`, `commands/task_restart`, `commands/task_logs`, `tasks/restart`, `tasks/redownload`, opening remote access, `oc/reapply` and resuming host tasks (one task or `tasks/resume`) are rejected with `rented`; overclocking, overclocking templates, auto-fan and `oc/manual-only` are saved and applied after the rental ends (`deferred: rented`); host compute tasks can be changed but give way to the renter (`state: yielded`); prices can be changed (the running rental keeps its price); unlisting is allowed and does not stop the rental. ## Compute task templates A template is `custom` (your own start command) or `hive` (a HiveOS custom miner package). Host tasks run on the machine; renter tasks run inside the instance. - **Custom tasks.** `custom.start_command` (required, at most 16 KiB) runs with `bash -c`. With `custom.package_url` the file is downloaded first: `.tar.gz`, `.tgz`, `.tar.xz` and `.tar` are unpacked into the working directory when `extract` is true (the default); other files (`.zip` included) are saved there unchanged and made executable. When the program exits it is started again after 3 to 60 s; the wait resets once it has run for 300 s. - **Variables** (`vars`, custom tasks only). Each item becomes an environment variable of the program; the value is passed as it is (no shell expansion). At most 64. `key` matches `^[A-Za-z_][A-Za-z0-9_]*$`, does not start with `SUANZU_` and is none of `CUDA_DEVICE_ORDER`, `CUDA_VISIBLE_DEVICES`, `NVIDIA_VISIBLE_DEVICES`, `BASH_ENV`, `ENV`, `PATH`. `value` is required (it may be empty), at most 4 KiB. A HiveOS template with `vars` fails with 400 `hive_vars_unsupported`. - **Values from your wallets / variables.** Set `ref` to the `id` of one of your wallets / variables and send `value: ""`: the value is always replaced with the current value of that wallet / variable, and changing that value restarts the tasks that use it. An `id` that is not yours fails with 400 `wallet_var_unavailable`. For HiveOS, `wallet_ref` does the same for `hive.wallet` (send `wallet: ""`). - **Set for the program.** `SUANZU_TASK_ID`, `SUANZU_TASK_DIR`, `SUANZU_WORKER_NAME`, `SUANZU_GPU_BUSIDS` (the task's GPU bus IDs, comma-separated) and `CUDA_DEVICE_ORDER=PCI_BUS_ID`. When the task uses only some GPUs, `CUDA_VISIBLE_DEVICES` and `NVIDIA_VISIBLE_DEVICES` hold their UUIDs. CPU tasks (`gpus: []`) get `SUANZU_TASK_CPU=1` and no GPU. - **HiveOS fields.** `install_url` must be an http(s) link to a `.tar.gz` / `.tgz` package with `/h-manifest.conf` and `/h-run.sh`. Leave `miner` empty to take it from the file name: drop the extension, then keep what comes before the last `-` (`pearlfortune-1.2.3.tar.gz` gives `pearlfortune`). `coin` and `algo` reach the package as `DIGITAL_CASH` and `CUSTOM_ALGO`. In `template`, `url`, `pass` and `user_config` the macros `%WAL%` (the wallet), `%WORKER_NAME%`, `%URL%`, `%URL_HOST%` and `%URL_PORT%` (from the first address in `url`) are replaced; any other `%...%` is left as it is. `%WAL%` with an empty wallet and no `wallet_ref` fails with 400 `hive_wallet_required`. - **Follow the latest version.** When the download link (`hive.install_url` / `custom.package_url`) is a GitHub release file with a version tag, set `follow` to `latest` (stable releases) or `latest_beta` (pre-releases too). When a newer release comes out, SuanZu switches the template's download link to it (with download acceleration on, once the cache is ready, at the latest 1 hour after the release) and sends the `tpl.auto_updated` notification. Templates return the version in use as `current_tag`. - **Is it running?** A task runs when its `states[]` item has `state: running` and the same `revision` as the task. Only HiveOS tasks report stats (`TaskStats`, from the package's `h-stats.sh`). ## Endpoints Format: METHOD path — what it does. Scope. Rate limit class. ### Market Machines that are listed for rent. Public; no key needed. - GET /api/v1/market/machines — List machines available for rent. Public, key optional. Rate class `read`. - GET /api/v1/market/machines/{machine_id} — Get one machine available for rent. Public, key optional. Rate class `read`. - GET /api/v1/market/facets — Get filter values for the market list. Public, key optional. Rate class `read`. ### Renter Rent machines and manage your instances, balance and deposits. Needs `renter:read` or `renter:write`. - GET /api/v1/renter/images — List preset images. Scope `renter:read`. Rate class `read`. - GET /api/v1/renter/leases — List your instances. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/leases — Rent a machine. Scope `renter:write`. Rate class `order`. - GET /api/v1/renter/leases/{lease_id}/settles — List the charges of one instance. Scope `renter:read`. Rate class `read_pg`. - GET /api/v1/renter/leases/{lease_id}/container-log — Read the container log. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/leases/{lease_id}/container-log — Ask the instance for a fresh container log. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/leases/{lease_id}/access — Get SSH connection details for an instance. Scope `renter:write`. Rate class `remote`. - POST /api/v1/renter/leases/{lease_id}/stop — Stop an instance. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/access/password — Change the SSH password of an instance. Scope `renter:write`. Rate class `write`. - PUT /api/v1/renter/leases/{lease_id}/startup — Change the startup command. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/startup/restart — Restart the container. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/rebuild — Rebuild the instance. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/account — Get your rent balance. Scope `renter:read`. Rate class `read_pg`. - GET /api/v1/renter/ledger — List your renter balance transactions. Scope `renter:read`. Rate class `read_pg`. - GET /api/v1/renter/task-templates — List your compute task templates. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/task-templates — Create a compute task template. Scope `renter:write`. Rate class `write`. - PUT /api/v1/renter/task-templates/{template_id} — Replace a compute task template. Scope `renter:write`. Rate class `write`. - DELETE /api/v1/renter/task-templates/{template_id} — Delete a compute task template. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/leases/{lease_id}/tasks — Get the compute tasks of an instance. Scope `renter:read`. Rate class `read_pg`. - PUT /api/v1/renter/leases/{lease_id}/tasks — Set the compute tasks of an instance. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/tasks — Change compute tasks on several instances. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/pause — Pause a compute task. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/resume — Resume a compute task. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/restart — Restart a compute task. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/reinstall — Download and install a compute task's package again. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/log — Read a compute task's log. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/leases/{lease_id}/tasks/{binding_id}/log — Ask the instance for a fresh task log. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/tags — List your instance tags. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/tags — Create an instance tag. Scope `renter:write`. Rate class `write`. - PATCH /api/v1/renter/tags/{tag_id} — Rename or recolor an instance tag. Scope `renter:write`. Rate class `write`. - DELETE /api/v1/renter/tags/{tag_id} — Delete an instance tag. Scope `renter:write`. Rate class `write`. - POST /api/v1/renter/leases/tags — Add or remove tags on several instances. Scope `renter:write`. Rate class `write`. - GET /api/v1/renter/wallet-vars — List your wallets and variables. Scope `renter:read`. Rate class `read_pg`. - POST /api/v1/renter/wallet-vars — Save a wallet or variable. Scope `renter:write`. Rate class `write`. - PUT /api/v1/renter/wallet-vars/{wallet_var_id} — Change a wallet or variable. Scope `renter:write`. Rate class `write`. - DELETE /api/v1/renter/wallet-vars/{wallet_var_id} — Delete a wallet or variable. Scope `renter:write`. Rate class `write`. - GET /api/v1/account/deposits — List your credited deposits. Scope `renter:read` or `host:read`. Rate class `read_pg`. - GET /api/v1/account/deposits/pending — List deposits seen on chain but not credited yet. Scope `renter:read` or `host:read`. Rate class `read_pg`. ### Host Manage the machines you rent out. Needs `host:read`, `host:write` or `host:exec`. - GET /api/v1/host/machines — List your machines. Scope `host:read`. Rate class `read`. - GET /api/v1/host/machines/summary — Get machine totals, overall and per group. Scope `host:read`. Rate class `read`. - GET /api/v1/host/machines/{machine_id} — Get one of your machines. Scope `host:read`. Rate class `read`. - PATCH /api/v1/host/machines/{machine_id} — Rename a machine. Scope `host:write`. Rate class `write`. - GET /api/v1/host/machines/{machine_id}/tasks — List the compute tasks of a machine. Scope `host:read`. Rate class `read`. - PUT /api/v1/host/machines/{machine_id}/tasks — Replace the compute tasks of a machine. Scope `host:write`. Rate class `write`. - GET /api/v1/host/machines/{machine_id}/checks — Check a machine against the listing rules. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/leases — List the rental history of a machine. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/timeline — List the commands and messages of a machine. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/messages — List the messages of one command. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/history — Get history charts of a machine. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/faults — List the fault history of a machine. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/remote — Get remote access state and connection details. Scope `host:exec`. Rate class `remote`. - POST /api/v1/host/machines/{machine_id}/remote — Open remote access to a machine. Scope `host:exec`. Rate class `write`. - DELETE /api/v1/host/machines/{machine_id}/remote — Close remote access to a machine. Scope `host:exec`. Rate class `write`. - GET /api/v1/host/device-groups — List your device groups. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/memberships — List groups shared with you. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/account — Get your host balances. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/ledger — List your host balance transactions. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/rent-payouts/{ledger_id} — Get the leases behind a rent payout. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/earnings — Get your rent earnings for a period. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/earnings/leases — List the leases that earned in a period. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/billing — Get this month's service fee summary. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/billing/days/{day} — Get the service fee bill of one day. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/machines/price — Set or clear rent prices. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/listing — List or unlist machines on the market. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/listing/precheck — Check whether machines can be listed. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/machines/{machine_id}/tasks/{binding_id}/pause — Pause a compute task. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/{machine_id}/tasks/{binding_id}/resume — Resume a paused compute task. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/commands/task_restart — Restart a compute task. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/commands/task_logs — Fetch the log of a compute task. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tasks/restart — Restart all compute tasks of machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tasks/redownload — Reinstall compute tasks of machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tasks/pause — Pause all compute tasks of machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tasks/resume — Resume all compute tasks of machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/commands/reboot — Reboot machines. Scope `host:exec`. Rate class `write`. - POST /api/v1/host/machines/commands/upgrade — Upgrade the Agent on machines. Scope `host:exec`. Rate class `write`. - GET /api/v1/host/machines/{machine_id}/driver-options — List the NVIDIA driver versions a machine can install. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/machines/commands/driver_install — Install or change the NVIDIA driver on a machine. Scope `host:exec`. Rate class `write`. - GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress — Get the progress and log of a long command. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/machines/{machine_id}/messages — List the messages of a machine. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/gpus — List all GPUs of your machines. Scope `host:read`. Rate class `read`. - GET /api/v1/host/tags — List your device tags. Scope `host:read`. Rate class `read`. - POST /api/v1/host/tags — Create a device tag. Scope `host:write`. Rate class `write`. - PATCH /api/v1/host/tags/{tag_id} — Rename or recolor a device tag. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/tags/{tag_id} — Delete a device tag. Scope `host:write`. Rate class `write`. - GET /api/v1/host/price-templates — List price templates. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/price-templates — Create a price template. Scope `host:write`. Rate class `write`. - PATCH /api/v1/host/price-templates/{price_template_id} — Change a price template. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/price-templates/{price_template_id} — Delete a price template. Scope `host:write`. Rate class `write`. - GET /api/v1/host/task-templates — List compute task templates. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/task-templates — Create a compute task template. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/task-templates/{task_template_id} — Change a compute task template. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/task-templates/{task_template_id} — Delete a compute task template. Scope `host:write`. Rate class `write`. - GET /api/v1/host/task-templates/{task_template_id}/usage — List machines that use a compute task template. Scope `host:read`. Rate class `read_pg`. - GET /api/v1/host/images — List common images for compute tasks. Scope `host:read`. Rate class `read`. - GET /api/v1/host/quote-coins — List coins with market quotes. Scope `host:read`. Rate class `read`. - GET /api/v1/host/oc-templates — List overclocking templates. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/oc-templates — Create an overclocking template. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/oc-templates/{oc_template_id} — Change an overclocking template. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/oc-templates/{oc_template_id} — Delete an overclocking template. Scope `host:write`. Rate class `write`. - GET /api/v1/host/fan-templates — List auto-fan templates. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/fan-templates — Create an auto-fan template. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/fan-templates/{fan_template_id} — Change an auto-fan template. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/fan-templates/{fan_template_id} — Delete an auto-fan template. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/price-template — Apply a price template to machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tags — Add or remove tags on machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/tasks/apply — Add, replace or clear compute tasks on machines. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/machines/{machine_id}/oc — Set overclocking values on one machine. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/{machine_id}/oc/reapply — Apply the saved overclocking values again. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/machines/{machine_id}/oc/manual-only — Turn manual-only overclocking on or off. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/oc/reapply — Apply the saved overclocking values again on several machines. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/oc-template — Apply an overclocking template to machines, or restore defaults. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/machines/{machine_id}/autofan — Set auto-fan on one machine. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/autofan-template — Apply an auto-fan template to machines, or turn auto-fan off. Scope `host:write`. Rate class `write`. - POST /api/v1/host/machines/{machine_id}/remote/password — Change the remote access password. Scope `host:exec`. Rate class `write`. - GET /api/v1/host/wallet-vars — List wallets and variables. Scope `host:read`. Rate class `read_pg`. - POST /api/v1/host/wallet-vars — Create a wallet or variable. Scope `host:write`. Rate class `write`. - PUT /api/v1/host/wallet-vars/{wallet_var_id} — Change a wallet or variable. Scope `host:write`. Rate class `write`. - DELETE /api/v1/host/wallet-vars/{wallet_var_id} — Delete a wallet or variable. Scope `host:write`. Rate class `write`. ## Error codes Every error body is `{"ok": false, "code": "...", "error": "..."}`. Branch on `code`. Batch endpoints also return a `code` per machine in `results[]`; see each endpoint in the OpenAPI spec. - 400: `accel_download_github_only`, `alias_invalid`, `autofan_param_invalid`, `bad_request`, `bad_target`, `container_image_invalid`, `cross_group`, `driver_param_invalid`, `driver_version_invalid`, `expected_gpu_count_invalid`, `follow_github_only`, `forward_dns_error`, `forward_forbidden_address`, `forward_not_in_task`, `hive_vars_unsupported`, `hive_wallet_required`, `idempotency_key_required`, `image_cuda_too_old`, `image_gpu_mismatch`, `image_invalid`, `image_registry_unsupported`, `image_unchanged`, `invalid_scope`, `oc_no_gpu`, `oc_param_out_of_range`, `oc_template_unavailable`, `package_url_github_query`, `package_url_private_host`, `startup_cmd_invalid`, `tag_color_invalid`, `tag_name_invalid`, `task_config_too_large`, `task_gpus_invalid`, `task_limit_reached`, `task_template_duplicate`, `template_invalid`, `wallet_var_invalid`, `wallet_var_unavailable` - 401: `api_key_expired`, `api_key_invalid`, `unauthorized` - 403: `account_overdue_restricted`, `advanced_not_enabled`, `api_key_ip_denied`, `api_key_route_not_allowed`, `api_key_scope_denied`, `group_forbidden`, `own_machine` - 404: `bill_day_not_found`, `fan_template_not_found`, `group_not_found`, `lease_not_found`, `machine_not_found`, `oc_template_not_found`, `payout_not_found`, `tag_not_found`, `task_not_found`, `template_not_found`, `wallet_var_not_found` - 409: `agent_outdated`, `agent_unsupported`, `balance_too_low`, `command_pending`, `driver_arch_unsupported`, `driver_env_unsupported`, `driver_os_unknown`, `driver_os_unsupported`, `forward_changed`, `group_forbidden`, `lease_not_running`, `listed`, `machine_configuration_changed`, `machine_not_rentable`, `machine_rented`, `oc_not_set`, `oc_task_managed`, `oc_template_in_use`, `offline`, `price_changed`, `rebuild_in_progress`, `remote_busy`, `remote_not_open`, `remote_not_ready`, `remote_too_many`, `rented`, `tag_lease_limit`, `tag_limit`, `tag_name_taken`, `task_no_package`, `task_paused`, `task_template_in_use`, `wallet_var_in_use`, `wallet_var_name_taken` - 422: `idempotency_mismatch` - 429: `container_log_rate_limited`, `rate_limited` - 503: `command_push_failed`, `device_index_rebuilding`, `forward_capacity_full`, `forward_unavailable`, `forward_unconfigured`, `history_unavailable`, `remote_relay_failed`, `remote_relay_unavailable`, `remote_unconfigured`, `request_timeout` ## Common flows ### Rent a machine, connect to it, stop it 1. GET /api/v1/market/facets — Optional. Get the GPU and CPU model names you can filter by. 2. GET /api/v1/market/machines — Find a machine. Keep its `machine_id` and `device_no`. 3. GET /api/v1/renter/images — Pick a preset `image_id`, or use your own public image. 4. POST /api/v1/renter/leases — Rent it with a new `Idempotency-Key`. Your balance must cover at least one hour of rent. Keep the returned `id`. 5. GET /api/v1/renter/leases — Poll until the instance's `phase` is `running`. 6. GET /api/v1/renter/leases/{lease_id}/access — Get the SSH command and password. Treat them as a secret. 7. POST /api/v1/renter/leases/{lease_id}/stop — Stop the instance when you are done. Rent is settled up to now. ### Price your machines and list them on the market 1. GET /api/v1/host/machines — Find the `machine_id` of your machines (use `group` to stay in one device group). 2. POST /api/v1/host/machines/price — Set `price_per_gpu_hr` (GPU machines) or `price_per_cpu_hr` (CPU-only machines). 3. POST /api/v1/host/machines/listing/precheck — See which machines can be listed; `reasons` lists the problems. 4. GET /api/v1/host/machines/{machine_id}/checks — Optional. Per-rule details for a machine that failed the check. 5. POST /api/v1/host/machines/listing — Send `listed: true` to put the machines on the market. ### Change the startup command, or run it again 1. PUT /api/v1/renter/leases/{lease_id}/startup — Save the new command. Saving the same command again does nothing, so you can safely retry this call. 2. POST /api/v1/renter/leases/{lease_id}/startup/restart — To run the same command again, restart the container instead. Each call restarts it once, so do not retry automatically. 3. GET /api/v1/renter/leases — Poll until `startup.rev` equals the returned `startup_rev` and `startup.state` is no longer `pending`. ### Set overclocking on one machine 1. GET /api/v1/host/machines/{machine_id} — Read `gpus[].busid` and the current `oc` (`revision`, `cards`). 2. PUT /api/v1/host/machines/{machine_id}/oc — Send all 6 values for each GPU to change. On 409 `oc_task_managed`, send again with `manual_only: true`. 3. GET /api/v1/host/machines/{machine_id} — Poll until `oc.applied_revision` equals the returned `revision`; check `oc.rejected` and `oc.result` for failures. ### Upgrade the Agent and track it 1. GET /api/v1/host/machines — Find the machines whose `agent_version` is lower than the stable version at `https://down.suanzu.ai/VERSION` (see Agent version under Business rules; the command installs the stable version whatever the machine runs, so a newer release or beta would be moved back to it). Split the `machine_id` values by `group_id`, at most 100 per request. 2. POST /api/v1/host/machines/commands/upgrade — Send one request per group. Keep `issued[].cmd_id`; `rejected[].reason` lists the machines that got no command (for example `rented`, `command_pending`). 3. GET /api/v1/host/machines/{machine_id}/timeline — Poll every 15 s until the item with your `cmd_id` has `state` `ok` or `error`. With `error`, the reason is in `latest_title` and `note` (`expired`, `timeout`, `interrupted`). 4. GET /api/v1/host/machines/{machine_id}/messages — Optional. For a failed upgrade, read the install log in `payload_gz`. 5. GET /api/v1/host/machines — After `ok`, `agent_version` shows the new version from the next heartbeat on. ### Reboot machines and confirm they are back 1. GET /api/v1/host/machines — Find the machines, for example `reason=gpu_dropped`. Split them by `group_id`, at most 100 per request. 2. POST /api/v1/host/machines/commands/reboot — Keep `issued[].cmd_id`. Rented machines are rejected with `rented` (unlisting with `POST /api/v1/host/machines/listing` does not end a rental). 3. GET /api/v1/host/machines/{machine_id}/timeline — Poll every 15 s until the item with your `cmd_id` has `state: ok` and `note: rebooted` (the machine is back online and has booted again). `note: timeout` = not back within 600 s. 4. GET /api/v1/host/machines/{machine_id} — Check that the problem is gone, for example `gpus[].dropped` and `status_reasons`. ### Watch for offline machines 1. GET /api/v1/host/machines/summary — Every 5 minutes, read `offline` in `all` and in each of `groups`. Stop here when it is 0. 2. GET /api/v1/host/machines — List them with `connectivity=offline` and `per_page=1000`, following `page` up to `total_pages`. `last_heartbeat_at` says since when; a machine counts as offline 120 s after its last heartbeat. Rented machines that stay offline for 600 s lose their rental. 3. GET /api/v1/host/machines/{machine_id}/timeline — Optional. Read the newest messages of a machine before it went offline. ### List machines across several groups 1. GET /api/v1/host/device-groups — Get the `id` of every group the key can use (yours and those shared with you, `shared: true`). 2. GET /api/v1/host/machines — Without `group` you get every machine the key can see in one list. With `group`, one request per group; follow `page` up to `total_pages` (`per_page` at most 1000). 3. GET /api/v1/host/machines/summary — Optional. Totals per group in one call. ### Run a renter task that uses a saved wallet 1. POST /api/v1/renter/wallet-vars — Save the wallet address. Keep `wallet_var.id`. 2. POST /api/v1/renter/task-templates — Custom task: add a `vars` item with `ref` set to that `id` and `value: ""`. HiveOS task: set `wallet_ref` to that `id` and `hive.wallet` to `""`. Keep `template.id`. 3. PUT /api/v1/renter/leases/{lease_id}/tasks — Put the template on a `running` instance. 4. GET /api/v1/renter/leases/{lease_id}/tasks — Poll every 15 s until `states[]` has your `binding_id` with `state: running` and the same `revision`. HiveOS tasks then report `stats` (hash rate in `params.khs`). 5. PUT /api/v1/renter/wallet-vars/{wallet_var_id} — Optional. Changing the value restarts every task that uses it. ### Fetch the log of a compute task 1. GET /api/v1/host/machines/{machine_id}/tasks — Find the task's `binding_id`. 2. POST /api/v1/host/machines/commands/task_logs — Send the command for that one machine and task. Keep `issued[0].cmd_id`; a `rejected[].reason` (for example `rented`, `task_not_found`) means no command was sent. 3. GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/messages — Poll every 10 s until there is an `ok` or `error` message. The log is the `payload_gz` of the `ok` message (gzip + base64, last 500 lines). ### Install or change the NVIDIA driver on one machine 1. POST /api/v1/host/machines/listing — If the machine is listed, send `listed: false` first (a rented machine cannot install a driver). 2. GET /api/v1/host/machines/{machine_id}/driver-options — Pick a `version` from `options`; a 409 `code` says why the machine cannot install now. Use `cuda: false` when `cuda_block` is not null. 3. POST /api/v1/host/machines/commands/driver_install — Send it for that one machine. Keep `issued[0].cmd_id`; a `rejected[].reason` means no command was sent. Do not retry blindly. 4. GET /api/v1/host/machines/{machine_id}/commands/{cmd_id}/progress — Optional. Every 5 s while it runs, read the stage, download percent and the new log with `offset` = `next_offset`. 5. GET /api/v1/host/machines/{machine_id}/timeline — Poll every 15 s until your `cmd_id` has `state` `ok` (`note: rebooted`, the machine is back with the new driver) or `error` (the code is in brackets in `latest_title`).