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

# Rules and filters

> A rule matches events by type pattern, project, subject and data conditions, then sends each match to one target.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Create a rule that sends only the events you want.

## Prerequisites

* An event type from the catalog.
* For a team rule, the Owner or Admin role.

## Workflow

**Step 1**

In Events, open Rules and choose New rule, or choose Create a rule on a catalog entry.

**Step 2**

Name the rule and enter the event pattern, for example deploy.failed, storage.object.\* or \*.failed.

**Step 3**

Optionally limit it to a project and add conditions on the event data.

**Step 4**

Choose the target and fill in its fields.

**Step 5**

Check the would-have-matched preview for the last 24 hours, then save.

**Step 6**

Use Send a test event to try the target.

## Event patterns

* An exact type: deploy.failed.
* * stands for any characters: storage.object.\* matches every object event, \*.failed matches every failure, and \* alone matches everything.
* A rule takes 1 to 100 patterns. Each must match at least one event in the catalog.

## Filters

* Project: only events from one project.
* Subject: a subject kind, and up to 100 subject ids.
* Conditions on data, up to 20: is, is one of, starts with, has a value. The API also accepts ends with (suffix). A field path is dot-separated inside data, for example content\_type.
* This is matching, not a query language: every condition must hold.

```json Filters in the API theme={null}
{
  "project_ids": ["p_789"],
  "data": [
    { "path": "bucket", "op": "equals", "value": "uploads" },
    { "path": "content_type", "op": "prefix", "value": "image/" }
  ]
}
```

## Whose events a rule sees

* A personal rule matches events in your personal account. A team rule matches that team’s events.
* At delivery time StackShift checks that the rule’s owner can still read the event’s subject. If not, the delivery fails with You no longer have access (access\_revoked) and is not retried.
* Rules created from stackshift.yaml show in Rules but can only be changed in the file.

## Delivery guarantees

Each match is delivered at least once, in order per subject where possible. Deduplicate on the event id.

## Expected result

> [!TIP]
>
> The rule is on and each matching event appears in Deliveries.

## Related guides

> [card] [Targets](https://docs.stackshift.cloud/events/targets.md)
>
> Send a matched event to a webhook, a Function, a durable queue or waiting job, a hosted agent or Stackie, Slack, email or the dashboard, or an automation.

> [card] [Retries, replay and the dead-letter list](https://docs.stackshift.cloud/events/retries-and-replay.md)
>
> Failed deliveries retry 8 times over about 2 days. After the eighth failure the delivery goes to the dead-letter list, the destination or rule is turned off, and the owner gets an email.

> [card] [Events from the CLI and stackshift.yaml](https://docs.stackshift.cloud/events/cli-and-config.md)
>
> List the catalog, tail live events, add a webhook and replay deliveries from the CLI, and declare rules in stackshift.yaml under spec.events.rules.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.