---
updatedAt: 2026-11-13T07:57:11.000Z
agentTools:
  projectIndex: https://doc.superannotate.com/llms.txt
---

# Action builder

In the **Action builder**, you can write your code and configure the execution environment by specifying the necessary libraries and dependencies for your action. You can also test your code with a simulated event before integrating it into the Pipeline.

The action builder consists of the **Code editor**, and the following tabs: **Environment**, **Testing**, **Version history** and **Settings**.

# **Code editor**

When creating or editing your action, you can find the **Code editor** on the right-hand side at all times. Here, you can write your Python code using a handler function.

## Handler function

`def handler(event, context)`: This function will process the input data and return results to be used in subsequent pipeline stages.

## Arguments

`event`: This dictionary provides runtime information about the execution, including the event's unique identifier, event type, and the ID of the pipeline where the trigger occurs.

```json
{
    "uuid": 0,
    "event": "project c",
    "pipeline_id": 0
}
```

`context`: is the input data passed to the function, which includes a trigger payload.

```json
{
    "op": "c",
    "after": {
        "id": 0,
        "name": "MyProject",
        "type": "Multimodal",
        "status": "NotStarted",
        "options": 0,
        "team_id": 0,
        "createdAt": 1718965118000,
        "deletedAt": 0,
        "is_pinned": false,
        "updatedAt": 1718965118000,
        "creator_id": "example@email.com",
        "description": null,
        "upload_state": "Initial",
        "entropy_status": "NotStarted",
        "sharing_status": null,
        "attachment_name": null,
        "attachment_path": null,
        "custom_editor_url": null
    },
    "ts_ms": 1718965118466,
    "before": null
}
```

## Return value

The function should return a serializable JSON  object, which represents the result of the action and will be used by the next stage in the pipeline. Make sure to structure this result in a way that is compatible with subsequent processing steps.

## Example

Here's an example of how you might use the handler method in your code to handle an event.

The following script sends a message to a **Slack** channel using Slack's API. For detailed information and additional examples, please refer to the templates available in our <Anchor target="_blank" href="https://github.com/superannotateai/orchestrate">GitHub repository</Anchor>.

```python
import os
import logging

from superannotate import SAClient
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

logging.basicConfig(level=logging.INFO)

SLACK_TOKEN = os.environ['SLACK_TOKEN']
CHANNEL_ID = os.environ['CHANNEL_ID']


def handler(event, context):
    sa = SAClient()

    current_state = context['after']
    project_name = sa.get_project_by_id(current_state['project_id'])['name']

    # Change the message to be sent
    message = f"Ready for annotation: {project_name} has been updated"

    slack_client = WebClient(token=SLACK_TOKEN)
    # Call the conversations.list method using the WebClient
    slack_client.chat_postMessage(
        channel=CHANNEL_ID,
        text=message
        # You could also use a blocks[] array to send richer content
    )
```

# **Environment configurations**

In the **Environment** tab, you set up the execution environment for your action by creating a container image. This environment is where your code will be executed.

## Python Version

Specify the version of Python that your code will use. The chosen Python version should be compatible with your code and any libraries you plan to use.

