mxHeadless
REST API gateway for headless frontends on MODX 3. Resources, objects, OpenAPI, API keys, and OAuth

Short-lived bearer tokens mxt_*. Disabled by default.
| Key | Default | Purpose |
|---|---|---|
mxheadless_oauth_enabled | false | POST /api/v1/auth/token |
mxheadless_oauth_token_ttl | 3600 | Access token TTL (seconds) |
mxheadless_oauth_password_grant_enabled | false | password grant |
php core/components/mxheadless/bin/oauth-client-create.php \
--client-id=next-preview \
--name='Next preview' \
--scopes=resources.read,preview \
--grants=client_credentialsThe secret is shown once. Tables: mxheadless_oauth_clients, mxheadless_oauth_tokens (hash).
curl -s -X POST https://example.com/api/v1/auth/token \
-H 'Content-Type: application/json' \
-d '{
"grant_type": "client_credentials",
"client_id": "next-preview",
"client_secret": "YOUR_CLIENT_SECRET",
"scope": "resources.read"
}'The response includes access_token (mxt_...), token_type, expires_in. Then:
curl -s https://example.com/api/v1/resources \
-H "Authorization: Bearer mxt_..."Supports application/json and application/x-www-form-urlencoded. For client credentials, HTTP Basic with client_id/client_secret is also allowed.
| Grant | When |
|---|---|
client_credentials | Machine-to-machine (default) |
password | Only if mxheadless_oauth_password_grant_enabled=true |
OAuth error: 400 invalid_grant.
| Credential | When |
|---|---|
mxh_* | CI, long-running workers, no refresh |
mxt_* | TTL, rotation without redeploying secrets in every service |
Both types pass the same scope checker. CSRF is not required.