The MainWP API uses REST conventions and returns all data in JSON format. Requests may be made using the HTTPS protocol and must be authenticated using a Consumer Key and Consumer Secret.
All MainWP REST API calls, including full documentation, and examples, are now publicly available on Postman.
NOTE: Requires your MainWP Dashboard to be set up on a web host. Locally hosted Dashboards will most likely not be reachable by the REST API requests.
How to enable REST API
To enable the REST API functionality,
- Go to WP Admin > Settings > Permalinks Page
- Choose any settings except for Plain (this is a WordPress REST API limitation)
- Navigate to Dashboard > REST API > Add API Keys page
- Enter the desired Description
- Copy the Consumer Key and Consumer Secret to a safe location.
NOTE: The Consumer Key and Secret cannot be revealed after you create them.
- Select the necessary Permissions
- Read: necessary for endpoints that use GET method
- Write: necessary for endpoints that use PUT method
- Delete: necessary for endpoints that use DELETE method
- Click the Save Settings button.
As long as at least one API key is enabled, the REST API functionality of the Dashboard will be enabled.
REST API Permissions
In version 4.5 of the Dashboard, we’ve added granular permissions to the REST API.
Read permission will allow only actions (endpoints) that use the
GET method. API Key, with this permission only, will only be used to return data via REST API.
Write Permission will allow only actions (endpoints) that use
PUT method. API Key, with this permission only, will only be used to trigger actions or add/edit data via REST API.
Delete Permission will allow only actions (endpoints) that use the
DELETE method. API Key, with this permission only, will only be used to trigger actions that delete data via REST API.
Each Key can have one or more permissions set.
API Keys created before version 4.5 will have all three permissions set. If you need to remove any permissions from your existing keys, you can Edit existing keys and readjust permissions as per your needs.
How to disable REST API
To disable the REST API on your Dashboard, navigate to Dashboard > REST API > Manage API Keys page, and disable any Enabled keys you have.
How to delete REST API Keys
To delete the REST API on your Dashboard, navigate to Dashboard > REST API > Manage API Keys page.
Click the Delete button to delete an individual key, or select multiple keys and then select Delete from the Bulk actions dropdown.