OAuth 2.0 and PKCE
Let other businesses connect your app with one consent screen: authorization code with PKCE (S256).
OAuth lets an app act on a business without ever seeing an API key. The owner or an admin of that business allows the app once on a consent screen that lists the requested scopes in plain language. The app then holds a short-lived access token and a rotating refresh token. A step-by-step walk-through is in the guide Build an app with OAuth.
Endpoints
| Endpoint | Purpose |
|---|---|
GET https://hevia.app/oauth/authorize | Consent screen (the person signs in to Hevia). |
POST https://hevia.app/api/oauth/token | Exchange a code, refresh a token. Form-encoded. |
POST https://hevia.app/api/oauth/revoke | End a token (RFC 7009). |
POST https://hevia.app/api/oauth/introspect | Is a token active, with which scopes (RFC 7662). |
https://hevia.app/.well-known/oauth-authorization-server | Server metadata (RFC 8414). |
1. Register the app and the client
Register the app manifest (dashboard, page API, tab Apps) with oauthRedirectUris and the scopes the app may ever ask for (at most 20 scopes and 5 redirect URIs). Then create the OAuth client: public (browser or mobile app, no secret) or confidential (server; the client secret hs_… is shown once). Client ids start with hc_.
2. Send the person to the authorize URL
https://hevia.app/oauth/authorize?response_type=code
&client_id=hc_...
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
&scope=deals%3Aread%20contacts%3Aread
&state=<random, required>
&code_challenge=<base64url(SHA-256(verifier))>
&code_challenge_method=S256- The redirect URI must match a registered one exactly. Otherwise the person sees an error page and nothing is redirected.
stateis required; check it when the person returns.- PKCE with
S256is required for every client, also confidential ones. - The scope must be a subset of the manifest scopes.
- Optional
resource(RFC 8707):https://hevia.app/api/v1orhttps://hevia.app/api/mcp. MCP clients must send the MCP URL.
The consent screen is valid 10 minutes. After consent Hevia redirects with code and state (or error=access_denied). A code is valid 60 seconds and works once; a second use revokes the access created from it.
3. Exchange the code
curl -X POST https://hevia.app/api/oauth/token \
-d grant_type=authorization_code \
-d code=hcode_... \
-d redirect_uri=https://app.example.com/callback \
-d client_id=hc_... \
-d code_verifier=<verifier>
# confidential clients add -d client_secret=hs_... (or HTTP Basic){
"access_token": "hv_live_...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "hr_...",
"scope": "deals:read contacts:read",
"hevia_business": "<business id>"
}The access token works exactly like an API key on /api/v1 and /api/mcp: same scopes, rate limits, package check, audit trail and version pin. See Token lifetime for refresh.
Errors
Token endpoint errors follow RFC 6749: invalid_request, invalid_client, invalid_grant, invalid_scope, invalid_target, unsupported_grant_type, with error_description.
Dynamic client registration (RFC 7591) is not offered. Every client is a registered developer app with a named publisher and fixed redirect URIs.