# On sandbox event

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

Sandbox event triggers allow you to automate pipelines based on sandbox lifecycle events: when a sandbox is created, deleted, or timed out.

Sandbox event triggers let you automate pipelines based on sandbox lifecycle events. When a sandbox is created, deleted, or times out, Buddy automatically runs all pipelines whose **Sandbox Scope** matches the sandbox.

There are three sandbox event types:

- **Sandboxes Created** - triggered when a new sandbox is created
- **Sandboxes Deleted** - triggered when a sandbox is deleted
- **Sandboxes Timeout** - triggered when a sandbox times out

![Sandbox event triggers in Buddy](https://buddy.works/docs/pipelines/triggering-pipelines/triggering-pipelines-sandboxes.png)

## Configure trigger

1. Open your pipeline and go to the **Workflow** tab.
2. Click **+** in the **Triggers** section and select one of the sandbox events: **Sandbox: Create**, **Sandbox: Delete**, or **Sandbox: Time out**.
3. Configure **Sandbox Scope** to control which sandboxes can start the pipeline.
4. Click **Save**.

## Sandbox Scope

Each sandbox trigger includes a **Sandbox Scope** section that controls which sandboxes can activate the pipeline. By default, the scope is set to `ID: *`, meaning the trigger fires for all sandboxes.

Click **+** to add a scope entry and choose between two modes:

- **Sandbox** - select one or more specific sandboxes from a searchable list of existing sandboxes in the workspace.
- **Match by filters** - define a filter manually using:
  - **ID** - a sandbox identifier pattern that supports wildcards (e.g., `my-sandbox-*`). Leave empty or use `*` to match any sandbox.
  - **Tags** - one or more tags the sandbox must have.

Multiple scope entries are evaluated with **OR logic** - the trigger fires if any entry matches the sandbox. All three event types (Create, Delete, Time out) use the same Sandbox Scope configuration.

### Examples

- `ID: preview-*` - matches all sandboxes whose name starts with `preview-`
- `Tags: staging` - matches only sandboxes tagged as `staging`
- `ID: *` + `Tags: production` - matches all sandboxes, or only those tagged `production` (OR logic)

> **Info**
>
> Sandbox triggers are available when your workspace has at least one sandbox. See [Sandboxes](https://buddy.works/docs/sandboxes/introduction.md) to learn how to create one.

## See also

- [On artifact event](https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-artifact-event.md)
- [On environment event](https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-environment-event.md)
- [On unit test event](https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-unit-test-event.md)


---
Original source: https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-sandbox-event