Each organization can run up to 10 sandboxes at once. To raise this limit, contact support.
/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:- Python
- API
Run the following code. It prints the token’s expiration time:
Use a token
Send the token in theAuthorization: Bearer header of sandbox requests and
of your MCP client’s configuration.
To send a request with a token:
-
Set
SANDBOX_TOKENto the returned token: -
Send a sandbox request with the token. This example lists your sandboxes:
Replace expired tokens
You can’t renew a token. Create a new one before the current token’sexpires_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.