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

# Tag content API

> Assign a list of content items to an existing tag in your Zapnito community through the API.

Work with content in the context of a tag, for example by assigning content to it. The tag must already exist. You can [create a tag](/api/v1/tags#create-a-tag) first.

Before you start, read about [authentication](/api/v1/authentication), [pagination](/api/v1/pagination) and [responses and errors](/api/v1/errors). The [API overview](/api/v1/overview) covers the base URL and lists every resource.

## Assign content to a tag

Assign a list of content items to an existing tag. You can identify the content by URL, by slug, or both.

<ParamField query="parent_name" type="string">
  The name of the tag's parent tag.
</ParamField>

<ParamField body="tag.name" type="string" required>
  The name of the tag to assign the content to.
</ParamField>

<ParamField body="tag.content_urls" type="string[]">
  The URLs of the content to assign to the tag.
</ParamField>

<ParamField body="tag.content_slugs" type="string[]">
  The slugs of the content to assign to the tag.
</ParamField>

```bash title="Assign content to a tag" theme={null}
curl -X PUT "https://your-community.zapnito.com/api/v1/tags/contents?parent_name=Regulation" \
  -H "Authorization: Token token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{
    "tag": {
      "name": "Compliance",
      "content_urls": [
        "https://your-community.zapnito.com/posts/preparing-for-an-audit",
        "https://your-community.zapnito.com/documents/annual-compliance-checklist"
      ],
      "content_slugs": [
        "preparing-for-an-audit"
      ]
    }
  }'
```

`PUT https://your-community.zapnito.com/api/v1/tags/contents`

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "tag": {
      "name": "Compliance",
      "external_url": "https://example.com/regulation/compliance",
      "external_id": "1221",
      "parent_name": "Regulation",
      "content_urls": [
        "https://your-community.zapnito.com/posts/preparing-for-an-audit",
        "https://your-community.zapnito.com/documents/annual-compliance-checklist"
      ]
    }
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "errors": {
      "content_urls": ["No matching items of content found"]
    }
  }
  ```
</ResponseExample>

* `200 OK`: the content was assigned to the tag.
* `404 Not Found`: no content matches the URLs or slugs you provided.


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