Authentication
Every Revolution API call — REST, SignalR, MQTT — needs a bearer token tied to a real user in a real tenant. We use OAuth 2.0 with PKCE; there are no API keys.
Quickstart
Section titled “Quickstart”-
Register your client in the Revolution admin → API clients.
-
Send the user to the authorization endpoint with a PKCE challenge.
-
Exchange the returned
codefor an access token. -
Send the token as a bearer header on every subsequent request.
Token exchange
Section titled “Token exchange”Once the user has authorized, your callback receives ?code=…&state=…. Exchange the code:
curl -X POST https://api.revolution.io/v1/auth/token \ -H "Content-Type: application/json" \ -d '{ "code": "<auth-code>", "code_verifier": "<pkce-verifier>", "client_id": "<your-client-id>", "redirect_uri": "https://your.app/callback" }'import httpx
resp = httpx.post( "https://api.revolution.io/v1/auth/token", json={ "code": auth_code, "code_verifier": pkce_verifier, "client_id": CLIENT_ID, "redirect_uri": "https://your.app/callback", },)resp.raise_for_status()token = resp.json()["access_token"]const resp = await fetch("https://api.revolution.io/v1/auth/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code: authCode, code_verifier: pkceVerifier, client_id: CLIENT_ID, redirect_uri: "https://your.app/callback", }),});const { access_token } = await resp.json();Calling the API
Section titled “Calling the API”Pass the token in the Authorization header.
curl https://api.revolution.io/v1/devices \ -H "Authorization: Bearer $TOKEN"import httpx
client = httpx.Client( base_url="https://api.revolution.io/v1", headers={"Authorization": f"Bearer {token}"},)devices = client.get("/devices").json()const devices = await fetch("https://api.revolution.io/v1/devices", { headers: { Authorization: `Bearer ${token}` },}).then((r) => r.json());Token lifetime
Section titled “Token lifetime”Access tokens are short-lived (1 hour by default). Use the refresh_token returned by the exchange to mint a new one without re-prompting the user.
Client-credentials flow
Section titled “Client-credentials flow”For machine-to-machine integrations (CI bots, scheduled jobs, internal services), use the client-credentials flow instead of PKCE.
curl -X POST https://api.revolution.io/v1/auth/token \ -H "Content-Type: application/json" \ -d '{ "grant_type": "client_credentials", "client_id": "<service-client-id>", "client_secret": "<service-client-secret>" }'The returned token is scoped to the service account’s role in your tenant. Create a service account with least-privilege roles in Revolution admin → Service accounts.