Skip to main content
Each organization can run up to 10 sandboxes at once. To raise this limit, contact support.
A sandbox access token is a short-lived credential for working with sandboxes. Sandbox requests to /v1/sandboxes and a sandbox’s MCP server both require a token, not your Baseten API key. The Baseten CLI and SDKs request new tokens for you before the old ones expire, so create one yourself only when your application calls the sandbox API or connects an MCP client directly.
Keep tokens private. Keep your API key and sandbox access tokens out of agent prompts, application logs, and code you submit to a sandbox. To open a private application preview, use a preview token created for that preview instead; a sandbox access token doesn’t grant access to a private preview URL.

Create a token

The token endpoint is experimental: Baseten can change or remove it without notice. Create tokens with a personal API key or a team API key with full access. A token carries your team memberships, so it isn’t scoped to one sandbox, and it doesn’t grant additional permissions. It expires 2 hours after you create it. To create a sandbox access token:
Run the following code. It prints the token’s expiration time:
For the request and response fields, see Create a sandbox access token.

Use a token

Send the token in the Authorization: Bearer header of sandbox requests and of your MCP client’s configuration. To send a request with a token:
  1. Set SANDBOX_TOKEN to the returned token:
  2. Send a sandbox request with the token. This example lists your sandboxes:
For more information, see List sandboxes.

Replace expired tokens

You can’t renew a token. Create a new one before the current token’s expires_at time. A token can also stop working early if your team memberships or role change. If the API rejects a previously valid token, create a new one. A token’s expiration is separate from the sandbox’s expiration policy: an expired token doesn’t delete the sandbox, and a new token doesn’t extend the time before the sandbox expires.

Next steps

Create and manage sandboxes

Create, inspect, and delete sandboxes.

Manage sandbox images

Choose a built-in image, or create and version your own.