Skip to main content
Run JavaScript in a sandboxed Node.js VM. Chain tool calls, transform data, and create files — all in a single request. For full tool parameters and schemas, see the code-execution server reference.

Quick Start

Send code, get a result. All you need is a runtime token.
Response:
That’s it. Your code runs, you get the return value back. No chat ID, no setup — just send code and get a result.
Your code is wrapped in an async function, so you can use await and return directly.

Response Format

Every response includes:

Sandbox Environment

Code runs in a Node.js VM sandbox. You get standard JavaScript built-ins (JSON, Date, Math, Array, Promise, etc.) plus these helpers: Not available: require(), import(), fetch(), eval(), process, fs, or any npm packages. All external access goes through callTool().

Examples

Chain Multiple Tools

Search the web and summarize the results — two tool calls composed in a single execution:

Use Connected Services

External integrations require a PCID (connection ID). Discover it first:

Transform Data

Process and reshape data between tool calls:

Working with Artifacts

Artifacts let you create and read files that persist across executions. This is useful for generating reports, storing intermediate results, or building files that your application retrieves later.

When You Need a Chat ID

The Quick Start above works for stateless code execution — send code, get a result. But artifacts require a chat context (the X-Chat-Id header) so the platform knows where to store files. There are two ways to get a chat ID: Option 1: Use chat_create (recommended) Use the Agent Management chat_create tool:
Option 2: Create an automation directly

Using Your Chat ID

Once you have a chat ID, include the X-Chat-Id header in your code execution requests:

Create a File

The file appears in createdArtifacts in the response and is stored in the platform. Supported file types: csv, txt, json, html, xml, js, ts, md, py

Read a File

In a later execution (same chat ID), read it back:
You can also read by file ID or platform URL instead of filename.

Retrieve Artifacts via API

Outside of code execution, list and download artifacts using the Agent Management tools or the REST API: Using chat_list_artifacts:
Using the REST API directly:

Limits

When to Use Code Execution