> ## 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]
>
> The [per-user ownership rules](https://docs.mainwp.com/api-reference/rest-api/overview.md#permission-scope) apply to tag routes, including batch operations and creation requests that refer to an existing tag ID. Lists omit tags owned by other users. Reading, changing, or deleting another user's tag returns that route's normal missing-tag response.

> [!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.

## 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](https://docs.mainwp.com/api-reference/rest-api/overview.md)
* [Sites Endpoints](https://docs.mainwp.com/api-reference/rest-api/sites.md)
* [Clients Endpoints](https://docs.mainwp.com/api-reference/rest-api/clients.md)
* [Batch Endpoint](https://docs.mainwp.com/api-reference/rest-api/batch.md)


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