# API overview

> Base URLs per region, API keys and permissions, v1 and v2, errors, rate limits and pagination.

**Ask your management agent:**

- "Which API keys does my account have?"


Everything you do in the dashboard can be done through the molted.net REST API: create instances, read and
write their files, connect apps, open the browser, give access, read costs. The full reference is at
[/api/docs/v2](https://www.molted.net/api/docs/v2); this page explains how to use it.

## Base URL

The API lives in your account's region:

| Region | Base URL |
|---|---|
| Europe | `https://api.eu1.molted.net/v2` |
| North America | `https://api.na1.molted.net/v2` |

There is no global `api.molted.net`: always use your region's address.

## v1 and v2

- **v2** is the current API, for every runtime (Mue, Hermes). Use it for new work.
- **v1** is frozen. It stays available for older integrations and for the few operations v2 does not cover
  yet. Its reference is at [/api/docs/v1](https://www.molted.net/api/docs/v1).

## Authentication

Send an **API key** of your account in the `Authorization` header:

```
Authorization: Bearer mk_live_…
```

- Create keys in **Developers → API Keys** (account owner only). The key is shown **once**: store it in a
  secrets vault, never in code or in a chat.
- Keys start with `mk_live_` (or `mk_test_`). Both act on your real account: there is no sandbox.
- Keys belong to the account, not to a person. Revoke a key at any time; it stops working immediately.
- A few actions need the account owner in person and refuse API keys: billing top-ups and cards, creating API
  keys, starting the management agent.

Each key carries **permissions** chosen when you create it (read instances, change instances, configuration,
logs, commands, access tokens, billing). Give each integration only what it needs.

## Requests and responses

- JSON in, JSON out (`Content-Type: application/json` when you send a body).
- Instances are identified by their id (`inst-…`) in paths.
- Times are ISO 8601, in UTC.

## Errors

Errors return an HTTP status and a JSON body:

```json
{ "error": "insufficient balance", "code": "insufficient_balance" }
```

Common codes:

| Status | `code` | Meaning |
|---|---|---|
| 400 | — | Invalid request (the message says which field) |
| 401 | — | Missing or revoked key |
| 403 | — | The key does not have the permission, or the action needs the owner |
| 402 | `insufficient_balance` | Not enough credit to create the instance |
| 402 | `balance_depleted` | Not enough credit to start the instance |
| 402 | `account_suspended_balance`, `account_suspended_payment` | The account is suspended for an unpaid balance |
| 403 | `instance_limit_reached` | Your account's instance limit is reached |
| 429 | `rate_limited` | Too many requests: wait `retryAfterSec` seconds (also in the `Retry-After` header) |
| 503 | `capacity_reached` | Capacity momentarily reached: retry later |

## Rate limits

- **300 requests per minute** per key.
- Some operations have their own limits per account, for example creating, starting, restarting or deleting
  instances many times an hour, or creating invite links. See [Limits](limits.md).

Over a limit you get `429` with `Retry-After`: wait, then retry.

## Pagination

Lists are paginated with a cursor, newest first:

- `limit`: 1 to 100 (100 by default);
- the response carries `nextCursor`; pass it as `cursor` to get the next page; `nextCursor: null` means you
  are done.

## Events and webhooks

There are no outgoing webhooks yet. To follow what happens, poll the instance, its alerts (`/v2/alerts`) and
its metrics, or read its events.

## Using the API from an agent

The simplest client of the API is an agent. Give your agent (Claude Code, Codex, a Mue agent…) an API key in an
environment variable and point it to:

- this documentation: [/docs/llms.txt](https://www.molted.net/docs/llms.txt);
- the reference: [/api/docs/v2](https://www.molted.net/api/docs/v2), which returns the raw OpenAPI file to
  programs and the interactive reference to browsers.

Ask it to read the reference before calling the API, and to confirm with you before anything that costs money
or deletes something. Recipes: [API recipes](api-recipes.md).
