Skip to main content
Retrieve tag information used to organize your child sites.

What You’ll Learn

  • Listing and filtering tags
  • Assigning tags to sites via other endpoints

GET /tags

Returns all tags with pagination support. Method: GET (readonly)
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/tags"

Parameters

NameTypeRequiredDefaultDescription
pageintegerNo1Page number
per_pageintegerNo10Items per page
searchstringNoSearch in tag name
includestringNoComma-separated tag IDs to include
excludestringNoComma-separated tag IDs to exclude

Response

[
  {
    "id": 1,
    "name": "Production",
    "color": "#3498db",
    "sites_count": 25,
    "created_at": "2024-01-01T00:00:00"
  },
  {
    "id": 2,
    "name": "Staging",
    "color": "#e74c3c",
    "sites_count": 10,
    "created_at": "2024-01-01T00:00:00"
  },
  {
    "id": 3,
    "name": "Development",
    "color": "#2ecc71",
    "sites_count": 5,
    "created_at": "2024-01-01T00:00:00"
  }
]

The REST API v2 provides read-only access to tags. For tag creation, modification, and deletion, use the Abilities API or the Dashboard interface.

Assigning Tags to Sites

Tags can be assigned to sites when creating or editing sites via the REST API:
# Assign tags when adding a site
curl -X PUT \
  -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/sites/add?url=https://example.com&name=My%20Site&admin=admin&groupids=1,2"

# Update tags on an existing site
curl -X PUT \
  -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/sites/1/edit?groupids=1,3"
The groupids parameter accepts a comma-separated list of tag IDs.