Code & Sandbox

Run custom JavaScript, Python, and Shell code in secure sandbox environments.

Code & Sandbox

Weavz includes built-in workspace integrations for code execution, from lightweight data transforms to full multi-language sandbox environments. 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.

Code Integration

A lightweight, secure JavaScript sandbox for data transformation and processing. Zero setup required — works out of the box.

  • 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://api.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"]] }
    }
  }'

Advanced Code 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 persistent when enabled on the workspace integration
  • Persistent storage: Optional mount at /persistent-storage
  • Timeout: Up to 60 seconds 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.

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://api.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": 45,
        "sandboxPersistence": "persistent",
        "storageMountScope": "workspace"
      }
    }
  }'

Example: Python data processing

bash
curl -X POST https://api.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://api.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

FeatureCodeAdvanced CodeMCP Code Mode
LanguagesJavaScript onlyJS, Python, ShellJavaScript only
Network accessNoYesYes (via weavz.*)
Access to integrationsNoNoYes (full weavz.* namespace)
Persistent stateNoYes (optional)No
Persistent storageNoYesNo
Best forData transformsComplex processingAI agent workflows
SetupZeroAvailable on supported plansMCP server in CODE mode

Next Steps