Table of Contents

MainWP REST API

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,

  1. Go to WP Admin > Settings > Permalinks Page
  2. Choose any settings except for Plain (this is a WordPress REST API limitation)
    How Can I Enable MainWP REST API? 1
  3. Navigate to Dashboard > REST API > Add API Keys  page
  4. Enter the desired Description
  5. Copy the Consumer Key and Consumer Secret to a safe location.
    NOTE: The Consumer Key and Secret cannot be revealed after you create them.
    MainWP REST API 1
  6. Select the necessary Permissions
    1. Read: necessary for endpoints that use GET method
    2. Write: necessary for endpoints that use PUT method
    3. Delete: necessary for endpoints that use DELETE method
  7. 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 POST or 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.

MainWP REST API 2

 

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.

MainWP REST API 3

 

 

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.

MainWP REST API 4

Still Have a Questions?
Search for additional solutions in the MainWP Community or start your own discussion