# E2B

## What is E2B?

The E2B node in StackAI allows you to execute code in a secure, sandboxed environment. This is ideal for running scripts, automating tasks, or processing data without exposing your main system to risk. E2B is designed for flexibility, supporting a wide range of coding and automation scenarios.

***

## How to Use the E2B Node

To use the E2B node, add it to your StackAI workflow and configure it to execute your desired code. You can pass inputs from other nodes, specify code to run, and retrieve outputs for further processing. E2B is especially useful for custom logic, data transformation, or integrating with APIs not natively supported by StackAI.

***

## Example of Usage

Suppose you want to process user input, run a Python script, and return the result:

1. Add an Input node to collect user data.
2. Connect the Input node to the E2B node.
3. In the E2B node, specify the code you want to execute, referencing the input as needed.
4. Connect the E2B node to an Output node to display the result.

***

## Available Actions for E2B

Below are the most commonly used actions for the E2B node:

### 1. Run Code (run\_code\_e2b)

**Description:**\
Executes custom code in a sandboxed environment and returns the output.

#### Inputs

| Name     | Description                         | Required | Example                |
| -------- | ----------------------------------- | -------- | ---------------------- |
| code     | The code to execute (string)        | Yes      | print("Hello, World!") |
| language | Programming language (string)       | Yes      | python                 |
| inputs   | Input variables (object/dictionary) | No       | {"x": 5, "y": 10}      |

Showing 1-3 of 3 items

#### Configurations

| Name           | Description                         | Required | Example |
| -------------- | ----------------------------------- | -------- | ------- |
| connection\_id | Connection ID for E2B (if required) | No       |         |

Showing 1-1 of 1 items

#### Outputs

| Name   | Description                        | Required | Example        |
| ------ | ---------------------------------- | -------- | -------------- |
| result | Output of the executed code        | Yes      | Hello, World!  |
| logs   | Execution logs (if any)            | No       | ...            |
| error  | Error message (if execution fails) | No       | SyntaxError... |

Showing 1-3 of 3 items

**Example**

**Input:**

```json
{
  "code": "return x + y",
  "language": "python",
  "inputs": {"x": 5, "y": 10}
}
```

**Output:**

```json
{
  "result": 15,
  "logs": "",
  "error": null
}
```

***

## Best Practices

* Always validate your code before running to avoid errors.
* Use input variables to make your code reusable and dynamic.
* Check the output and error fields to handle execution results gracefully.
* For sensitive or resource-intensive tasks, ensure your code is optimized and secure.

***

## Summary

The E2B node in StackAI is a powerful tool for executing custom code securely within your workflows. By leveraging its flexible input and output options, you can automate complex tasks, process data, and extend StackAI’s capabilities to fit your unique needs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stackai.com/workflow-builder/apps/e2b.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
