# Tags

Tags are reusable, publication-scoped labels. Posts assign an ordered tag list through `/post/save`; the public read API provides tag indexes and archives.

## Authentication

All routes require a bearer token and the named publication capability. Use a publication selector for lists and creates. An existing `tag_id` identifies the publication; any accompanying selector must match.

## Routes

| Route | Methods | Capability | Required input | Optional input and behavior | Success result |
| --- | --- | --- | --- | --- | --- |
| `/tag/list` | `GET`, `POST` | `taxonomy.list` | Publication selector | Pagination | Paginated `tags`. |
| `/tag/get` | `POST` | `taxonomy.list` | `tag_id`, or publication selector plus `slug` | — | `tag`. |
| `/tag/save` | `POST` | `taxonomy.save` | Create: publication selector and `name`; update: `tag_id` | `name`, `slug`, `description`, `seo`, `metadata` | Saved `tag`. |
| `/tag/merge` | `POST` | `taxonomy.merge` | `source_tag_id`, `target_tag_id` | — | Merge result. |
| `/tag/delete` | `POST` | `taxonomy.delete` | `tag_id` | Matching publication selector | Deleted `tag`. |

## Tag object and save fields

```json
{
  "tag_id": "TAG_UUID",
  "publication_id": "PUBLICATION_UUID",
  "slug": "release-notes",
  "name": "Release Notes",
  "description": "Product and deployment announcements.",
  "seo": { "title": "Release Notes" },
  "metadata": null
}
```

`/tag/save` uses `tag_id` for an update, or a publication selector and `name` to create. `slug` is optional and generated from `name` when omitted or empty. `description` accepts a string or `null`; `seo` and `metadata` accept an object, array, or `null`.

```bash
curl -sS https://api.blog.service.m7.org/v1/tag/save \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"publication_slug":"engineering-notes","name":"Release Notes"}'
```

`/tag/list` accepts the standard pagination fields. Merge requires two distinct tags in the same publication, moves source assignments to the target, removes duplicate assignments, then deletes the source tag. Delete is permanent and returns `409` while a post is still assigned the tag.
