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

# Views

> Save a filter once and use it on invoices, agreements, alerts and claims.

A View is a saved filter that everyone in the organization can use, such as "suppliers A and B,
delivered to recipient C". The filter decides which invoices, agreements, alerts and claims belong
to the View. Select it on a list with `view_ids`.

Views only narrow what you see. They never give anyone access to more. Anyone with **Write** access
can manage Views, but someone with an [access limit](https://docs.watchdog.no/api-reference/teams.md) can't delete one or replace
its filter.
Creating a View follows it for notifications. To follow or unfollow one later, use
`PUT` or `DELETE /v1/notifications/followed-views/{view_id}`, which only ever change your own follows.

## Create a View

Send a name and a filter.

```bash theme={null}
curl "$API_URL/v1/views" \
  -H "Authorization: Bearer $API_KEY" -H "X-Organization-Id: $ORGANIZATION_ID" \
  -H 'Content-Type: application/json' \
  -d @view.json
```

This `view.json` covers **supplier A or B, delivered to recipient C**:

```json theme={null}
{
  "name": "Purchasing",
  "filter": {
    "schema_version": 1,
    "root": {
      "combinator": "and",
      "children": [
        {
          "field": "supplier.id",
          "op": "is_any_of",
          "value": ["<supplier-a-id>", "<supplier-b-id>"]
        },
        { "field": "recipient.id", "op": "is", "value": "<recipient-c-id>" }
      ]
    }
  }
}
```

A filter is a group of conditions joined with `and` or `or`. Groups can contain other groups. The
endpoint reference lists every field and operator you can use.

## Things to know about filters

* **Use IDs, not names.** Suppliers, recipients and tags are referred to by ID. Look them up with
  `/v1/parties` and `/v1/agreements/tags`.
* **Deleting a tag removes it from your filters.** A filter with nothing else left is
  deleted.
* **Each condition is checked on its own.** An agreement with one large USD invoice and one small
  NOK invoice matches "amount over 1,000 **and** currency NOK", even though no single invoice
  meets both.
* **Invoice amounts include VAT** and are compared as they are, without currency conversion.
* **A View without a filter matches nothing.**

## Change a View

`PATCH /v1/views/{id}` changes the name, the filter or both. A filter you send replaces the whole
saved filter. Deleting a View is permanent, but doesn't touch any invoices, agreements or other
records.

## Use Views in lists

`view_ids=<id>,<id>` returns records covered by any of the Views you choose. Other filters narrow
the result further.

```bash theme={null}
curl "$API_URL/v1/alerts?view_ids=11111111-1111-4111-8111-111111111111" \
  -H "Authorization: Bearer $API_KEY" -H "X-Organization-Id: $ORGANIZATION_ID"
```

Invoice, agreement, alert and claim lists accept `view_ids`, and so do their totals and exports.


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