> ## 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.

# Teams

> Group people around the suppliers, recipients and agreements they look after.

A team is a group of people with a saved filter, such as "suppliers A and B, delivered to
recipient C". The filter decides which invoices, agreements, alerts and claims belong to the team.
Members then see just their records with `mine=true`.

Teams only narrow what you see. They never give anyone access to more. Anyone with **Write** access
can manage teams.

## Create a team

Send a name, a filter and the people who should be on the team. Find user IDs with
`GET /v1/members`, and your own with `GET /v1/me`.

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

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

```json theme={null}
{
  "name": "Purchasing",
  "user_ids": ["<user-id>"],
  "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/suppliers`, `/v1/recipients` and `/v1/agreements/tags`.
* **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 team without a filter matches nothing.**

## Change a team

`PATCH /v1/teams/{id}` changes the name, the filter or both. A filter you send replaces the whole
saved filter. Add people with `POST /v1/teams/{id}/members` and remove them with
`DELETE /v1/teams/{id}/members/{user_id}`. Deleting a team is permanent, but doesn't touch any
invoices, agreements or other records.

## Use teams in lists

* `mine=true` returns records covered by any team you're on.
* `team_ids=<id>,<id>` returns records covered by the teams you choose, whether or not you're a
  member.

You can't send both at once. Other filters you send narrow the result further.

```bash theme={null}
curl "$API_URL/v1/alerts?mine=true" \
  -H "Authorization: Bearer $API_KEY" -H "X-Organization-Id: $ORGANIZATION_ID"
```

Invoice, agreement, alert and claim lists accept these parameters, and so do their totals and
exports.


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