Skip to main content
Daytona provides secure, high-performance sandboxes that work well with Mesa. This guide shows the full end-to-end flow: use the Mesa SDK outside the sandbox to set up resources and sign a short-lived access token, then use the Daytona SDK to inject that token and mount Mesa inside the sandbox. The general flow for any sandbox integration is:
  1. Outside the sandbox — the orchestrator holds the API key. Use the Mesa SDK (TypeScript or Python) to create repos, then sign a short-lived access token locally with mesa.tokens.create(...). Only the token crosses into the sandbox; the API key never does.
  2. Inside the sandbox — install the mesa CLI, write a config file, and run mesa mount --daemonize with the injected token passed through the MESA_API_KEY environment variable to mount your repos as local directories.
  3. Run your agentcd into the mount path and launch your agent (e.g. Claude Code, Codex, or a custom agent). Any file edits are automatically persisted back to Mesa.
Access tokens are signed locally by whoever holds the API key — there is no server token endpoint and no network round-trip. The token’s scopes and repository restrictions are clamped against the signing key’s permissions on every request, and revoking the API key instantly invalidates every token it signed. For details on FUSE setup, system dependencies, and container configuration, see POSIX Mount.

Image setup

First, ensure that your Daytona image is properly configured. For example, you can use Daytona’s declarative image builder system, which exposes methods like dockerfileCommands.

Create and mount

Now you can use the Daytona SDK to create a new sandbox with your properly configured image and mount MesaFS inside the sandbox.
An access token is minted once with a fixed TTL (capped at 24 hours) and is never refreshed: there is no background rotation and no credential hot-swap. Mint a token whose TTL covers the whole agent session. After it expires, filesystem operations in the sandbox fail with authentication errors. To continue past expiry, mint a fresh token on the host (the API key lives only outside the sandbox) and remount inside the sandbox with the new token in MESA_API_KEY.

Tips

  • Use access tokens, not API keys, inside sandboxes. Tokens expire on their own, can’t be used to sign further credentials, and leave nothing behind to clean up. See Authentication for details.
  • Pick a TTL that covers the session. The token must outlive your agent’s work. When in doubt, round up — a leaked token is still bounded by its TTL.
  • Use --daemonize. Always run mesa mount --daemonize in sandbox environments so Mesa runs as a background process and doesn’t block your agent’s terminal.
  • Don’t forget user_allow_other. See POSIX Mount — this is the most common setup issue in sandbox environments.