<Callout icon="📘" theme="info">
  ### Supported packages

  You may use any package available in [PyPI](https://pypi.org/).
</Callout>

## Dependencies

List and manage the dependencies required by your code. This includes external libraries and packages that your action needs to function correctly.

<Callout icon="🚧" theme="warn">
  ### Using SuperAnnotate SDK functions

  Keep in mind that if you use SuperAnnotate's SDK functions in your code, you'll need to add SuperAnnotate as a dependency. i.e. `superannotate>=4.5.0`
</Callout>

After a successful build, actions with a `superannotate` dependency display the SDK version used and the date of the last successful build beneath **Edit**.

When you click **Build**, the platform checks which version of `superannotate` your dependencies would install and compares it with the version used in the action’s **last successful build**.

Confirmation is required when the resolved version introduces a **major or minor version** change, including upgrades and downgrades. Patch-only changes do not require confirmation.

To review a version change:

* In the action’s **Environment** tab, click **Edit**, update your dependencies, and click **Build**.
* If a confirmation pop-up appears, review the previous and proposed SDK versions.
* Click **View Changelog** to review SDK changes and check whether your code needs updating.
* Click **Build** to proceed, or **Cancel** to return without starting the build.

Confirming the build does not change your dependency specification.

Confirmation is not required when:

* The resolved SDK version is unchanged.
* Only the patch version changes.
* The dependency is pinned to an exact version using `==`.
* The action has no successful build to compare against.
* The dependencies do not include `superannotate`.

To keep a specific SDK version, pin it in your dependencies. For example:

```python
superannotate==4.6.2
```

Exact version pins bypass the confirmation pop-up, including when you change the pinned version.

# **Action testing**

In the **Testing** tab, you can test the action by replicating execution using simulated events.

To test your code, you first need to create the action, ensure the environment is successfully built, and then set up the test configurations.

<Callout icon="📘" theme="info">
  Keep in mind that you can only test code when editing an existing action.
</Callout>

## Create a test

To create a test configuration:

1. When in the Testing tab, click **+ Create**.
2. Type in the configuration’s name in the **Test name** field.
3. Select a **Team API key** you want to use for the test (optional). Refer to the <Anchor target="_blank" href="https://doc.superannotate.com/docs/api-keys#team-api-keys">Team API Key</Anchor> section for details.
4. Select a **Secret** you want to link to your test (optional). Refer to the <Anchor target="_blank" href="https://doc.superannotate.com/docs/secrets">Secret</Anchor> section for details.
5. Select a **payload** template (optional). This section lists all available events at SuperAnnotate. Payload templates provide a structured JSON format that you can customize for your testing needs.
6. Modify the prefilled data of the selected payload template or manually enter valid JSON into the **Event** and **Context** fields.
7. Click **Save**.

Once you’ve done this, you can see your configuration in a list under **Test configurations**. You may have a maximum of 10 configurations at one time. You can **Run**, **Edit**, or **Delete** your configurations from this menu.

While running your test, you may **Revoke** it at any time before it’s completed in order to cancel the run.

<Callout icon="⚠️" theme="warn">
  Users without permission to manage **Team API keys** cannot view or change the mounted key. The field is disabled and the key name is masked.
</Callout>

## Run the test

Clicking the **Run** button initiates the testing process, simulating code execution based on the current configuration. The button is located on the configuration row in the left panel and appears when hovering over the row.

You can find the results of your test under the **Test result** section when clicking on the test configuration row.

# Version history

In the **Version history** tab, you can view the history of changes made to an action, compare them to the current state, and restore older versions. Each version includes the **date** and **time** of the changes, the name of the **user** who made them, and the **version ID**.

Every time you make changes in an action, the editor creates a new **draft** you can work on. This draft has **no version ID** and is turned into a new version when you **save** your changes. In **draft mode**, you can freely navigate between tabs—even run tests from the **Testing** tab—without losing your unsaved changes. The draft remains active until you choose to save or discard it.

When you click on a version, the code editor on the right splits into two columns: the selected version's code appears on the left, and the current version's code appears on the right. You can also choose to view code versions in the **Unified** mode, which will compare the selected version and the current version in one unified layout. When viewing both versions in either manner, you can make changes to the current version as needed.

To restore an earlier version:

1. Select the version you want to return to.
2. Click **Restore**.
3. In the pop-up, click **Restore**.

<Callout icon="📘" theme="info">
  ### Will restoring a version overwrite the current one?

  No—restoring a previous version doesn't erase your history. When you restore an earlier version, a new entry is added to the version history, which becomes your new current version. All past versions remain accessible, and you can view or restore any of them at any time.
</Callout>

<Callout icon="📘" theme="info">
  ### Versions from removed members

  Versions made by Team Admins who are no longer a part of the team will still be visible in the history. They will be listed as `Deleted user`.
</Callout>

# **Settings**

In the **Settings** tab, you can update the action's name and description.

## Configurations

Under the **Configurations** tab, you can manage a few additional settings to manage the various limits of action execution:

* **Allocated memory** - The amount of memory that this action can use up. Any executions that exceed this limit will fail automatically.
* **Execution duration** - The amount of time that this action can take to be executed. Any actions that exceed this duration limit will fail automatically.
* **Concurrency** - The maximum number of executions that can take place simultaneously. Any actions that exceed this limit will be held in a queue in the `Received` state for up to 12 hours. If they aren’t executed before then, they’ll automatically fail.

## Resource limits & constraints

### Output size limit

* The return value of the handler function must not exceed 128 KB.
* If this limit is exceeded, the action will fail with the following error:

```json
{ 
"exc_type": "SAException",
"exc_value": "The maximum return size is 128 KB. Messages that exceed this limit won't be sent." 
}
```

### Memory limit exceeded

If the action exceeds its allocated memory:

```json
{ 
"exc_type": "OSError",
"exc_value": "OOMKilled" 
}
```

### Concurrency & scheduling limitations

Delayed Execution:

If an action cannot be scheduled for execution within a reasonable timeframe due to system load, it will be marked as failed.

```json
{ 
"exc_type": "ServiceOverloadedError",
"exc_value": "The action could not be completed due to high system load. Please try again later." 
}
```

Delayed Execution (User Concurrency Limit): If an action remains in the “received” state for more than 12 hours due to user-defined concurrency limits, it will also be marked as failed. This typically occurs when:

* The configured concurrency limit is too low
* A large number of actions are queued

In this case, new actions cannot start until previous ones finish, causing delays.

```json
{ 
"exc_type": "RateLimitError",
"exc_value": "The action could not start because it remained in the received state for over 12 hour due to high system concurrency and system-imposed rate limits. Please try again." 
}
```

### Execution timeout

If the action execution exceeds the configured execution duration, it will be terminated and marked as failed.

```json
{
  "exc_type": "TimeoutError",
  "exc_value": "Execution time exceeded the allowed limit."
}
```