> The index of all pages is at https://docs.afffast.com/llms.txt.

# Delivery filters

Send only some events to a webhook endpoint, a destination or a notification channel. All three use the same filters.

A webhook endpoint, a destination and a notification channel take the same `filters` object. Use it to send only the events of some sites, connections, networks, tags or conversion statuses.

```json
{
  "filters": {
    "networks": ["awin"],
    "tags": ["tag_0Yx3kqW7sRzL1nH8aBcD4e"],
    "conversion_statuses": ["approved", "paid"]
  }
}
```

The filters are in these requests:

- `POST /v1/webhook_endpoints` and `PATCH /v1/webhook_endpoints/{id}`
- `POST /v1/destinations` and `PATCH /v1/destinations/{id}`
- `POST /v1/notification_channels` and `PATCH /v1/notification_channels/{id}`

The responses have all five lists. A list that you did not set is empty.

## The rules

- An empty list does not filter.
- The values in one list are **OR**. An event passes when it matches one of them.
- The lists are **AND**. An event must pass each list that is not empty.
- A `PATCH` with `filters` replaces all old filters. A list that you leave out becomes empty. A `PATCH` without `filters` keeps them.
- Each filter applies to some event types only. An event that a filter cannot apply to is **not removed** by that filter. For example, `usage.limit_near` has no site, so a site filter does not remove it.
- An event that a filter applies to, but that has no value for it, is removed. A conversion without a site is removed when `sites` is not empty.

## The filters

| Filter                | Applies to                                                                                                         | Reads                                                                       |
| --------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| `sites`               | `conversion.*`, `click.attributed`, the clicks of a backfill                                                       | The site of the click.                                                      |
| `connections`         | `conversion.*`, `click.attributed`, `connection.*`, `payout.*`, `program.*`, `commission.changed`, backfill clicks | The connection of the object. For `connection.*`, the connection itself.    |
| `networks`            | The same as `connections`                                                                                          | The network of the connection, for example `awin`.                          |
| `tags`                | `conversion.*`, `click.attributed`, `program.*`, `commission.changed`                                              | The tags of the brand of the program. An object without a brand is removed. |
| `conversion_statuses` | `conversion.*`                                                                                                     | The status of the conversion after the change.                              |

`program.*` includes the `program.snapshot` of a backfill. `payout.*` includes the `payout.snapshot` of a backfill. All other event types pass all filters.

## Check of the values

The API checks each value when you save the filters. It answers `422` with `parameter_invalid` and the name of the list in `param` when a value is not valid:

- A site, a connection or a tag must be in your workspace and in the mode of your key. An ID of another workspace or of the other mode is refused.
- A network must be an ID from `GET /v1/networks`.
- A conversion status must be `pending`, `approved`, `rejected`, `paid` or `unknown`.

## A status filter on a data sync destination

A status filter on a data sync destination (Google Sheets, BigQuery) gives an **incomplete copy**. A conversion that leaves the filter is not updated. Example: you send only `pending` and `approved`. A conversion changes to `rejected`. The destination does not get the change, so your sheet or table keeps the old status.

Use `conversion_statuses` for a signal: a notification channel, a webhook endpoint or an analytics destination. Do not use it when you need a complete copy of your data.

## Webhook endpoints

An event that the filters of an endpoint remove makes **no delivery**. The delivery log has no row for it. A test send and a replay are not filtered.

## Where the filters apply

- **Webhook endpoints.** The relay checks the filters when it makes the deliveries of an event.
- **Destinations and notification channels.** The worker checks the filters when it reads the changes for a batch. A backfill uses the same filters.
- **Log drains** have their own filters (`levels` and `status_classes`). They filter log records, not business events.

See [Webhooks](https://docs.afffast.com/docs/webhooks.md), [Destinations](https://docs.afffast.com/docs/destinations.md) and [Notifications](https://docs.afffast.com/docs/notifications.md).
