> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OnSandboxState

[View source](https://github.com/wandb/wandb/blob/main/wandb/automations/events.py#L460)

## Class wandb.automations.OnSandboxState

A sandbox is created, completes, or fails.

A sandbox that exits cleanly or is stopped completes. One that fails to
start, exits with an error, or reaches its maximum lifetime fails.

```python theme={"system"}
*,
event_type: Literal[SANDBOX_STATE] = SANDBOX_STATE,
scope: Annotated[wandb.automations.scopes.ProjectScope | wandb.automations.scopes.TeamScope, BeforeValidator(func=<function parse_scope>, json_schema_input_type=PydanticUndefined), Discriminator(discriminator='typename__', custom_error_type=None, custom_error_message=None, custom_error_context=None)],
filter: Annotated[wandb._filters.operators.And | wandb._filters.operators.Or | wandb._filters.operators.Nor | wandb._filters.operators.Not | wandb._filters.operators.Lt | wandb._filters.operators.Gt | wandb._filters.operators.Lte | wandb._filters.operators.Gte | wandb._filters.operators.Eq | wandb._filters.operators.Ne | wandb._filters.operators.In | wandb._filters.operators.NotIn | wandb._filters.operators.Exists | wandb._filters.operators.Regex | wandb._filters.operators.Contains | wandb._filters.operators.Size | wandb._filters.operators.All | wandb._filters.expressions.FilterExpr | dict[str, Any], Json, BeforeValidator(func=<function ensure_json>, json_schema_input_type=PydanticUndefined), PlainSerializer(func=<function to_json>, return_type=PydanticUndefined, when_used='always')]
```

## Args

**event\_type** `Literal`

No description provided.

**scope** `Annotated`

The scope of the event: a project, or a team to cover all of its projects.

The event matches sandboxes by the project they were created in, so an
organization scope is not supported.

**filter** `Annotated`

Sandbox state condition(s) that must be satisfied for this event to trigger.

## Examples

Define an event that triggers for any sandbox created in project
"my-project" when it completes or fails:

```python theme={"system"}
from wandb import Api
from wandb.automations import OnSandboxState, SandboxEvent

api = Api()
project = api.project(name="my-project")

event = OnSandboxState(
    scope=project,
    filter=SandboxEvent.state.in_(["completed", "failed"]),
)
```
