What You’ll Learn
- How to authenticate with the REST API
- Available endpoint categories
- Request and response formats
- Pagination and batch operations
- Error handling
Postman Collection
Interactive API documentation
Authentication Guide
Set up API keys
Dashboard Setup
Enable REST API
How It Works
The REST API exposes your MainWP Dashboard functionality through standard HTTP endpoints. External tools send authenticated requests to perform actions like listing sites, triggering updates, or managing clients. Responses return structured JSON data that can be parsed by any programming language or automation platform.Prerequisites
| Requirement | Details |
|---|---|
| MainWP Dashboard | Version 5.2 or later |
| Permalinks | Pretty permalinks enabled (not “Plain”) |
| API Key | Generated in Dashboard > REST API |
| Network Access | Dashboard must be publicly accessible |
Your MainWP Dashboard must be accessible via the internet. Locally hosted Dashboards cannot receive external API requests.
Base URL
All API requests target your Dashboard’s WordPress REST API namespace:your-dashboard.com with your actual Dashboard domain.
Authentication
All API requests require a Bearer token in the Authorization header.Bearer Token
Generate API keys in your Dashboard under Dashboard > REST API > Add API Keys:Permissions
Each API key can have granular permissions:| Permission | Methods | Description |
|---|---|---|
| Read | GET | Retrieve data only |
| Write | POST, PUT | Create or modify data |
| Delete | DELETE | Remove data |
API Categories
Sites
17 endpoints for site management
Clients
4 endpoints for client management
Costs
4 endpoints for cost tracking
Tags
1 endpoint for tag retrieval
Updates
13 endpoints for update management
Extensions
33 endpoints for SSL Monitor & Pro Reports
Request Format
The API accepts parameters in different ways depending on the HTTP method:- GET requests: Pass parameters as URL query strings
- POST/PUT requests: Send parameters as JSON in the request body
- DELETE requests: Usually require only the resource identifier in the URL
Content-Type: application/json header when sending JSON bodies:
Response Format
Success
All responses return JSON with the requested data:Errors
Error responses include a code and message:Pagination
List endpoints support pagination through query parameters:| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Current page number |
per_page | integer | 10 | Items per page |
| Header | Description |
|---|---|
X-WP-Total | Total number of items |
X-WP-TotalPages | Total number of pages |
Batch Operations
When triggering batch updates, the API responds immediately with confirmation rather than waiting for completion:Error Reference
HTTP Status Codes
| Code | Description |
|---|---|
| 200 | Request succeeded |
| 201 | Resource created |
| 400 | Bad request - invalid parameters |
| 401 | Authentication required or invalid |
| 403 | Permission denied |
| 404 | Resource or endpoint not found |
| 405 | Method not allowed |
| 5XX | Server error |
MainWP-Specific Errors
| Code | HTTP | Description |
|---|---|---|
mainwp_site_not_found | 404 | Site ID or domain not found |
mainwp_client_not_found | 404 | Client ID or email not found |
mainwp_site_offline | 503 | Site unreachable |
mainwp_invalid_parameters | 400 | Required parameter missing or invalid |
rest_forbidden | 403 | API key lacks required permission |
Feature-Gated Endpoints
Some endpoints require optional MainWP extensions:| Extension | Required For |
|---|---|
| Cost Tracker | /costs endpoints |
| SSL Monitor | /ssl-monitor endpoints |
| Pro Reports | /pro-reports endpoints |
Related Resources
- Authentication Guide - API key setup
- Sites Endpoints - Site management
- Updates Endpoints - Update management
- Abilities API Overview - Alternative API for AI agents