<!-- https://developers.silktide.com/guides/tag-websites | Get started -->

# Tag websites

Tags group websites, such as "Pre-production" or "Faculty of Arts", so people can filter them in Silktide and reports can cover every website with a tag. Silktide 5 shows them as labels; they are the same thing. This guide makes a tag and puts it on a website.

## 1. Find or create the tag

[List the account's tags](https://developers.silktide.com/v1/platform/tags/list-tags.md) and look for one whose `entityType` is `section`. Those are the tags for websites and their sections; `document` and `task` tags are for other things.

If the tag you want is not there, [create it](https://developers.silktide.com/v1/platform/tags/create-tag.md):

```bash
curl https://api.eu.silktide.com/v1/tags \
  -H "Authorization: silktide token=$SILKTIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tag": {
      "tagId": "pre-production",
      "label": "Pre-production",
      "entityType": "section"
    }
  }'
```

Use its `tagId`, not its label, from here on.

## 2. Set the website's tags

Send the website's whole set of tags as `tagIds` to [Update a website](https://developers.silktide.com/v1/governance/websites/update-website.md):

```bash
curl -X PUT https://api.eu.silktide.com/v1/websites/6 \
  -H "Authorization: silktide token=$SILKTIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tagIds": ["pre-production", "faculty-of-arts"] }'
```

`tagIds` replaces the website's tags; it does not add to them. To add one tag, read the website's `tagIds` with [Get a website](https://developers.silktide.com/v1/governance/websites/get-website.md), add the new id, and send the whole list back. To remove every tag, send `[]`. Leave `tagIds` out and its tags stay as they are.

Each id you add must be one of the account's `section` tags, so create the tag first. Any other id, including a `task` or `document` tag's, is refused with `400` and an `InvalidRequest` error whose `properties.field` is `tagIds`, and nothing in the request is saved.

You can also send `tagIds` when you [create a website](https://developers.silktide.com/v1/governance/websites/create-website.md).

## 3. Use the tag

- In reports and report schedules, `context.criteria.tagIds` covers every website and section with those tags. See [Create a report](https://developers.silktide.com/v1/governance/reports/create-report.md).
- [Update a tag](https://developers.silktide.com/v1/platform/tags/update-tag.md) changes its label or color on every website that has it.
- [Delete a tag](https://developers.silktide.com/v1/platform/tags/delete-tag.md) takes it off every website that has it.
