API Issues
This page covers common HTTP error responses from the LicenceForge REST API, their causes, and how to resolve them.
429 Too Many Requests
Symptom
API requests return HTTP 429 with a response body indicating the rate limit has been exceeded.
Cause
The client has exceeded the per-IP rate limit for the endpoint. LicenceForge enforces separate rate limits for validation and activation requests.
| Endpoint Type | Option | Default Limit |
|---|---|---|
| License validation | wplf_rate_limit_validate |
30 requests/minute |
| License activation | wplf_rate_limit_activate |
10 requests/minute |
Solutions
- Implement backoff in the client. The
429response includes aRetry-Afterheader indicating how many seconds the client should wait before retrying. Implement exponential backoff in your client library to respect this header. - Increase the rate limit. If legitimate usage exceeds the defaults, adjust the limits in LicenceForge > Settings or via WP-CLI:
# Increase validation limit to 60 requests/minute wp option update wplf_rate_limit_validate 60 # Increase activation limit to 20 requests/minute wp option update wplf_rate_limit_activate 20 - Cache validation results client-side. Avoid calling the validation endpoint on every page load. Cache the result locally and re-validate periodically (e.g. once per day). The client library handles this automatically.
Note
Rate limits are enforced per IP address using WordPress transients with a 1-minute expiry. See Rate Limiting for full details.
401 Unauthorized
Symptom
API requests return HTTP 401 with an error message indicating authentication failure.
Possible Causes
- Missing API key header. The
X-LicenceForge-Keyheader is not included in the request, and thewplf_require_api_keyoption is set toyes. - Invalid API key. The key provided does not match any record in the
wplf_api_keystable (keys are stored as SHA-256 hashes). - Revoked API key. The key exists but has
is_active = 0(revoked).
Solutions
- Ensure the request includes the API key header:
curl -H "X-LicenceForge-Key: your-api-key-here" \ https://your-site.com/wp-json/wplf/v1/licenses/validate - Verify the API key exists and is active in LicenceForge > API Keys. If the key was regenerated, update the client with the new value.
- If the key was revoked, create a new one with the appropriate permissions. See API Keys.
403 Forbidden
Symptom
API requests return HTTP 403 indicating the authenticated user or API key does not have sufficient permissions.
Possible Causes
- Insufficient API key permissions. A key with
readpermissions cannot perform write operations (creating licenses, activating, etc.). Permission levels are hierarchical:read<write<admin. - WordPress user lacks capabilities. If using cookie-based authentication (admin panel AJAX), the logged-in WordPress user must have the
manage_optionscapability for admin-level API operations.
Solutions
- Check the API key's permission level in LicenceForge > API Keys. Upgrade the permission level if the key needs to perform write or admin operations:
Permission Allowed Operations readValidate licenses, check update info writeAll read operations + activate, deactivate adminAll operations including create, delete, and manage - For cookie-authenticated requests, verify the WordPress user's role includes the
manage_optionscapability (typically Administrator role).
404 Not Found
Symptom
API requests return HTTP 404.
Possible Causes
- WordPress REST API is disabled. A security plugin or custom code has disabled the REST API entirely.
- Incorrect endpoint path. The URL does not match any registered LicenceForge route.
- Product slug does not exist. An endpoint that requires a product slug was called with a slug that does not match any product in the database.
- Permalink structure not configured. WordPress pretty permalinks are required for the REST API to work. The default "Plain" setting does not support REST routes.
Solutions
- Verify the REST API is accessible:
curl https://your-site.com/wp-json/wplf/v1/If this returns a 404 or empty response, the REST API may be disabled.
- Check the endpoint path against the Public Endpoints or Admin Endpoints documentation.
- Verify the product slug exists in LicenceForge > Products.
- Ensure WordPress permalinks are set to anything other than "Plain" in Settings > Permalinks. After changing, flush rewrite rules:
wp rewrite flush
CORS Issues
Symptom
Browser-based API requests fail with CORS (Cross-Origin Resource Sharing) errors in the console, such as Access-Control-Allow-Origin header missing.
Cause
WordPress does not add CORS headers to REST API responses by default. If your client application runs in a browser on a different domain than your WordPress site, the browser blocks the response.
Solution
Add a rest_api_init filter in your theme's functions.php or a custom plugin to set the required CORS headers:
add_action( 'rest_api_init', function () {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function ( $value ) {
header( 'Access-Control-Allow-Origin: https://your-app-domain.com' );
header( 'Access-Control-Allow-Methods: GET, POST, OPTIONS' );
header( 'Access-Control-Allow-Headers: X-LicenceForge-Key, Content-Type' );
return $value;
});
}, 15 );
Warning
Do not set Access-Control-Allow-Origin to * in production. This allows any website to make API requests to your licensing endpoints. Always specify the exact origin domain of your client application.
Quick Reference
| HTTP Status | Most Likely Cause | First Step |
|---|---|---|
401 |
Missing or invalid API key | Check X-LicenceForge-Key header |
403 |
Insufficient permissions | Check API key permission level |
404 |
Wrong endpoint or REST API disabled | Verify endpoint URL and permalink settings |
429 |
Rate limit exceeded | Implement Retry-After backoff |
Related Pages
- Public Endpoints — Full endpoint reference
- Admin Endpoints — Administrative API operations
- API Keys — Key management and permissions
- Rate Limiting — Rate limit configuration and behavior
- Debug Mode — Enabling detailed logging for diagnosis