Key rotation
Rotate API keys and OAuth client secrets on a schedule or after a suspected leak. mxHeadless stores hashes only. You cannot recover an old secret from the database.
API keys (mxh_*)
Format: mxh_{lookupId}_{secret}. In the database: lookup_id, secret_hash, scopes, and optional rate limits.
- Create a new key with the same or tighter scopes (API keys or Manager).
- Deploy the new secret to every consumer (CI, frontend server, integrations).
- Confirm traffic uses the new key (
last_used_onor audit log). - Revoke the old key (
revoked = 1).
Do not revoke until every caller has switched.
After revoke, Bearer with the old secret returns 401. Cached anonymous GET responses may live until mxheadless_cache_ttl. Lower TTL or disable cache during rotation.
OAuth clients (mxt_*)
When mxheadless_oauth_enabled=true:
- Create a new client via OAuth.
- Update services that call
POST /api/v1/auth/token. - Revoke the old client row.
Access tokens expire after mxheadless_oauth_token_ttl (default 3600 seconds). Changing the client secret blocks new token exchanges. Issued tokens live until expiry.
Webhook secrets
Secrets live in mxheadless_webhook_subscriptions.secret.
- Update the secret on the subscription.
- Update env on the subscriber (for example
MXHEADLESS_WEBHOOK_SECRET). - Run a test mutation and verify the signature.
Pending outbox rows store the secret snapshot at enqueue time.
