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

# Tags Endpoints

> Route-level reference for MainWP REST API v2 tag endpoints, including tag CRUD, related sites/clients, and tag batch operations.

Use these endpoints to manage MainWP tags (site groups).

<Note>
  Use the [MainWP Postman collection](https://www.postman.com/mainwp/mainwp/collection/ujfddk4/mainwp-rest-api-v2-current) as the source of truth for request and response schemas.
</Note>

## Route Matrix

| Method           | Path                 | Purpose                                 | Key Params                                         |
| ---------------- | -------------------- | --------------------------------------- | -------------------------------------------------- |
| GET              | `/tags`              | List tags                               | `page`, `per_page`, `search`, `include`, `exclude` |
| GET              | `/tags/{id}`         | Get one tag                             | `id`                                               |
| POST             | `/tags/add`          | Create a tag                            | `name`, optional `color`                           |
| POST, PUT, PATCH | `/tags/{id}/edit`    | Edit a tag                              | `name`, optional `color`                           |
| DELETE           | `/tags/{id}/remove`  | Delete a tag                            | `id`                                               |
| GET              | `/tags/{id}/sites`   | Get sites in a tag                      | `id`                                               |
| GET              | `/tags/{id}/clients` | Get clients linked through tagged sites | `id`                                               |
| POST             | `/tags/batch`        | Batch tag create/update/delete          | `create[]`, `update[]`, `delete[]`                 |

***

## Representative Requests

### Create a tag

```bash theme={null}
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production","color":"#7fb100"}' \
  "https://your-dashboard.com/wp-json/mainwp/v2/tags/add"
```

```json theme={null}
{
  "success": 1,
  "message": "Tag created successfully.",
  "data": {
    "id": 7,
    "name": "Production"
  }
}
```

### Batch tags

```bash theme={null}
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "create": [{"name":"VIP"}],
    "update": [{"id":7,"name":"Production Sites"}],
    "delete": [11]
  }' \
  "https://your-dashboard.com/wp-json/mainwp/v2/tags/batch"
```

```json theme={null}
{
  "create": [{"success": 1}],
  "update": [{"success": 1}],
  "delete": [{"success": 1}]
}
```

***

## Related Resources

* [REST API Overview](/api-reference/rest-api/overview)
* [Sites Endpoints](/api-reference/rest-api/sites)
* [Clients Endpoints](/api-reference/rest-api/clients)
* [Batch Endpoint](/api-reference/rest-api/batch)
