> This page is for Tools.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.moveworks.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.moveworks.com/_mcp/server.

# Script Actions

# Using Script Actions

Script Actions allow you to write custom code to transform data, perform calculations, or implement custom logic. Moveworks currently supports a variation of Python called APIthon.

To provide a secure runtime, each Script Action adds non-negligible latency to your plugins. Please make sure to use [DSL](/api-reference/configuration-languages/moveworks-dsl-reference) and our [Data Mapper](/api-reference/configuration-languages/moveworks-bender-language-reference) for common data transformation operations.

## Option 1: Creating a standalone Script Action

You can create a standalone script action inside of the Plugin Workspace, under Actions > Script Actions. Once created, this action can be referenced inside of plugins through Action Activities.

### Script Action Editor

The standalone Script Action editor includes:

1. **Language selector** - Choose between APIthon (default) or Python (if enabled).
2. **Code editor** - Write your script code here. The last expression evaluated is the output of the script.
3. **Input Args** button - Opens the Input Arguments panel to define inputs for your script.
4. **Test** button - Execute your script with the example values you defined.

### Defining Input Arguments

Click the **Input Args** button to open the Input Arguments panel. Click **Create New** to add an argument with the following fields:

| Field             | Required | Description                                                         |
| ----------------- | -------- | ------------------------------------------------------------------- |
| **Argument Name** | Yes      | The variable name to use in your script (e.g., `customerName`).     |
| **Data Type**     | Yes      | The type of the argument. See [Data Types](#data-types) below.      |
| **List\[T]**      | No       | Check this box if the argument is a list of the selected data type. |
| **Example Value** | No       | A test value used when clicking the **Test** button.                |
| **Description**   | No       | Describe the purpose of this input argument.                        |
| **Required**      | No       | Check if this argument must be provided when calling the action.    |

Click **Save** to save the argument.

### Data Types

The following primitive data types are available for Script Action arguments:

| Type      | Description                      | Example Value                 |
| --------- | -------------------------------- | ----------------------------- |
| `string`  | Text values                      | `John Doe`                    |
| `integer` | Whole numbers                    | `123`                         |
| `number`  | Decimal numbers                  | `3.14`                        |
| `boolean` | True or false                    | `true` or `false`             |
| `array`   | JSON array (mixed types allowed) | `[1, "two", true]`            |
| `object`  | JSON object                      | `{"name": "John", "age": 30}` |

### Using List\[T] for Lists

Check the **List\[T]** checkbox to indicate the argument is a list of the selected type. The example value must be a JSON array where each element matches the base type.

| Data Type | With List\[T]   | Example Value                   |
| --------- | --------------- | ------------------------------- |
| `string`  | `List[string]`  | `["apple", "banana", "cherry"]` |
| `integer` | `List[integer]` | `[1, 2, 3, 4, 5]`               |
| `object`  | `List[object]`  | `[{"id": 1}, {"id": 2}]`        |

> **Note**
>
> The `array` type accepts mixed types within the array, while `List[T]` enforces that all elements are of type T.

## Option 2: Creating a Script Action inside a Compound Action

You can insert a script action directly inside a [Compound Action](/tool-studio/actions/compound-actions) using the `script` keyword.

![](https://files.readme.io/9bdc6e4381a01f5cb97a86e9215e212eb6d589992bdd0c0bdf072aa2a26c55a0-CleanShot_2024-12-11_at_21.32.192x.png)

### YAML Fields for Compound Action Scripts

When adding a script inside a Compound Action, use the following YAML fields:

```yaml
- script:
    output_key: result_variable
    input_args:
      arg_name: data.some_value
    code: |
      # Your APIthon code here
      arg_name.upper()
```

| Field        | Required | Description                                                                                                                                                         |
| ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `output_key` | Yes      | A variable name to store the result of the script.                                                                                                                  |
| `input_args` | No       | A dictionary mapping argument names to values. Accepts [Moveworks Data Mapping Syntax](/api-reference/configuration-languages/moveworks-bender-language-reference). |
| `code`       | Yes      | A string containing the code to execute.                                                                                                                            |

# Supported Languages

Moveworks currently supports a variation of Python called APIthon. This provides a familiar and powerful scripting environment for developers.

Follow [our roadmap item](https://community.moveworks.com/ideas/actions-python-1522) to be the first to get full Python support in your instance.