Code & Sandbox
Run custom JavaScript, Python, and Shell code in secure sandbox environments.
Code & Sandbox
Weavz includes built-in code execution integrations — 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.
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
inputsJSON 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": "proj_abc123",
"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 sandbox environment with persistent state and network access.
- Languages: JavaScript, Python, Shell
- Network access: fetch, HTTP libraries, external APIs
- Filesystem:
/tmpand/workspacedirectories - Persistent sandbox: Keep installed packages and state across executions
- Persistent storage: Mounted at
/persistent-storage - Timeout: Up to 60 seconds per execution
- Storage scoping: End-user-bound (when
endUserIdprovided), workspace-bound, or external-ID-bound via custom ID. Persistent sandbox containers are also per-user when end-user scoped.
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": "proj_abc123",
"input": {
"language": "python",
"code": "import json\ndata = json.loads(inputs[\"raw\"])\nresult = sum(d[\"amount\"] for d in data)\nprint(f\"Total: {result}\")",
"persistSandbox": true
}
}'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": "proj_abc123",
"input": {
"language": "shell",
"code": "echo \"Files in workspace:\"\nls -la /workspace\necho \"Done\""
}
}'When to Use Which
| Feature | Code | Advanced Code | MCP Code Mode |
|---|---|---|---|
| Languages | JavaScript only | JS, Python, Shell | JavaScript only |
| Network access | No | Yes | Yes (via weavz.*) |
| Access to integrations | No | No | Yes (full weavz.* namespace) |
| Persistent state | No | Yes (optional) | No |
| Persistent storage | No | Yes | No |
| Best for | Data transforms | Complex processing | AI agent workflows |
| Setup | Zero | Available on supported plans | MCP server in CODE mode |
Next Steps
- MCP Code Mode — AI agent code execution with integration access
- Storage & KV — persistent data storage
- Actions — execute integration actions