# Using the API

Base URLs, the auth header, API keys, idempotency, error shape and pagination.

Source: https://slashinfra.com/docs/reference/api
Last modified: 2026-11-30T16:36:19.000Z

Two hosts serve the API. The control API at `https://api.slashinfra.com` creates, lists and deletes VMs and API keys. Each VM has its own API at `https://<id>.slashinfra.dev`, which runs programs and reads and writes files. A preview of a port uses `https://<port>-<id>.slashinfra.dev`.

Send your key with every request:

```http
Authorization: Bearer si_...
```

On a preview host, send the key in `X-Si-Authorization`, because the app keeps `Authorization` for itself. A key starts with `si_`. `si login` saves a device key for the CLI. The dashboard creates an organization key and shows its secret once. [`DELETE /keys/current`](https://slashinfra.com/docs/api-reference/control/keys#deleteKeysCurrent) or `si auth logout` revokes a device key. Delete an organization key on the [API keys](https://app.slashinfra.com/keys) page. A revoked key stops working within 30 seconds.

`GET`, `PUT` and `DELETE` are idempotent. `POST` runs the program again, so retry a `POST` only when a second run is safe.

Control API errors are JSON with `error` and `code`. The VM API answers text unless you send `Accept: application/json`. Branch on the `code`. See [Errors](https://slashinfra.com/docs/reference/errors).

List endpoints return one page at a time. Pass `limit`, then send the `next_cursor` of the previous reply as `cursor`. [`GET /svms`](https://slashinfra.com/docs/api-reference/control/svms#getSvms) takes `limit` from 1 to 200, 100 by default. The last page returns `next_cursor` as `null`. [`GET /audit`](https://slashinfra.com/docs/api-reference/control/audit#getAudit) also takes `limit` and `cursor`, with 50 by default.

Endpoint reference:

- [Control API](https://slashinfra.com/docs/api-reference/control) 
- [VM API](https://slashinfra.com/docs/api-reference/svm)
