What You’ll Learn
- How to generate and use API keys
- Permission levels for API keys
- Legacy v1 authentication methods
- Troubleshooting authentication errors
Bearer Token Authentication
Generate an API key in your MainWP Dashboard to authenticate requests.Generating an API Key
1
Navigate to REST API settings
Go to Dashboard > REST API > Add API Keys.
2
Create the key
Enter a descriptive name and click Generate.
3
Save the token
Copy the generated API key immediately—it cannot be retrieved later.
4
Set permissions
Select the required permissions (Read, Write, Delete).
Using the Token
Include the token in theAuthorization header:
Permissions
Each API key can have one or more permissions:| Permission | HTTP Methods | Description |
|---|---|---|
| Read | GET | Retrieve data without modifications |
| Write | POST, PUT | Create or update resources |
| Delete | DELETE | Remove resources |
Legacy API (v1)
For backward compatibility, version 1 endpoints accept Consumer Key and Consumer Secret authentication.Enabling Legacy Credentials
- Edit an existing API key or create a new one
- Click Show Legacy API Credentials
- Copy the Consumer Key and Consumer Secret
- Enable MainWP REST API v1 Compatibility
Using Legacy Authentication
Pass credentials as HTTP Basic authentication:Legacy v1 endpoints are maintained for compatibility. New integrations should use v2 with Bearer tokens.
Troubleshooting
Common Authentication Errors
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Missing or invalid token | Verify the token is included and correctly formatted |
403 Forbidden | Insufficient permissions | Check that the API key has the required permission level |
rest_forbidden | Endpoint requires different permission | Verify the HTTP method matches the key’s permissions |
Requirements
- WordPress permalinks must be set to any option except “Plain”
- At least one active API key must exist
- The Dashboard must be accessible over HTTPS
Self-Check Checklist
- API key generated in Dashboard > REST API
- API key copied and stored securely
- Appropriate permissions assigned
- Token included in Authorization header
- Test request returns expected data
Related Resources
- REST API Overview - API endpoints and usage
- REST API Setup Guide - Detailed setup with screenshots
- Sites Endpoints - Site management endpoints