# API reference

The public API manages the servers, templates, SSH keys and billing of one organization with an [API key](/docs/api-keys). It is meant for server-to-server use: scripts, CI and your own back end. Do not call it from a browser page, and do not ship a key in a mobile or web app. Cross-origin browser requests are not supported.

Base URL: the address you open the console at, followed by `/api/v1`. The examples use `https://YOUR-DOMAIN`.

Clients built on this API are open source: see [Open-source tools](/docs/open-source-tools).

## OpenAPI description

A machine-readable [OpenAPI 3.1 document](/api/v1/openapi.json) of every endpoint, with request schemas, is served at `/api/v1/openapi.json`. It needs no key. Use it to generate a client or to import the API into a tool such as Postman. Each operation lists the key scope it needs in `x-required-scope`.

## Authentication

Send the key in the `Authorization` header. Cookies are never used.

```bash
curl https://YOUR-DOMAIN/api/v1/me \
  -H "Authorization: Bearer $APIDLY_API_KEY"
```

A missing, malformed, unknown, revoked or expired key returns `401 unauthenticated`. A suspended organization returns `403 org_suspended` for every call.

### Scopes

Every key has a scope that caps what it may do (see [API keys](/docs/api-keys#permissions)). A call above the key's scope returns `403 insufficient_scope`.

| Scope | Allows |
| --- | --- |
| `read` | `GET` endpoints for servers, plans, templates, usage and billing. Never the lists of API keys, team invitations, roles, webhooks or secrets: secret names need `servers`, the others `full`. |
| `servers` | Reads, plus request, start, stop, restart, rename and delete servers, cancel waiting requests, list secret names, save and delete plan filters, watch and unwatch plans, and report a shared template. No billing, no managing endpoints, no changes to SSH keys or templates. |
| `full` | Everything the key creator's role allows. |

Every call is checked against the key's effective permissions: the creator's current permissions, within the scope's ceiling, within the key's own optional permission list (`permissions` when the key was created; a subset of the organization's permission names such as `servers.view`). When only the scope stands in the way, the answer is `403 insufficient_scope` and names the scope the call needs; when the creator's role or the key's own list does, it is `403 forbidden`.

A server that was launched with "Allow this server to stop itself" gets a per-server token in `GPU_SERVER_KEY` (`apc_srv_...`). It can only call `GET /api/v1/me` and `POST /api/v1/servers/{id}/stop` or `DELETE /api/v1/servers/{id}` for its own server, and stops working when the server is destroyed. Anything else answers `403`.

Inside its scope a key acts with the role of the person who created it. Endpoints marked "owner or admin" below also need a key created by an owner or admin, otherwise `403 forbidden`.

## Conventions

- Requests with a body are JSON with `Content-Type: application/json`. The body limit is 1 MB.
- Every response is JSON and carries an `x-request-id` header. Quote it when you contact support.
- Timestamps are ISO 8601 in UTC.
- Money is exact. Each amount named `...Micros` is a string of integer millionths of a US dollar (`"940000"` is 0.94 USD). Next to it is `...Usd`, the same amount as a decimal string with six places (`"0.940000"`). Never use floating point for money. Amounts in cents (`amountCents`) are integers.
- Server ids start with `ins_`, requests with `dep_`, plans with `pln_`, templates with `tpl_`, SSH keys with `ssh_`.

### Pagination

Every list that can grow takes `limit` (1 to 200, default 50) and `cursor`, and returns `nextCursor`. Pass `nextCursor` as `cursor` to get the next page; it is `null` on the last page. Cursors are opaque; do not build or parse them. A cursor that was not issued by the API answers `400 invalid_cursor`. Repeat the same filters on every page.

```bash
curl "https://YOUR-DOMAIN/api/v1/servers?limit=2" -H "Authorization: Bearer $APIDLY_API_KEY"
# { "servers": [ ... ], "nextCursor": "eyJ0Ijox..." }
curl "https://YOUR-DOMAIN/api/v1/servers?limit=2&cursor=eyJ0Ijox..." -H "Authorization: Bearer $APIDLY_API_KEY"
```

Not every list pages. Small lists that are capped by an organization limit come back whole in one answer, without `cursor` or `nextCursor`: team roles, secrets, webhooks and their events, server groups, serverless endpoints, endpoint groups and workers, API keys, the SSH keys of one server, template revisions, usage and metrics series, the price history of a plan, notification preferences and the regions of volume offers. A few feeds take only `limit` (the newest rows, no cursor): the jobs and requests of an endpoint, the deliveries of a webhook and notifications. The [OpenAPI document](/api/v1/openapi.json) lists `limit` and `cursor` on exactly the operations that page.

### Idempotency

These creates accept an `Idempotency-Key` header: `POST /servers`, `POST /topups`, `POST /team/invitations`, `POST /templates`, `POST /endpoints`, `POST /volumes` and `POST /transfers`.
The key is 1 to 128 printable characters without spaces, for example a UUID. A retry with the same key and the same body within 24 hours returns the first answer (with the header `idempotent-replayed: true`) and does nothing again, so a timeout never creates two servers or two checkouts. The same key with a different body answers `422 idempotency_key_reused`. While the first request is still running a retry answers `409 idempotency_in_progress` with `retry-after`. Only successful answers are stored: after a failure (for example `402 insufficient_balance`) you can fix the cause and retry with the same key. Other creates, including the ones that return a secret once (an API key, a webhook), do not take the header: after a timeout, list what exists before you repeat the call. A `PATCH`, `PUT` or `DELETE` that sets a state is safe to repeat. The SDKs send a fresh key with `servers.create`, top-ups and invitations unless you pass one; for the other creates above, pass the header yourself.

### Rate limits

Limits are per key and per minute unless a row says otherwise. Reads and writes are counted in separate windows: 120 read requests (`GET`) and 20 write requests (`POST`, `PATCH`, `PUT`, `DELETE`). Some routes have a tighter limit of their own, on top of that:

| Route class | Limit | Counted per |
| --- | --- | --- |
| Reads (`GET`) | 120 per minute | key |
| Writes (`POST`, `PATCH`, `PUT`, `DELETE`) | 20 per minute | key |
| `POST /servers` | 10 per minute | key |
| `POST /topups` | 10 per minute | key |
| Log download, `GET /servers/{id}/logs/download` | 10 per minute | key |
| PDF downloads (invoice receipts, statements) | 12 per minute | organization |
| Invitations, `POST /team/invitations` and resend | 30 per hour each | key |
| Support tickets: create / reply | 10 / 30 per hour | key |
| Webhook test sends / redeliveries | 60 / 120 per hour | organization |
| Endpoint proxy requests | 600 per minute, and 1200 per endpoint | key |
| Failed authentications | 30 per minute | client address |

Every response carries the state of the per-key window the call was counted in:

| Header | Meaning |
| --- | --- |
| `X-RateLimit-Limit` | Calls allowed per minute in this window. |
| `X-RateLimit-Remaining` | Calls left in this window. |
| `X-RateLimit-Reset` | When the window ends, in Unix seconds. |

Over a limit you get `429 rate_limited` and a `retry-after` header with the seconds to wait; every `429` carries it, whichever limit was hit. The SDKs wait for it and retry. The route-specific limits above are answered with the same `429`, but their windows are not shown in the `X-RateLimit-*` headers.

## Errors

Every error, on the public API and on the console API, has the same shape:

```json
{
  "error": {
    "code": "invalid_body",
    "message": "planId is required.",
    "fields": [{ "path": "planId", "message": "planId is required." }],
    "requestId": "req_5c1f0a9d7e3b24a6c801",
    "docsUrl": "https://YOUR-DOMAIN/docs/troubleshooting#api-error-codes"
  }
}
```

`code` is the stable machine code. Branch on it, never on `message`. `message` is one plain-English sentence with what to do next. `fields` appears for validation errors (`invalid_body`, `invalid_query`) and lists each problem with the dotted path of the field (`env.HF_TOKEN`, `sshKeyIds[0]`). `requestId` is the same id as the `x-request-id` header: quote it when you contact support. A body that is not valid JSON answers `400 invalid_json`, so it is never confused with a valid document of the wrong shape (`invalid_body`). The set of codes only grows: a code is never renamed, and `fields`, `requestId` and `docsUrl` were added next to `code` and `message` without changing them. The [full list of codes](/docs/troubleshooting#api-error-codes) is in the troubleshooting guide.

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `invalid_json` | The body is not valid JSON. |
| 400 | `invalid_body`, `invalid_query`, `invalid_params`, `invalid_cursor` | The request did not pass validation. `message` says what is wrong and `fields` lists each field. |
| 400 | `invalid_idempotency_key` | The `Idempotency-Key` header is empty, too long or has spaces. |
| 400 | `invalid_disk`, `invalid_ssh_key`, `ssh_key_required`, `vram_too_small` | The request is valid JSON but breaks a rule of the plan or template. |
| 400 | `key_invalid`, `key_private`, `key_weak` | The SSH key you sent cannot be used. |
| 400 | `amount_too_small`, `amount_too_large` | The top-up amount is outside the allowed range. |
| 401 | `unauthenticated` | Missing, malformed, unknown, revoked or expired key. |
| 402 | `insufficient_balance` | The balance does not cover at least one hour of the new server. |
| 403 | `org_suspended` | The organization is suspended. |
| 403 | `insufficient_scope` | The key's scope is lower than this call needs. |
| 403 | `forbidden` | The key's creator no longer has the role this call needs, or the key was created with fewer permissions than the call needs. |
| 403 | `instance_suspended` | The server is suspended and only support can lift it. |
| 404 | `feature_unavailable` | The feature is switched off for the platform. The same call works once the feature is on. |
| 405 | `method_not_allowed` | The path exists but not for this method; the `Allow` header lists the methods it supports. |
| 404 | `not_found` | The server, request, plan, template or SSH key does not exist in your organization. |
| 409 | `plan_unavailable`, `template_unavailable` | The plan is out of stock or the template is off. |
| 409 | `invalid_state` | The status does not allow this action. |
| 409 | `key_duplicate`, `limit_reached` | The SSH key is already added, or a limit is reached. |
| 409 | `idempotency_in_progress` | A request with this `Idempotency-Key` is still running. |
| 413 | `payload_too_large` | The body is over 1 MB. |
| 422 | `idempotency_key_reused` | The `Idempotency-Key` was used with a different request. |
| 429 | `rate_limited` | Too many requests. See `retry-after`. |
| 429 | `too_many_pending` | Five requests are already waiting for a decision. |
| 500 | `internal` | Something went wrong on our side. Retry, then contact support with the `x-request-id`. |
| 503 | `no_capacity` | No machine is available right now. |

## Account

### GET /api/v1/me

The organization, the key and the wallet. Scope `read`.

```json
{
  "org": { "id": "org_...", "name": "Acme", "slug": "acme", "status": "active" },
  "key": {
    "id": "key_...", "name": "CI pipeline", "prefix": "apc_live_ab12cd34",
    "scope": "servers", "expiresAt": "2027-02-18T09:00:00.000Z",
    "createdAt": "2026-11-20T09:00:00.000Z", "creatorRole": "owner"
  },
  "balance": {
    "balanceMicros": "100000000", "balanceUsd": "100.000000",
    "burnPerHourMicros": "960000", "burnPerHourUsd": "0.960000",
    "runwayHours": 104.1,
    "state": "ok",
    "graceUntil": null,
    "monthToDateMicros": "5200000", "monthToDateUsd": "5.200000"
  }
}
```

`expiresAt` is `null` for a key that does not expire. `state` is `ok`, `low`, `grace` or `suspend`. `runwayHours` is `null` when nothing is running.

### GET /api/v1/team/members

The members of the organization, in the order they joined. Scope `read`. Paginated.

```json
{
  "members": [
    { "userId": "usr_...", "name": "Ada Lovelace", "email": "ada@example.com", "role": "owner", "joinedAt": "2026-11-01T10:00:00.000Z" }
  ],
  "nextCursor": null
}
```

`role` is `owner`, `admin` or `member`. A member with a custom role shows `member` plus `roleId` and `roleName`.

### GET /api/v1/team/invitations

Pending invitations, newest first. Scope `full`, needs `team.manage`. Paginated. Each has `id`, `email`, `role`, `roleKey` (`admin`, `member` or a custom role id), `roleName`, `expiresAt`, `createdAt` and `expired`.

### POST /api/v1/team/invitations

Invites a person. Scope `full`, needs `team.manage`. Honours `Idempotency-Key`. Body `{ "email": "ada@example.com", "role": "member" }`; `role` is `admin`, `member` (default) or a custom role id from `GET /team/roles`. The invitation mail is sent and the link is valid for 7 days. The key's creator cannot grant permissions they lack (`403 role_escalation`). Other refusals: `409 email_in_use`, `already_invited`, `member_limit`. Answers `201` with `{ "invitation": { ..., "mailSent": true } }`.

### DELETE /api/v1/team/invitations/{id}

Revokes a pending invitation. Scope `full`, needs `team.manage`. Returns `{ "deleted": true, "id": "..." }`.

### PATCH /api/v1/team/members/{userId}

Changes a member's role. Scope `full`, needs `team.manage`. Body `{ "role": "admin" }` (`admin`, `member` or a custom role id; nobody becomes owner here). The console's rules apply: no escalation beyond the key creator's own permissions (`403 role_escalation`), the last owner keeps the role (`403 last_owner`). Returns `{ "userId", "role", "roleKey", "roleName" }`.

### DELETE /api/v1/team/members/{userId}

Removes a member. Scope `full`, needs `team.manage`, same rules as the console. A key cannot remove the member who created it (`403 forbidden`); leave from the console. Returns `{ "deleted": true, "userId": "..." }`.

## Catalogue

### GET /api/v1/plans

The plans you can request, with price and availability, recommended first. Scope `read`. Paginated. `availability` is `available`, `limited` or `unavailable`; an `unavailable` plan cannot be requested.

```json
{
  "plans": [
    {
      "id": "pln_...", "slug": "rtx-4090-1x", "name": "RTX 4090",
      "gpuModel": "RTX 4090", "gpuCount": 1, "vramGb": 24, "vcpus": 16, "ramGb": 64, "diskGb": 50,
      "hourlyPriceMicros": "940000", "hourlyPriceUsd": "0.940000",
      "storageHourlyMicrosPerGb": "400", "storageHourlyUsdPerGb": "0.000400",
      "monthlyPriceMicros": null,
      "tier": "standard", "featured": false, "sort": 0,
      "availability": "available",
      "priceSyncedAt": "2026-11-20T08:00:00.000Z"
    }
  ],
  "nextCursor": null
}
```

Filters and sort run on the server, with the same rules as the pricing page. All are optional query parameters:

| Parameter | Meaning |
| --- | --- |
| `gpu` | Text in the GPU model or plan name, case-insensitive (`gpu=h100`). |
| `minVramGb` | Memory of each GPU, GB (a 2-GPU plan of 24 GB cards is 24). |
| `minRamGb`, `minVcpus` | Plans whose machines can offer at least this RAM (GB) or CPU threads. |
| `region` | `na`, `eu`, `ap` or `other`. |
| `hosting` | `datacenter` (commercial data centres only), `independent` or `any` (default). |
| `maxPriceUsd` | Most you will pay per hour, for example `0.75`. Applies to the cheapest option that matches `region` and `hosting`. |
| `minPerfIndex` | Minimum Apidly performance index (one RTX 3090 = 100); plans without an index never pass. |
| `minPerfScore` | Deprecated: the old name of `minPerfIndex` (same scale), read until 2027-05-31. |
| `availability` | `available`, `limited` or `unavailable`. |
| `sort` | `recommended` (default), `price` (cheapest first), `perf`, `perf_per_dollar`, `vram` (most per GPU first). |
| `maxVramGb` | At most this much memory on each GPU, GB. |
| `minGpus`, `maxGpus` | Fewest and most GPUs per server. |
| `minDiskGb` | Plans that come with at least this much disk, GB. |
| `query` | All of these filters as one line of `KEY OP VALUE` terms that must all hold, for example `vram>=24 gpus>=2 price<1.5 sort=perf_per_dollar`. Keys: `gpu`, `gpus`, `vram`, `ram`, `cpu`, `disk`, `price`, `perf`, `region`, `hosting`, `availability`, `sort`. A filter given both ways must agree; a line the API cannot read answers 400 `invalid_query` with the reason. |

Ties break by price, then id, so `cursor` paging is stable under every sort; repeat the same filters and sort on each page. To launch on machines that match, pass the same region, hosting and minimums as `constraints` in `POST /servers`.

Prices are per hour while a server runs. Storage is charged per GB-hour on the whole disk while the server exists. A plan's `diskGb` is the smallest disk you can request.

### GET /api/v1/gpus

One row per GPU model across the plans: the lowest hourly price, the best availability of any plan with that model, and the GPU counts offered. Scope `read`. Paginated.

```json
{
  "gpus": [
    {
      "gpuModel": "RTX 4090", "vramGb": 24,
      "fromHourlyPriceMicros": "940000", "fromHourlyPriceUsd": "0.940000",
      "availability": "limited", "gpuCounts": [1, 2, 4], "plans": 3
    }
  ],
  "nextCursor": null
}
```

Use it to choose a model, then pick the plan with `GET /plans`.

### GET /api/v1/benchmarks

Performance we measured ourselves, one row per GPU class: the median of each test over our runs, each run's value in `samples`, and `perDollar` (median divided by our current hourly price). Classes we have not measured are absent; nothing is estimated. Optional `gpu` (exact model name). Scope `read`. Paginated. See [GPU benchmarks](/docs/benchmarks).

```json
{
  "benchmarks": [
    {
      "gpuModel": "RTX 3060", "gpuCount": 1, "runs": 2,
      "measuredAt": "2026-11-21T22:10:00.000Z", "source": "measured",
      "metrics": [
        { "id": "fp16", "benchmark": "matmul-fp16", "metric": "tflops", "unit": "TFLOPS",
          "median": 24.5, "runs": 2, "samples": [24.1, 24.9], "perDollar": 172.5 }
      ]
    }
  ],
  "nextCursor": null
}
```

### GET /api/v1/regions

The regions your organization's current servers run in, with a count. Scope `read`. Paginated.

```json
{ "regions": [ { "region": "Germany", "regionCode": "DE", "continent": "europe", "servers": 2 } ], "nextCursor": null }
```

Plans are not pinned to a region: a server is placed on the best matching machine when it launches, so you cannot choose a region in a request. The list is empty while you have no running server.

### GET /api/v1/templates

Software images you can start a server with: the public catalogue and your organization's own templates. Scope `read`. Paginated.

```json
{
  "templates": [
    {
      "id": "tpl_...", "slug": "pytorch", "name": "PyTorch", "summary": "...", "category": "base",
      "image": "...", "tag": null, "launchMode": "jupyter", "env": {}, "ports": [], "startScript": null, "onStart": null,
      "appPort": 8888, "defaultDiskGb": 50, "minVramGb": 0, "custom": false, "sort": 0,
      "createdAt": "2026-11-01T00:00:00.000Z"
    }
  ],
  "nextCursor": null
}
```

`launchMode` is `ssh`, `jupyter` or `app`. A template with `launchMode: "ssh"` needs at least one SSH key in the request. The field set matches the console; fields for private registries and secret variables show names only, never values.

### GET /api/v1/templates/{id}

One template: `{ "template": { ... } }`.

### POST /api/v1/templates

Creates a template of your organization. Scope `full`, owner or admin. The body is the same as the console's template form (see the OpenAPI document for every field); the answer is `201` with `{ "template": { ... } }`. `409 limit_reached` when the organization has the maximum number of templates.

```bash
curl https://YOUR-DOMAIN/api/v1/templates \
  -H "Authorization: Bearer $APIDLY_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"My PyTorch","image":"pytorch/pytorch","tag":"2.5.1-cuda12.4-cudnn9-runtime","launchMode":"ssh"}'
```

### PATCH /api/v1/templates/{id}

Updates fields of one of your organization's templates; send only the fields to change. Scope `full`, owner or admin. Public templates answer `404 not_found`.

### DELETE /api/v1/templates/{id}

Scope `full`, owner or admin. Deletes the template. If servers or requests still reference it, it is hidden instead. Returns `{ "deleted": true, "hidden": false }` or `{ "deleted": false, "hidden": true }`.

### GET /api/v1/ssh-keys

Scope `read`. Paginated, newest first.

```json
{ "keys": [ { "id": "ssh_...", "name": "laptop", "fingerprint": "SHA256:...", "publicKey": "ssh-ed25519 AAAA...", "createdAt": "2026-11-02T10:00:00.000Z" } ], "nextCursor": null }
```

Use the `id` values as `sshKeyIds` when you request a server.

### POST /api/v1/ssh-keys

Adds a public key. Scope `full`. The body is `{ "name": "laptop", "publicKey": "ssh-ed25519 AAAA..." }` (name up to 60 characters). A private key is refused (`400 key_private`). Answers `201` with `{ "key": { ... } }`, or `409 key_duplicate` when the same key is already added. A member's key can later be removed only by that member, an admin or the owner.

### PATCH /api/v1/ssh-keys/{id}

Renames a key. Scope `full`. The body is `{ "name": "desk" }` (1 to 60 characters). Only the name changes: the key itself and the servers that already carry it are untouched. A member can rename only their own keys. Returns `{ "key": { ... } }`.

### DELETE /api/v1/ssh-keys/{id}

Removes a key. Scope `full`. Servers that already use it keep running. Returns `{ "deleted": true, "id": "ssh_..." }`.

## Secrets

Named, write-only values of the organization. Reference one from an environment value as `secret:NAME`; it is filled in when the server starts and never stored in a template or request. See [Secrets](/docs/secrets).

### GET /api/v1/secrets

Scope `servers` (a `read` key gets `403 insufficient_scope`), and a creator who may use secrets (`secrets.manage`, `servers.deploy` or `templates.manage`). Names only: `{ "secrets": [ { "name": "HF_TOKEN", "last4": "ab12", "updatedAt": "..." } ] }`.

### PUT /api/v1/secrets

Creates a secret or rotates its value. Scope `full`, key created by an owner or admin. Body `{ "name": "HF_TOKEN", "value": "..." }`; names are capital letters, digits and underscores, starting with a letter, up to 64 characters. Returns `{ "name": "HF_TOKEN", "created": true }`.

### DELETE /api/v1/secrets?name=HF_TOKEN

Scope `full`, key created by an owner or admin. `409 secret_in_use` while a template or a server request references it.

## Servers

### GET /api/v1/servers

Your servers, newest first. Scope `read`. Paginated. Destroyed servers are left out unless you pass `?includeDestroyed=1`. Filters: `?status=running,stopped` (any of `provisioning`, `starting`, `running`, `stopping`, `stopped`, `restarting`, `error`, `suspended`, `interrupted`, `destroyed`; naming `destroyed` also lists destroyed servers), `?pricing=on_demand` or `interruptible`, `?tag=team-a,batch` (servers that carry every listed tag) and `?q=` for text in the id, label, GPU model, note or any tag. Pass the same filters on every page.

```json
{
  "servers": [
    {
      "id": "ins_...", "deploymentId": "dep_...", "planId": "pln_...", "templateId": "tpl_...",
      "label": "training-run", "tags": ["team-a", "batch"],
      "status": "running", "statusMessage": null, "statusReason": null,
      "gpuModel": "RTX 4090", "gpuCount": 1, "vramGb": 24, "vcpus": 16, "ramGb": 64, "diskGb": 50,
      "region": "South Korea", "regionCode": "KR", "continent": "asia", "launchMode": "ssh",
      "hourlyPriceMicros": "940000", "hourlyPriceUsd": "0.940000",
      "storageHourlyMicros": "20000", "storageHourlyUsd": "0.020000",
      "startedAt": "2026-11-20T09:05:00.000Z", "stoppedAt": null, "destroyedAt": null,
      "createdAt": "2026-11-20T09:00:00.000Z",
      "connection": {
        "ssh": { "host": "203.0.113.10", "port": 2222, "user": "root", "command": "ssh root@203.0.113.10 -p 2222" },
        "ports": [ { "internal": 22, "external": 2222, "host": "203.0.113.10" }, { "internal": 8888, "external": 40012, "host": "203.0.113.10" } ],
        "appUrl": null, "accessToken": null, "gateway": false
      }
    }
  ],
  "nextCursor": null
}
```

`status` is one of `provisioning`, `starting`, `running`, `stopping`, `stopped`, `restarting`, `error`, `suspended`, `destroyed`. `connection` is `null` unless the server is `running`. `statusReason` is `null` or one of `start_unavailable`, `launch_failed`, `machine_lost`, `machine_problem`. The example values are placeholders; the console's server page shows the same extra fields (for example hardware details) that the API returns.

`region` is the country the server runs in, as an English country name (`"South Korea"`), with its ISO 3166-1 alpha-2 code in `regionCode` and the continent in `continent` (`africa`, `antarctica`, `asia`, `europe`, `north_america`, `oceania`, `south_america`). State and city are not given. A location that cannot be read is `"Unknown region"` with `regionCode: null`. Match and translate on `regionCode`; the console shows the country name in your language. In `hardware`, `netDownMbps`, `netUpMbps` and `diskBwMBs` are the host's speeds rounded to sensible steps (the console says "about"), `cpuName` is the CPU model in a consistent format (`"Xeon E5-2630 v4"`), and `diskName` is deprecated and always `null`. `connection.ssh` is `null` while the server has no direct SSH port, for example while it is still opening its ports or when its template does not run SSH; it never points at another address.

### GET /api/v1/servers/{id}

One server: `{ "server": { ... } }` with the same fields. Scope `read`. A server of another organization answers `404 not_found`, the same as an id that does not exist.

### POST /api/v1/servers

Requests a new server. Scope `servers`. Honours `Idempotency-Key`. The body is the same as the console's deploy form.

| Field | Type | Notes |
| --- | --- | --- |
| `planId` | string | Required. From `GET /plans`. |
| `templateId` | string | Required. From `GET /templates`. |
| `label` | string | Required. 1 to 60 characters, no control characters. |
| `diskGb` | integer | Required. From the plan's `diskGb` up to 2000. |
| `sshKeyIds` | string[] | Up to 20 ids from `GET /ssh-keys`. Default empty. |
| `env` | object | Up to 50 variables, names like `[A-Za-z_][A-Za-z0-9_]*`, values up to 4096 characters. Default empty. |
| `tags` | string[] | Up to 10 tags copied onto the server, each 1 to 32 characters of `a-z`, `0-9`, `-`, `_`, `.`, `:` (first character a letter or digit; capitals are lower-cased). Default empty. See [Tags](/docs/start-stop-restart#tags). |
| `volumeId`, `volumeMountPath` | string | Optional persistent volume to mount. |
| `allowSelfStop` | boolean | Boolean. Give the server a token in `GPU_SERVER_KEY` that can only read `GET /me` and stop or destroy this server. Default `false`. |
| `fallbackPlanIds` | string[] | Up to two other plan ids, tried in order when the first has no capacity. The price you agree to is the highest hourly total among the plans. Default empty. |
| `webTerminal` | boolean | Reserve one extra port and run a browser terminal on the server (default `false`; `404 feature_unavailable` while the platform does not offer it; not for templates that run the image's own command). Read the address and password with `POST /servers/{id}/terminal`. |
| `constraints` | object | Optional hardware requirements: `region`, `hosting`, `reliability`, `minCpuCores`, `minRamGb`, `minDownMbps`, `minUpMbps`, `minCudaMajor`, `directPorts`. |
| `pricing` | string | `on_demand` (default) or `interruptible`: a cheaper price, and the server can be paused when demand rises (disk kept, compute not charged while paused). Only for plans with an `interruptibleHourlyPriceMicros`; answers the same error as the console while the mode is switched off. There is no separate maximum-price field; the price agreed is returned as `maxHourlyPriceMicros` on the server. |

```bash
curl https://YOUR-DOMAIN/api/v1/servers \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2f1e-8a4b-4a0e-9d34-0c5a1b2d3e4f" \
  -d '{"planId":"pln_...","templateId":"tpl_...","label":"training-run","diskGb":50,"sshKeyIds":["ssh_..."]}'
```

Price and storage price are locked when you ask. If your organization requires an approval for new servers, the answer is `202` and `deployment.status` is `pending_approval`; `server` is `null`. Poll `GET /deployments/{id}` or `GET /servers` until the server appears, or watch the request in the console. Otherwise the answer is `201` and the server starts provisioning:

```json
{
  "deployment": {
    "id": "dep_...", "planId": "pln_...", "templateId": "tpl_...", "label": "training-run", "diskGb": 50,
    "sshKeyIds": ["ssh_..."], "envKeys": [],
    "status": "pending_approval", "reason": null,
    "hourlyPriceMicros": "940000", "hourlyPriceUsd": "0.940000",
    "storageHourlyMicros": "20000", "storageHourlyUsd": "0.020000",
    "instanceId": null, "decidedAt": null, "createdAt": "2026-11-20T09:00:00.000Z"
  },
  "server": null
}
```

`deployment.status` is `pending_approval`, `approved`, `provisioning`, `active`, `rejected`, `failed` or `cancelled`. A request that fails after it was accepted shows `status: "failed"` with `reason` set to `no_capacity`, `price_moved`, `provider_error` or `insufficient_balance`; nothing is charged for a server that never started. `price_moved` means the market price rose past the tolerance between your request and the launch: read the plan price again with `GET /plans` and request again if you accept the new price. Environment variable values are never echoed, only their names (`envKeys`). Refused requests use the error codes above, for example `402 insufficient_balance` and `409 plan_unavailable`.

When the plan you asked for is out of stock, the `409 plan_unavailable` answer names up to three plans that are in stock now and the same or better, cheapest first, in `error.alternatives`. Nothing was created; send the request again with one of the `planId` values. A request that failed for lack of a machine shows the same list as `deployment.alternatives` in `GET /deployments/{id}` for 24 hours. `withinAgreed` is `false` when the plan costs more per hour than the one you asked for. The list is absent when no plan fits.

```json
{
  "error": {
    "code": "plan_unavailable",
    "message": "This configuration is out of stock right now.",
    "requestId": "req_...",
    "docsUrl": "https://YOUR-DOMAIN/docs/troubleshooting#api-error-codes",
    "alternatives": [
      { "planId": "pln_...", "name": "RTX 4090", "hourlyPriceMicros": "990000", "withinAgreed": false }
    ]
  }
}
```

With the CLI, `apidly deploy` prints the same plans as "Try instead:" lines, each with the exact command to run.

### PATCH /api/v1/servers/{id}

Renames a server, switches its automatic move and/or edits its tags. Scope `servers`. Body: `label` (1 to 60 characters), `autoExtend` (boolean; `true` replaces the server on a new machine with the same plan, template, variables and SSH keys shortly before its host's `availableUntil`; disk contents are not moved; `404 feature_unavailable` while the platform has it off, `409 auto_extend_unavailable` for a server with a volume or a reserved term; the server then carries `"autoExtend": true`) and any one way of changing tags: `tags` (replaces the whole list) or `addTags` and `removeTags` (remove first, then add). At least one field. Example: `{ "addTags": ["team-a"], "removeTags": ["old"] }`. A result of more than 10 tags answers `400 too_many_tags`; an invalid tag answers `400 invalid_body`. Tags are your own data and are never sent to the host. Returns `{ "server": { ... } }`.

### POST /api/v1/servers/{id}/start, /stop, /restart

No body. Scope `servers`. Returns `{ "server": { ... } }` with the new status. `409 invalid_state` if the status does not allow it (for example starting a running server). Stopping keeps the disk, which is still charged at the storage price. Starting can answer `402 insufficient_balance` or `503 no_capacity`.

### DELETE /api/v1/servers/{id}

Deletes the server and its disk. This cannot be undone. Scope `servers`, and a key created by an owner or admin, otherwise `403 forbidden`. Returns `{ "server": { ... } }`.

### GET /api/v1/servers/{id}/logs

Scope `read`. `?tail=` is the number of lines, 1 to 1000, default 200.

```json
{ "logs": "line one\nline two\n" }
```

`logs` is an empty string while the server is not running or has not written anything yet.

### POST /api/v1/servers/{id}/exec

Runs one file command on a stopped server and waits up to 60 seconds for the output. Scope `servers`. The body is `{ "command": "ls -la /workspace" }` (one line, up to 512 characters). Only `ls`, `du` and `rm` are accepted (`400 command_refused` for anything else), and only while the server is stopped (`409 exec_needs_stopped` on a running one: use SSH there). It is not an interactive shell. The key must have been created by an owner, an admin or the member who launched the server (otherwise `403 forbidden`); `429` after 20 commands per minute per user.

```json
{ "output": "...", "truncated": false, "timedOut": false }
```

`output` is scrubbed and at most 64 KB (the end is kept, `truncated: true`). `timedOut: true` means no output arrived in time and the command may still be running. The audit log keeps the first 200 characters of the command, never the output.

### POST /api/v1/servers/{id}/terminal

Returns the address and password of the server's browser terminal, under `terminal`: `url`, `host`, `port`, `username`, `password`, `secure`, `selfSigned` and `reachable`. Scope `servers`; the creator of the key must be an owner, an admin or the member who launched the server. The server must be running and must have been requested with `webTerminal: true`.

The page is served by the server itself over HTTPS with a certificate it made at boot, so a browser warns about it once. The address holds no credential: the browser asks for the user name and password. `reachable` is `false` while the terminal is still starting or when it could not start (the server itself is unaffected, use SSH). This is the only call that returns the password; every call is written to the audit log without it. Errors: `404 feature_unavailable` while the platform does not offer the terminal, `404 terminal_not_enabled` for a server requested without it, `409 invalid_state` when the server is not running, `409 terminal_port_unmapped` while its port is not reachable yet.

### GET /api/v1/servers/{id}/ssh-keys

The organization's saved keys, each with `attached` (is it on this server now). Scope `read`, needs `servers.view`. `{ "keys": [ { "id", "name", "fingerprint", "attached" } ], "live": true }`; `live` is `false` when the server could not be asked, and `attached` is then unknown.

### POST /api/v1/servers/{id}/ssh-keys

Attaches a saved key to a running server. Scope `full`, needs `ssh_keys.manage`. Body `{ "keyId": "ssh_..." }` (an id from `GET /ssh-keys`). `409 invalid_state` unless the server is running. Returns the updated list.

### DELETE /api/v1/servers/{id}/ssh-keys/{keyId}

Removes a saved key from the running server; the key stays saved in the organization. Scope `full`, needs `ssh_keys.manage`. Returns the updated list.

### GET /api/v1/servers/{id}/max-price

For an [interruptible](/docs/interruptible) server: `maxHourlyPriceMicros` (the most charged per hour of compute) and `limitHourlyPriceMicros` (the highest the maximum may be raised to), each with a `...Usd` sibling. Both are `null` for any other server. Scope `read`, needs `servers.view`.

### POST /api/v1/servers/{id}/max-price

Raises the maximum price of an interruptible server. Body `{ "maxHourlyPriceMicros": "1500000" }` (whole micros: `1500000` is $1.50 per hour). The price can only go up and never above the limit from the `GET`; otherwise `400 above_cap` or `400 invalid_price`. `409 invalid_state` for a server that is not interruptible, destroyed or suspended. Scope `full`, needs `billing.manage`. Returns `{ "server": { ... } }`.

### GET /api/v1/servers/{id}/metrics?range=1h

Utilisation samples, oldest first. Scope `read`, needs `servers.view`. `range` is `1h` (default), `6h`, `24h` or `48h`. One sample per sync (at most 240); `current` is the latest reading when it is under five minutes old, else `null`.

```json
{
  "samples": [
    { "at": "2026-11-20T09:00:00.000Z", "cpuUtilPct": 12, "ramUsedMb": 8192, "ramTotalMb": 65536,
      "gpuUtilPct": 97, "gpuMemUsedMb": 20480, "gpuMemTotalMb": 24576, "gpuTempC": 71,
      "diskUsedPct": 18, "diskTotalGb": 100 }
  ],
  "current": null
}
```

### GET /api/v1/servers/{id}/events

What happened to a server, newest first: started, stopped, failed and so on. Scope `read`. Paginated.

```json
{
  "events": [
    { "id": "...", "type": "started", "message": "Server started", "actorType": "user", "createdAt": "2026-11-20T09:05:00.000Z" }
  ],
  "nextCursor": null
}
```

`actorType` is `user` (you or a key), `admin` (support) or `system`.

## Requests

A request is what `POST /servers` creates; it turns into a server once it is approved and launched.

### GET /api/v1/deployments

Your requests, newest first. Scope `read`. Paginated. `?status=` filters by one status (`pending_approval`, `approved`, `provisioning`, `active`, `rejected`, `failed`, `cancelled`). Each item has the `deployment` shape shown under `POST /servers`.

```json
{ "deployments": [ { "id": "dep_...", "status": "failed", "reason": "price_moved", "...": "..." } ], "nextCursor": null }
```

### GET /api/v1/deployments/{id}

One request: `{ "deployment": { ... } }`. Scope `read`.

### POST /api/v1/deployments/{id}/cancel

Cancels a request that still waits for approval. Scope `servers`. No body. Returns `{ "deployment": { "status": "cancelled", ... } }`. Any other status answers `409 invalid_state`; to stop a running server use `stop` or `DELETE`.

## Billing

### GET /api/v1/balance

The prepaid balance, the burn rate and the runway at that rate: `{ "balance": { ... } }` with the same fields as `balance` in `GET /me`. Scope `read`.

### GET /api/v1/ledger

Every credit and charge on the wallet, newest first. Scope `read`. Paginated. `?type=` filters by `topup`, `usage`, `refund`, `adjustment`, `subscription_credit` or `promo`. `?from=` (inclusive) and `?to=` (exclusive) take a date (`2026-11-01`, UTC) or a date-time, and `?serverId=` keeps the charges and credits of one server. Pass the same filters on every page.

```json
{
  "entries": [
    {
      "id": "led_...", "type": "topup",
      "amountMicros": "20000000", "amountUsd": "20.000000",
      "balanceAfterMicros": "120000000", "balanceAfterUsd": "120.000000",
      "description": "Credit added", "instanceId": null,
      "createdAt": "2026-11-20T08:30:00.000Z"
    }
  ],
  "nextCursor": "eyJ0IjoiMjAy..."
}
```

`amount...` is signed: charges are negative.

### GET /api/v1/invoices

Invoices, receipts and monthly statements, newest first. Scope `read`. Paginated. `?kind=` keeps `topup`, `subscription` or `statement`; `?from=` (inclusive) and `?to=` (exclusive) take a date or a date-time. Pass the same filters on every page.

```json
{
  "invoices": [
    {
      "id": "inv_...", "kind": "topup", "number": "...",
      "amountCents": 2000, "currency": "usd", "status": "paid",
      "hostedUrl": "https://...", "pdfUrl": "https://...",
      "periodStart": null, "periodEnd": null, "createdAt": "2026-11-20T08:30:00.000Z"
    }
  ],
  "nextCursor": null
}
```

`kind` is `topup`, `subscription` or `statement`. `hostedUrl` and `pdfUrl` are set for payments made through the payment provider and are `null` for monthly statements; open statements in the console.

### GET /api/v1/statements

Monthly statements, newest first: one entry per UTC month from the one the organization was created in (at most 120). Scope `read`, needs `billing.view`. Paginated.

```json
{ "statements": [ { "month": "2026-11", "from": "2026-11-01T00:00:00.000Z", "to": "2026-12-01T00:00:00.000Z", "current": true } ], "nextCursor": null }
```

### GET /api/v1/statements/{month}

One month (`YYYY-MM`, UTC): totals for compute, storage and volumes, the balance at both ends, ledger credits by type and the charge per server, per volume and per day. Scope `read`, needs `billing.view`. `404` for a month before the organization existed or in the future. The current month is not final.

```json
{
  "statement": {
    "month": "2026-10", "from": "2026-10-01T00:00:00.000Z", "to": "2026-11-01T00:00:00.000Z", "current": false,
    "computeMicros": "12340000", "computeUsd": "12.340000",
    "storageMicros": "400000", "storageUsd": "0.400000",
    "volumeMicros": "1200000", "volumeUsd": "1.200000",
    "totalMicros": "13940000", "totalUsd": "13.940000",
    "openingBalanceMicros": "20000000", "openingBalanceUsd": "20.000000",
    "closingBalanceMicros": "26060000", "closingBalanceUsd": "26.060000",
    "credits": [ { "type": "topup", "amountMicros": "20000000", "amountUsd": "20.000000" } ],
    "servers": [ { "key": "ins_...", "label": "training-run", "totalMicros": "12740000", "totalUsd": "12.740000" } ],
    "volumes": [ { "volumeId": "vol_...", "name": "datasets", "sizeGb": 100, "hours": 720, "amountMicros": "1200000", "amountUsd": "1.200000" } ],
    "days": [ { "key": "2026-10-01", "totalMicros": "460000", "totalUsd": "0.460000" } ]
  }
}
```

`?format=csv` returns the per-server and per-volume rows as a CSV download (`text/csv`), the same layout as the console's usage export.

`?format=pdf` returns the printable statement as a PDF download (`application/pdf`) with the same figures; optional `lang` is a locale code for the labels (English when the PDF font cannot draw that script).

### GET /api/v1/ledger/{id}/receipt

The payment receipt of one top-up as a PDF (`application/pdf`): date, amount, currency, payment reference and the balance afterwards. `id` is the `id` of a ledger entry of type `topup`. Scope `read`, needs `billing.view`. `404` when the entry is not a top-up of this organization. Optional `lang` as above.

### GET /api/v1/usage

What you were charged, from `from` (inclusive) to `to` (exclusive), as a date (`2026-11-01`) or a full timestamp. Scope `read`. The default is the current UTC month. The range is at most 366 days. `groupBy` is `instance` (default) or `day`. `rows` is paginated; `totalMicros` covers the whole range.

```json
{
  "from": "2026-11-01T00:00:00.000Z", "to": "2026-11-20T09:10:00.000Z", "groupBy": "instance",
  "rows": [
    {
      "key": "ins_...", "label": "training-run", "destroyed": false,
      "computeMicros": "4800000", "computeUsd": "4.800000", "computeSeconds": 18400,
      "storageMicros": "400000", "storageUsd": "0.400000", "storageSeconds": 72000,
      "totalMicros": "5200000", "totalUsd": "5.200000"
    }
  ],
  "nextCursor": null,
  "totalMicros": "5200000", "totalUsd": "5.200000"
}
```

With `groupBy=day`, `key` is the UTC day and `label` is `null`.

### POST /api/v1/topups

Starts a hosted checkout to add prepaid credit. Scope `full`. Honours `Idempotency-Key`. It returns a payment page URL; open it in a browser and pay there. The credit lands when the payment completes (watch `GET /balance` or `GET /ledger`). The API never charges a saved card, so there is no off-session payment through it. For automatic top-ups use [auto top-up](/docs/auto-top-up) in the console.

| Field | Type | Notes |
| --- | --- | --- |
| `amountCents` | integer | Required. From the minimum top-up (see the console) up to 500000 (5,000 USD). |
| `acceptTerms` | boolean | Required, must be `true`. |

`acceptTerms: true` is the same confirmation the console asks for before payment: you expressly ask for the service to start now and you acknowledge the cancellation refund wording shown in the console. By sending it you confirm this for the person who owns the key. The call is refused if it is missing or `false`; the confirmation is stored with the payment.

```bash
curl https://YOUR-DOMAIN/api/v1/topups \
  -H "Authorization: Bearer $APIDLY_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0a7b0f0e-1c2d-4e3f-8a9b-1c2d3e4f5a6b" \
  -d '{"amountCents":2000,"acceptTerms":true}'
```

```json
{ "topup": { "amountCents": 2000, "checkoutUrl": "https://checkout.example/c/pay/..." } }
```

## Storage

Persistent volumes and data transfers. Reads need scope `read`; the caller's creator needs the permission shown. Volumes cost money from the first hour, so creating one needs scope `full`.

### GET /api/v1/volumes

Paginated, newest first (needs `servers.view`). Returns `{ "volumes": [ ... ], "limits": { "minGb": 10, "maxGb": 2000 }, "nextCursor": null }`. To mount a volume, pass `volumeId` (and optionally `volumeMountPath`) in `POST /api/v1/servers`; only volumes with `attachable: true` can be mounted.

### GET /api/v1/volumes/options?sizeGb=100

Scope `read`. The regions where a volume of that size can be created, with the hourly and monthly price of each. `GET /api/v1/volumes/offers` is the deprecated name of this call (same answer, until 2027-05-31); `offer` in the answer is the deprecated name of `option`.

### POST /api/v1/volumes

Scope `full`, needs `servers.deploy`. Body `{ "name", "sizeGb", "region", "shownHourlyMicros" }` using a region and price from the offers call; the call is refused when the price rose since. Answers `201` with `{ "volume": { ... } }`.

### GET /api/v1/volumes/{id}

Needs `servers.view`. Returns `{ "volume": { ... } }`.

### DELETE /api/v1/volumes/{id}?confirm=NAME

Scope `full`, needs `storage.manage`. `confirm` must equal the volume's name. The data is deleted for good.

### GET /api/v1/transfers, GET /api/v1/transfers/{id}

Scope `read`. Copies between servers, newest first (the list keeps the latest 50; the lookup by id finds any transfer of the organization). A transfer has `kind` (`copy`), `status` (`running`, `completed`, `failed`, `cancelled`, `unverified`) and `percent`.

### POST /api/v1/transfers

Scope `servers`, key created by any built-in role. Body: `{ "kind": "copy", "srcInstanceId", "dstInstanceId", "srcPath", "dstPath" }`. Both servers must be running. Answers `201` with `{ "transfer": { ... } }`.

### DELETE /api/v1/transfers/{id}

Scope `full`. Cancels a running transfer. A copy that is already moving data cannot be stopped: data already in flight may still arrive at the destination (the transfer then shows `status: "cancelled"` and a `message` that says so).

## Registries

Logins for private image registries, used when a server pulls an image.

### GET /api/v1/registries

Scope `read`. `{ "registries": [ { "id", "host", "username", "last4", "createdAt" } ], "nextCursor": null }`. The token is never returned.

### POST /api/v1/registries

Scope `full`, key created by an owner or admin. Body `{ "host": "ghcr.io", "username": "...", "token": "..." }`. The token is write-only. Answers `201` with `{ "registry": { ... } }`.

### PATCH /api/v1/registries/{id}

Rotates the login. Scope `full`, needs `templates.manage`. Body `{ "username"?: "...", "token"?: "..." }` with at least one field; the host does not change. Answers `{ "registry": { ... } }` (never the token).

### DELETE /api/v1/registries/{id}

Scope `full`, key created by an owner or admin. Returns `{ "deleted": true }`.

## API keys

Needs the `api_keys.manage` permission.

### GET /api/v1/api-keys

Scope `full`. Active keys: `id`, `name`, `prefix`, `scope`, `permissions` (null = no extra limit), `expiresAt`, `allowedCidrs`, `lastUsedAt`, `createdAt`. The secret is never returned.

### POST /api/v1/api-keys

Scope `full` only: a key with a lower scope is refused with `403 insufficient_scope`. Body `{ "name", "scope": "read|servers|full", "expiresAt": "2026-12-31T00:00:00Z", "allowedCidrs": ["203.0.113.0/24"], "permissions": ["servers.view", "servers.manage"] }`; only `name` is required (scope defaults to `full`, expiry to none). The new key acts as the same member as the calling key, so it can never do more than that member may. Answers `201` with `{ "key": { ..., "key": "apc_live_..." } }`; the full key is in this response only.

`allowedCidrs` is an optional IP allowlist: up to 20 CIDR blocks or single addresses, IPv4 or IPv6. When it is not empty, a call from any other address answers `401 unauthenticated`, exactly like an unknown key. Leave it out to accept calls from anywhere. The console's create-key dialog has the same field.

### DELETE /api/v1/api-keys/{id}

Scope `full`. Revokes the key at once (a key may revoke itself). Returns `{ "revoked": true, "id": "key_..." }`.

## Settings and billing details

### GET /api/v1/budget, PUT /api/v1/budget

`GET` needs `billing.view` and scope `read`: `monthlyBudgetMicros`, `alertThresholds`, `hardStop`, `lowBalanceThresholdMicros`, `level`, `month`, `percent`, `spentMicros` (each micros field has a `Usd` twin) and `members` (spend per member, owners only). `PUT` needs `billing.manage` and scope `full`; the body takes `monthlyBudgetCents`, `alertThresholds` (`50`, `80`, `100`), `hardStop` (needs `"confirmHardStop": true`) and `lowBalanceCents`, any of them; `null` clears an amount. Returns the new status.

### GET /api/v1/billing/details, PUT /api/v1/billing/details

`GET` needs `billing.view`: `{ "details": { "billingName", "line1", "line2", "city", "state", "postalCode", "country", "taxId", "taxIdType" } }`. `PUT` needs `billing.manage` and scope `full`; send every field (`country` is a two-letter code). Returns `{ "details": { ... }, "stripeSynced": true }`.

### GET /api/v1/notification-preferences, PUT /api/v1/notification-preferences

Scope `read` / `full`. Categories with the email and in-app switches of the member the key acts as, and the organization's webhook switch. `PUT` body `{ "user": { "<category>": { "email": true, "inApp": false } }, "org": { "<category>": { "webhook": true } } }`; both parts are optional and categories left out are unchanged. `org` rows need the `webhooks.manage` permission.

### GET /api/v1/activity

Scope `read`, needs `activity.view`. The organization's activity trail, newest first: `{ "activity": [ { "id", "at", "category", "action", "actor", "ip", "params" } ], "nextCursor": null }`. Query: `category` (`signIn`, `team`, `keys`, `servers`, `billing`, `settings`), `actor` (exactly one actor id: a member's user id or an API key id), `from` and `to` (UTC days, `YYYY-MM-DD`), `limit` (1 to 100, default 25), `cursor`. Addresses are masked to the /24 unless the key was created by the owner.

### GET /api/v1/plans/{id}/history

Scope `read`. The last 30 days of price and availability of one plan as seen in our catalogue: `days` (one entry per day, `null` when there is no snapshot), `minMicros`, `maxMicros`, `observedDays`.

## Server automation and recreation

### GET /api/v1/servers/{id}/automation

Needs `servers.view`. `{ "rules": { "maxRuntimeHours", "idle", "destroyAt", "spendCapCents", "schedule", "lastFired" }, "nextStopAt", "nextStartAt" }`. `nextStopAt` is when the time rules (including the weekly schedule) stop the running server next; `nextStartAt` is when the weekly schedule starts the stopped server next. Each is null when nothing is planned. PUT and DELETE return the same shape.

### PUT /api/v1/servers/{id}/automation

Scope `servers`, needs `automation.manage`. Body: any of `maxRuntimeHours`, `idle` (`{ "thresholdPct", "minutes" }`), `destroyAt`, `spendCapCents` and `schedule`; a key sent as `null` clears that rule, a key left out is unchanged. Setting a scheduled destroy also needs the destroy permission. Returns `{ "rules": { ... } }`.

### DELETE /api/v1/servers/{id}/automation

Scope `servers`, needs `automation.manage`. Clears every rule of the server.

### POST /api/v1/servers/{id}/recreate

Scope `servers`, needs `servers.manage`. Recreates the server from a freshly pulled image with the same configuration. **It erases every file on the server, `/workspace` included**; attached volumes and cloud copies are not affected, and the SSH and app ports change (read them again with `GET /api/v1/servers/{id}`). The key's creator must be an owner, an admin or the member who launched the server. Returns `{ "server": { ... } }`.

`POST /api/v1/servers/{id}/recycle` is the deprecated name of this call. It still works the same way, with the same scope and permission; use `/recreate` in new code.

### POST /api/v1/servers/{id}/hard-reboot

Scope `servers`, needs `servers.manage`. Stops a running server and starts it again with the next minute job, which gives the container a clean start. Files on the disk, `/workspace` included, are kept; the uptime the operating system reports is the host's and does not reset. `409 invalid_state` unless the server is running. Returns `{ "server": { ... } }`.

### GET /api/v1/servers/{id}/usage

Hourly charges of one server. Scope `read`, needs `servers.view`. Optional `from` and `to` (ISO dates; `from` defaults to the hour the server was created). Returns `usage` (one row per hour and kind, `compute` or `storage`) and `totals` with `computeMicros`, `storageMicros` and `totalMicros`, each with a `...Usd` sibling.

## Webhook changes

Beyond create, list and delete, a webhook can be changed with `PATCH /api/v1/webhooks/{id}` (any of `url`, `description`, `events`, `active`), given a new signing secret with `POST /api/v1/webhooks/{id}/rotate-secret` (the old secret keeps signing for 24 hours), sent a signed test event with `POST /api/v1/webhooks/{id}/test`, and a past delivery can be sent again with `POST /api/v1/webhooks/deliveries/{deliveryId}/redeliver`. All need scope `full` and `webhooks.manage`.

## Template copies and history

`POST /api/v1/templates/{id}/duplicate` copies one of your organization's templates (`201`). `GET /api/v1/templates/{id}/revisions` lists its revision history, newest first, without secret values. `POST /api/v1/templates/{id}/revisions/{rev}/restore` restores an older revision as a new one; history is never rewritten. The copy and the restore need `templates.manage` and scope `full`; the history needs scope `read`.

## Roles, invitations, notifications, support and log files

- `POST /api/v1/team/roles`, `PATCH /api/v1/team/roles/{id}` and `DELETE /api/v1/team/roles/{id}` create, replace and delete custom roles (body `{ "name", "description", "permissions": [...] }`, names from `GET /team/roles`). Scope `full`, needs `team.manage`, and the key's creator must be the owner. `409 role_in_use` while members or invitations hold the role.
- `POST /api/v1/team/invitations/{id}/resend` sends an invitation again with a fresh link (valid 7 days). Scope `full`, needs `team.manage`.
- `GET /api/v1/notifications?limit=` lists the in-app notifications of the member the key acts as (newest first, with the unread count); `POST /api/v1/notifications/read` marks all as read.
- Support tickets: `GET /api/v1/support/tickets` (paginated, `?status=open|pending|closed`), `POST /api/v1/support/tickets` (`subject`, `message`, optional `category`, `priority`, `serverId`), `GET /api/v1/support/tickets/{id}` (with messages), `POST /api/v1/support/tickets/{id}/messages` (`{ "message" }`, `409 ticket_closed` on a closed ticket) and `POST /api/v1/support/tickets/{id}/close`. Replies from staff arrive by e-mail and in the console.
- `GET /api/v1/servers/{id}/logs/download` returns the last 1000 log lines as a `text/plain` attachment.

Automation rules also take `stopAt` (ISO date-time or `null`) on `PUT /servers/{id}/automation`: the server is stopped at that time. A time in the past, or less than a minute ahead, is `400 invalid_stop_time`.

## Webhooks and groups

Webhook endpoints (`/webhooks`, `/webhooks/{id}`, `/webhooks/{id}/deliveries`) and server groups (`/groups`, `/groups/{id}`, `/groups/{id}/pause`, `/groups/{id}/resume`) are described in the [OpenAPI document](/api/v1/openapi.json). Reading groups needs scope `read`; reading webhooks needs scope `full` and an owner or admin creator. Every change needs scope `full`, except pause and resume of groups (`servers`), and an owner or admin creator.

## Serverless endpoints

When endpoints are switched on for the account: `/endpoints` (list, create), `/endpoints/{id}` (read, change, delete), `/endpoints/{id}/pause`, `/endpoints/{id}/resume` and `/endpoints/{id}/metrics?range=1h|24h|7d`, described in the [OpenAPI document](/api/v1/openapi.json). Reads need scope `read`; create, change and delete need `full`, pause and resume `full`, all with an owner or admin creator. Requests to your server go to `/endpoints/{id}/proxy/<path>` (`GET` with `read`, other methods with `servers`); see [Serverless endpoints](/docs/endpoints) for the routing, limits and the `503 no_worker_ready` answer. Workers are billed by the second like servers; there is no per-request price.

## Audit

Every call that changes something is written to the organization's audit log with the key's id as the actor.
