Introducing Ephemeral Sandbox Deployments for Mastra Server and Studio

Deploy your entire Mastra project to E2B, Daytona, or Vercel sandboxes.

Paul ScanlonPaul Scanlon·

Aug 5, 2026

·

3 min read

You can now deploy your Mastra project (Server and Studio) to an ephemeral sandbox — manually or programmatically, with configurable runtime limits. Share previews with teammates, let agents deploy autonomously to verify results, or run per-user instances isolated from your infrastructure.

A sandbox deploy gives you two public URLs to test your application. Open Studio to chat with your agents, or hit /api to test the endpoints directly.

We're starting today with E2B, Daytona, and Vercel Sandbox, with more providers to follow.

Before sandbox deployments, hosting a Mastra project meant working through the full development lifecycle — create a PR, push a deploy, share a link. Now you can skip the pipeline and deploy straight to a sandbox. Subsequent deployments reconnect to the existing sandbox without reinstalling dependencies.

Each deployment writes a sandbox-deployment.json manifest with sandbox url, id, and expiresAt, so CI can smoke-test the deploy.

Get started

Install the deployer and a sandbox provider. The examples below use E2B:

GNU BashTerminal
npm install @mastra/deployer-sandbox @mastra/e2b
note
Requires @mastra/core@1.52.0 or later, added in PR #19577.

Configure SandboxDeployer on the Mastra instance. The id identifies the sandbox — repeat deploys with the same id reconnect to the existing one instead of provisioning a fresh sandbox:

TypeScriptsrc/mastra/index.ts
import { Mastra } from "@mastra/core/mastra";
import { SandboxDeployer } from "@mastra/deployer-sandbox";
import { E2BSandbox } from "@mastra/e2b";
 
export const mastra = new Mastra({
  // ...
  deployer: new SandboxDeployer({
    sandbox: new E2BSandbox({
      id: "mastra-sandbox-deploy",
      template: "base",
      timeout: 3_600_000 // 1 hour
    })
  })
});

Manually deploy

Add your E2B API key to .env:

GNU Bash.env
E2B_API_KEY=e2b_...

mastra build doesn't auto-load .env, and the deployer needs your provider credentials at build time. Install dotenv-cli and wire up a deploy script that loads .env before running the build:

GNU BashTerminal
npm install -D dotenv-cli
JSONpackage.json
{
  "scripts": {
    "deploy": "dotenv -e .env -- mastra build"
  }
}

Then build and deploy in one command:

GNU BashTerminal
npm run deploy

Each deploy outputs two URLs to the terminal and writes a manifest into .mastra/output:

  1. API endpoints: https://4111-eijrptonwfyfew4q7cnl6.e2b.app/api
  2. Studio: https://4111-eijrptonwfyfew4q7cnl6.e2b.app
JSON.mastra/output/sandbox-deployment.json
{
  "provider": "e2b",
  "sandboxId": "mastra-sandbox-deploy",
  "url": "https://4111-eijrptonwfyfew4q7cnl6.e2b.app",
  "port": 4111,
  "deployedAt": "2026-08-04T12:46:50.675Z",
  "expiresAt": "2026-08-04T13:46:50.675Z"
}

Hit API endpoints by appending /api to the sandbox url:

GNU BashTerminal
curl -s -X POST <sandbox-url>/api/agents/weatherAgent/generate \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Weather in London"}]}' \
  | jq -r '.text'

Programmatically deploy

From CI, agent code, or your own scripts, use deployToSandbox() to deploy. By default this is API only — pass studio: true to include Studio:

import { deployToSandbox } from "@mastra/deployer-sandbox";
import { E2BSandbox } from "@mastra/e2b";
 
const deployment = await deployToSandbox({
  sandbox: new E2BSandbox({
    id: "ci-smoke",
    template: "base",
    timeout: 3_600_000 // 1 hour
  }),
  dir: ".mastra/output",
  studio: true // optional
});

Use deployment.stop(), and deployment.destroy() for further control over the sandbox lifecycle.

For more information and full configuration options, see:

Share:
Paul Scanlon
Paul ScanlonTechnical Product Marketing Manager

Paul Scanlon sits between Developer Education and Product Marketing at Mastra. Previously, he was a Technical Product Marketing Manager at Neon and worked in Developer Relations at Gatsby, where he created educational content and developer experiences.

All articles by Paul Scanlon