> ## Documentation Index
> Fetch the complete documentation index at: https://www.agent37.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Core concepts

> Persistent sandboxes for code, services, and agents: instances, templates, networking, and APIs.

Agent37 Cloud provides persistent sandboxes for code, services, and agents. Each sandbox is an **instance**. A **template** chooses the software installed inside it. The **Sandbox API** manages your instances, and authenticated HTTPS URLs let you reach the services they run. Choose an agent template when you also need the **Agent API** for conversations and tools.

An instance can also be a [full Linux VM](https://www.agent37.com/docs/agents-api/vm-instances.md): set `"type": "vm"` for its own kernel, Docker-in-Docker, Compose, or nested KVM. Use `agent37-ubuntu` for Docker and a Linux desktop, or [`agent37-android`](https://www.agent37.com/docs/agents-api/android) for Android 14 with ADB and a browser screen. Both use the same Sandbox API.

## Two planes, one key

| Plane | Base URL | What it serves |
| - | - | - |
| **Sandbox API** | `https://api.agent37.com/v1` | Creates and manages sandboxes: [instances](https://www.agent37.com/docs/agents-api/instances.md), [templates](https://www.agent37.com/docs/agents-api/templates.md), [budgets](https://www.agent37.com/docs/agents-api/budgets.md). |
| **Sandbox API, on the instance's own machine** | `https://sandbox.agent37.app` | [exec](https://www.agent37.com/docs/agents-api/exec.md) and [logs](https://www.agent37.com/docs/agents-api/logs.md), answered by the machine the instance runs on. The `api.agent37.com` form of both still works and returns the same body. |
| **Agent API** | `https://{instanceId}.agent37.app` | An API included in agent templates: `POST /v1/responses` for [chat](https://www.agent37.com/docs/agents-api/chat.md), plus `/v1/sessions`, `/v1/files`, `/v1/models`, `/v1/health`, and `/v1/version`. |

Both planes take the same `sk_live_` key, in two different headers. `api.agent37.com` takes `Authorization: Bearer sk_live_...`. Everything on `agent37.app` (instance URLs and `sandbox.agent37.app`) takes the raw key as `X-Agent37-Key: sk_live_...`, which leaves `Authorization` free for your own app running inside the instance. Mint keys in the [dashboard](https://www.agent37.com/dashboard/cloud/api-keys), or get your first one with [`POST /v1/signup`](https://www.agent37.com/docs/agents-api/signup) if the caller is a program; each key is scoped to one workspace. On the Sandbox API the key selects your workspace. On an instance URL, the platform edge authenticates the key, verifies the instance belongs to your workspace, and forwards the request to the service listening on the requested port. On an agent template's default port, that service is the agent gateway.

A key can carry an **IP allowlist**: up to 20 IPs or CIDR ranges (IPv4 and IPv6), edited per key in the [dashboard](https://www.agent37.com/dashboard/cloud/api-keys). A restricted key only works from those addresses, on both planes; anywhere else it gets `403 ip_not_allowed` with the observed IP in the message. An empty list means the key works from any IP. [Signed URLs](https://www.agent37.com/docs/agents-api/urls.md) and [public ports](https://www.agent37.com/docs/agents-api/public-ports.md) carry their own authorization and are not affected, so a browser link keeps working wherever it is opened.

A key can also carry an **expiry date**, picked when you create it in the [dashboard](https://www.agent37.com/dashboard/cloud/api-keys). After the end of that day the key gets the same `401` as a revoked key. A key with no date never expires.

Create and manage a sandbox through the Sandbox API, regardless of which template it runs:

```bash theme={null}
curl https://sandbox.agent37.app/v1/instances/ab12cd34ef/exec \
  -H "X-Agent37-Key: sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"command": "uname -s"}'
```

> [!NOTE]
>
> Instance URLs require auth on every request: the `X-Agent37-Key` header for API calls, or a time-boxed [signed URL](https://www.agent37.com/docs/agents-api/urls.md#browser-access-with-signed-urls) to open a preview URL in a browser tab. An unauthenticated request gets a 401.

## The resource model

| Concept | What it is |
| - | - |
| **Instance** | An isolated, persistent computer for code, services, or an agent harness. Built from a [template](https://www.agent37.com/docs/agents-api/templates.md). Lives until you delete it, metered per minute for what it holds: the full rate while running, disk alone while stopped or sleeping. A default instance runs one container; a VM can run Docker and multiple containers inside it. Create one per user or workload. Runs on dedicated servers in the United States. |
| **Template** | The image an instance runs, with an optional default port. Choose a system template or register your own Docker image. |

## Every port has a derivable URL

Nothing about ports is declared per instance:

* The **instance URL**, `https://{instanceId}.agent37.app`, routes to the template's `default_port` (`3737`, the gateway, unless the template says otherwise). On an agent template such as `agent37-hermes`, that makes it the chat URL. The default template, `agent37-base`, has no default port, so its instance URL has nothing behind it.
* Every other port is reachable at its **preview URL**, `https://{instanceId}-{port}.agent37.app`, for example `https://ab12cd34ef-9119.agent37.app`.
* A port can also get a permanent unauthenticated URL; see [Public ports](https://www.agent37.com/docs/agents-api/public-ports.md).

See [Instance and preview URLs](https://www.agent37.com/docs/agents-api/urls.md) for how routing and authentication work, and [Templates](https://www.agent37.com/docs/agents-api/templates.md) for `default_port` on your own images.

## Agent template resources

These resources belong to the Agent API supplied by agent templates. A custom image or a web app such as n8n does not acquire a chat API just by running in a sandbox.

| Concept | What it is |
| - | - |
| **Session** | One conversation on an instance. A message starts one; reuse its `session_id` to continue. An instance can hold many. |
| **Response** | One agentic turn: your input, the agent's work, its reply. Stream it live, or reconnect to its stream by id. |

> [!NOTE]
>
> **The agent is not the model.** The *template* installs the agent software, the *gateway* inside the instance runs your sessions on it (Hermes, OpenClaw, Claude Code, Codex, Grok, OpenCode, and Pi are the live agents today), and the *model* is the LLM the agent thinks with, set as `model` on a turn (plus `provider` on Hermes; see [Models](https://www.agent37.com/docs/agents-api/models.md) for how each harness applies it).

### How they fit together

* Create an **instance** for a user or workload with `POST /v1/instances` on the Sandbox API. It keeps files, connected accounts, and memory across every session. An instance does not have to run around the clock: create it with `auto_sleep: true` and the platform checkpoints it to `sleeping` once it has been idle past its `idle_timeout_seconds`, billing disk alone while it sleeps; any request to its URL wakes it transparently. See [Auto-sleep](https://www.agent37.com/docs/agents-api/instance-auto-sleep.md).
* On an agent template, start a **session** by sending a message to the instance's own URL: `POST https://{instanceId}.agent37.app/v1/responses`. Omit `session_id` and the gateway mints a new session; the reply carries the `session_id` you reuse to continue the thread. See [Sessions](https://www.agent37.com/docs/agents-api/sessions.md).
* Each message produces a **response**. Stream it live with `stream: true` (see [Streaming](https://www.agent37.com/docs/agents-api/streaming.md)), or reconnect a dropped stream with `GET /v1/responses/{id}/stream`.

## One wallet, per-instance caps

Your workspace has exactly one pot of money: the wallet, funded by top-up from the [billing dashboard](https://www.agent37.com/dashboard/cloud/billing). Two things draw on it:

* **Compute.** Each instance is metered per minute: the full rate while running, disk alone while stopped or sleeping. See [Billing](https://www.agent37.com/docs/agents-api/billing.md).
* **Managed usage.** Every instance gets managed LLM, Brave search, and Composio credentials, metered at cost as the agent uses them. They arrive as environment variables inside the container, so a [custom image](https://www.agent37.com/docs/agents-api/custom-image.md) can use them too; see [Managed services in your image](https://www.agent37.com/docs/agents-api/managed-services.md). Model usage on `agent37-claude-code` and `agent37-codex` is the exception: [Claude Code](https://www.agent37.com/docs/agents-api/claude-code.md) runs on your own Anthropic account and [Codex](https://www.agent37.com/docs/agents-api/codex.md) on your own OpenAI account, so Agent37 never supplies or bills their model spend.

Per-instance [budgets](https://www.agent37.com/docs/agents-api/budgets.md) are caps, not money. A budget bounds how much managed spend an instance may pull from the wallet: a monthly cap that resets each UTC month (default \$0) plus one-time top-up headroom. Raising a cap moves no funds; an instance with a generous cap and an empty wallet still gets refused.

## Conventions

* **Instance ids** are bare 10-character lowercase alphanumerics, like `ab12cd34ef`. No prefixes. The id doubles as the DNS label in the instance URL.
* **Session and response ids** are 32-character hex strings minted by the gateway, like `7f3e0b6c52a949d2b1c4a8e9d0f31726`.
* **Money** is integer micros: USD x 1e6, in `*_micros` fields.
* **Timestamps** are epoch seconds on the Sandbox API and epoch milliseconds on the Agent API. The [App integrations](https://www.agent37.com/docs/agents-api/integrations.md) endpoints are the exception: they pass Composio's native shapes through unchanged, with millisecond timestamps.
* **Lists** wrap results in `{ "data": [...] }`. Instance and session lists are newest first. (The App integrations endpoints again pass Composio's native paginated and connection shapes through instead.)

An instance's `status` is one of `provisioning`, `running`, `stopping`, `stopped`, `starting`, `restarting`, `updating`, `sleeping`, `waking`, `failed`, `deleting`, or `deleted`; a response's `status` is `in_progress`, `completed`, `failed`, or `cancelled`.

## Next steps

> [card] [Create an instance](https://www.agent37.com/docs/agents-api/instances/create.md)
>
> Start a persistent sandbox with one request.

> [card] [Bring your own image](https://www.agent37.com/docs/agents-api/custom-image.md)
>
> Choose the tools and services your sandbox runs.

> [card] [Instance and preview URLs](https://www.agent37.com/docs/agents-api/urls.md)
>
> Reach any service over authenticated HTTPS.

> [card] [Use an agent template](https://www.agent37.com/docs/agents-api/agent-quickstart.md)
>
> Add conversations with a hosted harness.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.