Skip to content

Issue an access token

Request

OAuth 2.0 token endpoint (RFC 6749). Supports three grants:

  • authorization_code — exchange a code obtained from the browser GET /oauth/authorize flow (PKCE code_verifier required). Returns an access token and a rotating refresh token.
  • client_credentials — machine-to-machine token for a marketplace application. With location_id it is an installation token: the installation is resolved from the authenticated OAuth client plus that Location and must be active. Without location_id it is an application token: no scopes, only the application's own /marketplace_apps/{marketplace_app_id}/installations routes. No refresh token is returned.
  • refresh_token — rotate a refresh token from the Authorization Code flow. The previous refresh token is invalidated; replaying it revokes the token family. The new access token never exceeds the scopes of the original consent: scope may narrow it, unknown codes are ignored, and invalid_scope is returned when every known scope in scope is outside the consent (the refresh token is not rotated then). The same rule applies to scope on the code exchange. A refresh token lives 30 days from its issue, the family 90 days from the code exchange; after that the user approves access again.

Confidential clients authenticate with HTTP Basic (client_secret_basic) or send client_id and client_secret in the form body (client_secret_post); public clients (PKCE-only) send their client_id in the form body. There is no password grant.

Errors from this endpoint use the standard OAuth 2.0 error object ({"error": "...", "error_description": "..."}), not application/problem+json.

Bodyapplication/x-www-form-urlencodedrequired
One of:

Token request (RFC 6749, form-encoded). resource selects REST vs MCP token audience (RFC 8707).

grant_typestringrequired
Value:"authorization_code"
codestringrequired
code_verifierstringrequired
client_idstringrequired
redirect_uristring

Optional (OAuth 2.1 §10.2): PKCE already binds the code to the client. If sent, it must equal the redirect_uri of the authorization request byte for byte.

client_secretstring

Confidential clients using client_secret_post only.

scopestring
resourcestring, (uri)

RFC 8707 resource indicator: https://api.alteg.io/api/v3 or an Altegio MCP address under https://mcp.alteg.io/pro (an address ending in /readonly caps the scopes at read-only). Compared case-insensitively on scheme and host and without a trailing slash. Every accepted address yields the same audience https://api.alteg.io/api/v3; on code exchange it must equal the resource of the authorization request.

curl -i -X POST \
  https://developer.alteg.io/_mock/en/b2b-v3/openapi/oauth/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode grant_type=client_credentials \
  --data-urlencode location_id=90211 \
  --data-urlencode 'scope=appointments:read appointments:create clients:read'

Responses

Token issued.

Bodyapplication/json
access_tokenstringrequired

Opaque access token — never parse it.

token_typestringrequired
Value:"Bearer"
expires_inintegerrequired

Access token lifetime in seconds (3600).

refresh_tokenstring

Rotating refresh token; only issued by the Authorization Code flow.

scopestring

Space-separated scopes carried by the token.

Response
{ "access_token": "ag_at_7f3a1c9e0b2d4f68a1c9e0b2", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "ag_rt_5b8e2d4f68a1c9e0b2d4f68a", "scope": "appointments:read appointments:create clients:read" }