Authentication
The API uses OAuth 2.0 client credentials (RFC 6749, section 4.4). Your server exchanges its client ID and secret for a short-lived access token, then sends the token with each request.
Get an access token
curl -X POST https://api.staging.agantia.com/api/public/v1/oauth/token \
-u "$AGANTIA_CLIENT_ID:$AGANTIA_CLIENT_SECRET" \
-d grant_type=client_credentials
You can also send client_id and client_secret in the form body or as JSON, instead of HTTP Basic.
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 600,
"scope": "catalogues:read products:read bookings:create"
}
To get a token with fewer permissions, pass scope as a space-separated list: -d "scope=products:read availability:read". Without scope, the token gets every permission the app has.
Use the token
curl https://api.staging.agantia.com/api/public/v1/products \
-H "Authorization: Bearer $ACCESS_TOKEN"
Tokens last 10 minutes. Cache the token and request a new one shortly before expires_in runs out. Do not request a token for every API call: token requests have their own rate limit.
Token errors
The token endpoint returns OAuth errors (RFC 6749, section 5.2):
| Status | error | Meaning |
|---|---|---|
| 400 | unsupported_grant_type | Only client_credentials is supported. |
| 400 | invalid_scope | You asked for a scope the app does not have. |
| 401 | invalid_client | Wrong ID or secret, a revoked or expired credential, a disabled app, or a credential from the other environment. |
| 429 | slow_down | Too many token requests. Wait for Retry-After seconds. |
Permissions take effect at once
The token says which permissions it was issued with, but every request is checked against the app's current settings. When an administrator disables the app, revokes the credential, removes a permission, or changes data access, your existing tokens follow the change within seconds.
Verifying tokens yourself
You do not need to. If you want to, the signing keys are published per environment at /api/public/v1/.well-known/jwks.json. Tokens are RS256 JWTs.