API Key authentication is the simplest method. Use it for server-to-server integrations where a long-lived credential is appropriate.
Including the Key in a Request #
Primary method — Authorization header (recommended):
curl https://yoursite.com/wp-json/dmsi-api/v1/licenses \
-H "Authorization: Bearer dmsi_key_<your-40-hex-chars>"
Alternative method — X-API-Key header:
curl https://yoursite.com/wp-json/dmsi-api/v1/licenses \
-H "X-API-Key: dmsi_key_<your-40-hex-chars>"
Both headers are accepted. The Authorization: Bearer form is preferred for consistency with other token types.
What the Middleware Validates #
When an API key is presented, the middleware:
- Extracts the 12-character prefix from the submitted key
- Queries the
dmsi_aapi_keystable for rows matching that prefix - Bcrypt-verifies the submitted key against the stored hash (cost 12)
- Checks the key status is
active(not revoked or deleted) - Checks the key has not expired (if an expiry datetime is set)
- Enforces IP whitelist if configured (see Part 2 – API Keys, Doc 4: IP Whitelisting)
Permissions and Rate Limiting #
- The authenticated request inherits the scopes assigned to the key.
- The rate limit tier assigned to the key (or its override) applies to all requests made with that key.
Error Responses #
| Code | HTTP Status | Meaning |
|---|---|---|
api_key_invalid | 401 | Key not found or bcrypt verification failed |
api_key_expired | 401 | Key has passed its expiry datetime |
api_key_revoked | 401 | Key has been revoked |
ip_not_whitelisted | 403 | Request IP is not in the key’s IP whitelist |
insufficient_scope | 403 | Key lacks the required scope for the requested operation |
