Skip to content
Weavz
Menu

Sandbox

Run JavaScript, Python, and Shell code in Weavz-managed Sandbox environments.

Weavz includes built-in workspace integrations for Sandbox execution, from lightweight JavaScript transforms to full multi-language runs. Use them to run custom logic, process data between integration calls, or build complex multi-step workflows.

For the full first-party catalog, see Built-In Workspace Integrations.

JavaScript Sandbox

A lightweight JavaScript Sandbox for data transformation and processing. Zero setup required.

  • Action: run_code
  • Input: JavaScript code + optional inputs JSON object
  • Output: Return value + captured console logs
  • No network access, no filesystem, no imports — pure computation only

Use Cases

  • Data transformation between API calls
  • Text parsing and formatting
  • JSON reshaping and filtering
  • Calculations and aggregations

Example: Transform API data

bash
curl -X POST https://platform.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "code",
    "actionName": "run_code",
    "workspaceId": "550e8400-e29b-41d4-a716-446655440000",
    "input": {
      "code": "const data = inputs.rows.map(row => ({ name: row[0], email: row[1], score: parseInt(row[2]) })); return data.filter(d => d.score > 80);",
      "inputs": { "rows": [["Alice", "[email protected]", "90"], ["Bob", "[email protected]", "70"]] }
    }
  }'

Sandbox Integration

A full multi-language code environment with owner-controlled execution policy and network access. Action callers provide only the language and code; timeout, persistence, and mounted storage are configured on the workspace integration.

  • Languages: JavaScript, Python, Shell
  • Network access: fetch, HTTP libraries, external APIs
  • Filesystem: /tmp and /workspace directories
  • Sandbox policy: Ephemeral by default, or reuse within a prepaid lifetime when persistent is enabled
  • Persistent storage: Optional mount at /persistent-storage
  • Timeout: Up to 5 minutes per execution
  • Persistent storage mount: None, Current end user, Shared workspace, or Custom namespace via a storage namespace key. Persistent environments are also per-user when current-end-user scoped.

Hosted sandbox lifetime

Hosted runs reserve time from your organization's monthly sandbox allowance before execution. The active window includes startup and idle time, and lasts up to the configured timeout or the available allowance, whichever is shorter. The maximum window is 300 seconds.

A persistent sandbox can reuse its running environment during that same window. More calls do not restart the clock. When the window ends, running code and background processes stop, and temporary files and in-memory state are cleared. Save durable results through Filesystem or an available persistent storage mount.

Ephemeral sandboxes stop after each run. Unused reserved time returns after the sandbox is confirmed stopped, including failed code runs. If a stop cannot be confirmed, the reservation stays counted until it can be reconciled. Sandbox limits are prepaid caps and do not create automatic overage charges.

Mounted storage is optional and separate from keeping a process alive. If it is unavailable, mounted execution returns 503 SANDBOX_STORAGE_UNAVAILABLE before sandbox time is reserved. Existing files are preserved. Set storageMountScope to none to run without a mount.

Configure execution policy

Create or update the advanced-code workspace integration with settings.advancedCode. This policy is applied by the platform for API, SDK, Playground, and MCP executions, and cannot be overridden by action input.

bash
curl -X POST https://platform.weavz.io/api/v1/workspaces/550e8400-e29b-41d4-a716-446655440000/integrations \
  -H "Authorization: Bearer wvz_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "advanced-code",
    "alias": "advanced_code",
    "settings": {
      "advancedCode": {
        "timeoutSeconds": 300,
        "sandboxPersistence": "persistent",
        "storageMountScope": "none"
      }
    }
  }'

Example: Python data processing

bash
curl -X POST https://platform.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "advanced-code",
    "actionName": "run_code",
    "workspaceId": "550e8400-e29b-41d4-a716-446655440000",
    "workspaceIntegrationId": "660e8400-e29b-41d4-a716-446655440111",
    "input": {
      "language": "python",
      "code": "data = [{\"amount\": 19}, {\"amount\": 23}]\nresult = sum(d[\"amount\"] for d in data)\nprint(f\"Total: {result}\")"
    }
  }'

Example: Shell scripting

bash
curl -X POST https://platform.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "advanced-code",
    "actionName": "run_code",
    "workspaceId": "550e8400-e29b-41d4-a716-446655440000",
    "input": {
      "language": "shell",
      "code": "echo \"Files in workspace:\"\nls -la /workspace\necho \"Done\""
    }
  }'

When to Use Which

FeatureJavaScript SandboxSandboxMCP Code Mode
LanguagesJavaScript onlyJS, Python, ShellJavaScript only
Network accessNoYesYes (via weavz.*)
Access to integrationsNoNoYes (full weavz.* namespace)
Persistent stateNoYes (optional local Sandbox state)Via configured Filesystem/State KV workspace integrations
Persistent filesystemNoYes (when enabled)Via configured Filesystem workspace integrations
Best forData transformsComplex processingAI agent workflows
SetupZeroAvailable on supported plansMCP server in Code Mode

Next Steps