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

# Authentication

Agent Sandboxes requires two credentials, one for each plane. A Telnyx API key authenticates requests at the control plane. A short-lived token authenticates requests at a region's data plane. Both are sent as `Authorization: Bearer`.

| Credential | Plane | Host |
| - | - | - |
| Telnyx API key | Control plane | `api.telnyx.com` |
| Sandbox token | Data plane | `api.<region>.sandbox.telnyxcompute.com` |

See [Architecture](https://developers.telnyx.com/docs/edge-compute/sandboxes/architecture.md) for the requests each plane serves.

## API Key

A Telnyx API key authenticates every request to the control plane at `https://api.telnyx.com`. Create one in the [Telnyx Portal](https://portal.telnyx.com/#/api-keys). See [Create API Keys](https://developers.telnyx.com/docs/development/api-fundamentals/create-api-keys.md).

The request below creates a sandbox with the API key. The CLI reads the key stored by `telnyx-edge auth api-key set`.

```bash Workstation theme={null}
telnyx-edge sandbox-cpu create \
  --image docker.io/library/python:3.12-slim
```

```bash API theme={null}
curl -X POST https://api.telnyx.com/v2/compute/sandbox \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": {"ref": "docker.io/library/python:3.12-slim"}}'
```

## Sandbox Token

A token authenticates requests at a region's data plane. The control plane issues it for the API key's organization.

```bash API theme={null}
curl -X POST https://api.telnyx.com/v2/compute/sandbox/token \
  -H "Authorization: Bearer $TELNYX_API_KEY"
```

The response carries the token, its expiry, and the base URL of every region.

```json Output theme={null}
{
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsImtpZCI6InByb2QtMSJ9...",
    "expires_at": "2026-11-11T19:04:05Z",
    "regions": {
      "us-east-1": "https://api.us-east-1.sandbox.telnyxcompute.com"
    }
  }
}
```

The token is valid for one hour in every region. A request with a missing, expired, or altered token receives `401`. The token is checked when a request starts, so an exec stream or a WebSocket opened with it stays open after it expires.

The CLI uses the API key for the control plane, and mints and caches the data-plane token itself.

A data-plane request carries the token in the same header. The data-plane examples on the other pages write the region's base URL with `/v2/compute/sandbox` appended as `$DATA_API`.

```bash API theme={null}
DATA_HOST=https://api.us-east-1.sandbox.telnyxcompute.com
DATA_API=$DATA_HOST/v2/compute/sandbox
curl $DATA_API -H "Authorization: Bearer $SANDBOX_TOKEN"
```
