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
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
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", "alice@example.com", "90"], ["Bob", "bob@example.com", "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:
/tmpand/workspacedirectories - Sandbox policy: Ephemeral by default, or persistent when enabled on the workspace integration
- 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.
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.
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": 300,
"sandboxPersistence": "persistent",
"storageMountScope": "workspace"
}
}
}'Example: Python data processing
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
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
| 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 local sandbox state) | Via configured Storage/KV/state workspace integrations |
| Persistent storage | No | Yes (/persistent-storage when enabled) | Via configured Storage/KV workspace integrations |
| 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