# Create Sandbox — Daytona

> Creates a new sandbox on Daytona. Provide a Snapshot to create from a pre-built template, an Image to create from a custom Docker image, or neither to use the Daytona default snapshot. Snapshot takes precedence over Image if both are…

- Key: `daytona-create-sandbox`
- Type: Action (Write)
- Version: 0.0.3
- App: Daytona (`daytona`) — https://pipedream.com/apps/daytona.md
- This page (HTML): https://pipedream.com/apps/daytona/actions/create-sandbox
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/daytona/actions/create-sandbox/create-sandbox.mjs

## Description

Creates a new sandbox on Daytona. Provide a **Snapshot** to create from a pre-built template, an **Image** to create from a custom Docker image, or neither to use the Daytona default snapshot. **Snapshot takes precedence over Image** if both are provided. [See the documentation](https://www.daytona.io/docs/en/typescript-sdk/daytona/#create)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | No | The name of the Sandbox |
| `snapshotId` | `string` | No | Pre-built snapshot to use as the sandbox base. Takes precedence over Image if both are provided. If neither Snapshot nor Image is specified, the Daytona default snapshot is used. Options are loaded from the connected account. |
| `image` | `string` | No | Custom Docker image to use for the Sandbox (e.g. python:3.12-slim). Only used when no Snapshot is specified. Supports public registry images. |
| `cpu` | `integer` | No | Number of CPU cores to allocate (minimum: 1). Only applies when using a custom Image, not a Snapshot. |
| `memory` | `integer` | No | Amount of memory in GiB to allocate (minimum: 1). Only applies when using a custom Image, not a Snapshot. |
| `disk` | `integer` | No | Amount of disk space in GiB to allocate (minimum: 1). Only applies when using a custom Image, not a Snapshot. |
| `autoArchiveInterval` | `integer` | No | Auto-archive interval in minutes (0 means the maximum interval will be used). Default is 7 days. |
| `autoDeleteInterval` | `integer` | No | Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping). By default, auto-delete is disabled. |
| `autoStopInterval` | `integer` | No | Auto-stop interval in minutes (0 means disabled). Default is 15 minutes. |
| `envVars` | `object` | No | Optional environment variables to set in the Sandbox |
| `ephemeral` | `boolean` | No | Whether the Sandbox should be ephemeral. If true, autoDeleteInterval will be set to 0 |
| `labels` | `object` | No | Labels to set on the Sandbox. Example: { 'my-label': 'my-value' } |
| `language` | `string` | No | Programming language for direct code execution. Defaults to python if not specified. |
| `networkAllowList` | `string` | No | Comma-separated list of allowed CIDR network addresses for the Sandbox (e.g. 10.0.0.0/8,192.168.1.0/24) |
| `networkBlockAll` | `boolean` | No | Whether to block all network access for the Sandbox |
| `public` | `boolean` | No | Is the Sandbox port preview public? |
| `user` | `string` | No | Optional OS user to use for the Sandbox |
| `volumes` | `object` | No | Optional array of volumes to mount to the Sandbox. See the documentation for more details. |
| `timeout` | `integer` | No | Timeout in seconds (0 means no timeout, default is 60) |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "daytona",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "daytona-create-sandbox",
  arguments: {
    name: "Name",
    snapshotId: "Snapshot ID",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "daytona-create-sandbox",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    daytona: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    snapshotId: "Snapshot ID",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "daytona-create-sandbox",
    "configured_props": {
      "daytona": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "snapshotId": "Snapshot ID"
    }
  }'
```

---

- App: https://pipedream.com/apps/daytona.md · All apps: https://pipedream.com/apps
