> ## 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.

# Sites Endpoints

> Route-level reference for MainWP REST API v2 site endpoints, including site listing, sync, plugin/theme operations, client/cost lookups, and site batch actions.

Use these endpoints to manage child sites in MainWP Dashboard.

<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>

`{id_or_domain}` accepts either a numeric site ID or a site domain.

## Route Matrix

### Global Site Routes

| Method           | Path                | Purpose                             | Key Params                                                                             |
| ---------------- | ------------------- | ----------------------------------- | -------------------------------------------------------------------------------------- |
| GET              | `/sites`            | List sites                          | `page`, `per_page`, `search`, `include`, `exclude`, `status`, `with_tags`, `full_data` |
| GET              | `/sites/basic`      | List lightweight site records       | `page`, `per_page`, `search`, `include`, `exclude`, `status`                           |
| GET              | `/sites/count`      | Count sites                         | `include`, `exclude`, `status`                                                         |
| POST, PUT, PATCH | `/sites/sync`       | Trigger sync for all sites          | Optional filters like `include`, `exclude`                                             |
| POST, PUT, PATCH | `/sites/reconnect`  | Trigger reconnect for all sites     | Optional filters                                                                       |
| POST, PUT, PATCH | `/sites/disconnect` | Disconnect all matched sites        | Optional filters                                                                       |
| POST, PUT, PATCH | `/sites/check`      | Run connection checks for all sites | Optional filters                                                                       |
| POST             | `/sites/add`        | Add a child site                    | `url`, `name`, `admin`, optional `groupids`, `client_id`                               |
| POST             | `/sites/batch`      | Batch create/update/delete sites    | `create[]`, `update[]`, `delete[]` payload                                             |

### Per-Site Routes

| Method           | Path                                       | Purpose                          | Key Params                                                                                  |
| ---------------- | ------------------------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------- |
| GET              | `/sites/{id_or_domain}`                    | Get full site details            | `id_or_domain`, optional `with_tags`                                                        |
| POST, PUT, PATCH | `/sites/{id_or_domain}/edit`               | Update site fields               | `name`, `groupids`, `client_id`, other editable site fields                                 |
| POST, PUT, PATCH | `/sites/{id_or_domain}/sync`               | Sync one site                    | `id_or_domain`                                                                              |
| GET              | `/sites/{id_or_domain}/security`           | Fetch security snapshot          | `id_or_domain`                                                                              |
| GET              | `/sites/{id_or_domain}/plugins`            | List plugins on one site         | `status`, `search`, `page`, `per_page`, `must_use`                                          |
| POST, PUT, PATCH | `/sites/{id_or_domain}/plugins/activate`   | Activate plugin(s)               | `slug` (single or comma list)                                                               |
| POST, PUT, PATCH | `/sites/{id_or_domain}/plugins/deactivate` | Deactivate plugin(s)             | `slug`                                                                                      |
| DELETE           | `/sites/{id_or_domain}/plugins/delete`     | Delete plugin(s)                 | `slug`                                                                                      |
| GET              | `/sites/{id_or_domain}/plugins/abandoned`  | List abandoned plugins           | Standard list filters                                                                       |
| GET              | `/sites/{id_or_domain}/themes`             | List themes on one site          | `status`, `search`, `page`, `per_page`                                                      |
| POST, PUT, PATCH | `/sites/{id_or_domain}/themes/activate`    | Activate a theme                 | `slug`                                                                                      |
| DELETE           | `/sites/{id_or_domain}/themes/delete`      | Delete theme(s)                  | `slug`                                                                                      |
| GET              | `/sites/{id_or_domain}/themes/abandoned`   | List abandoned themes            | Standard list filters                                                                       |
| GET              | `/sites/{id_or_domain}/non-mainwp-changes` | Show external/non-MainWP changes | `id_or_domain`, optional `source`, `actions`, `contexts`, `total_count`, `page`, `per_page` |
| POST, PUT, PATCH | `/sites/{id_or_domain}/reconnect`          | Reconnect one site               | `id_or_domain`                                                                              |
| POST, PUT, PATCH | `/sites/{id_or_domain}/disconnect`         | Disconnect one site              | `id_or_domain`                                                                              |
| POST, PUT, PATCH | `/sites/{id_or_domain}/suspend`            | Suspend one site                 | `id_or_domain`                                                                              |
| POST, PUT, PATCH | `/sites/{id_or_domain}/unsuspend`          | Unsuspend one site               | `id_or_domain`                                                                              |
| POST, PUT, PATCH | `/sites/{id_or_domain}/check`              | Run check for one site           | `id_or_domain`                                                                              |
| DELETE           | `/sites/{id_or_domain}/remove`             | Remove site from Dashboard       | `id_or_domain`                                                                              |

### Site Relationship Routes

| Method | Path                           | Purpose                     | Key Params     |
| ------ | ------------------------------ | --------------------------- | -------------- |
| GET    | `/sites/{id_or_domain}/client` | Get client linked to a site | `id_or_domain` |
| GET    | `/sites/{id_or_domain}/costs`  | Get costs linked to a site  | `id_or_domain` |

***

## Representative Requests

### List sites

```bash theme={null}
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://your-dashboard.com/wp-json/mainwp/v2/sites?page=1&per_page=20&status=connected"
```

```json theme={null}
{
  "success": 1,
  "total": 2,
  "data": [
    {
      "id": 12,
      "name": "Example Site",
      "url": "https://example.com",
      "status": "connected"
    }
  ]
}
```

### Activate a plugin on one site

```bash theme={null}
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"slug":"akismet/akismet.php"}' \
  "https://your-dashboard.com/wp-json/mainwp/v2/sites/12/plugins/activate"
```

```json theme={null}
{
  "success": 1,
  "message": "Plugin activated successfully."
}
```

### Batch site operations

```bash theme={null}
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "create": [{"url":"https://new-site.com","name":"New Site","admin":"admin"}],
    "update": [{"id":12,"name":"Renamed Site"}],
    "delete": [31]
  }' \
  "https://your-dashboard.com/wp-json/mainwp/v2/sites/batch"
```

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

***

## Related Resources

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