Skip to content
Documentation
Hevia for developers

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

EndpointPurpose
GET https://hevia.app/oauth/authorizeConsent screen (the person signs in to Hevia).
POST https://hevia.app/api/oauth/tokenExchange a code, refresh a token. Form-encoded.
POST https://hevia.app/api/oauth/revokeEnd a token (RFC 7009).
POST https://hevia.app/api/oauth/introspectIs a token active, with which scopes (RFC 7662).
https://hevia.app/.well-known/oauth-authorization-serverServer 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

Text
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.
  • state is required; check it when the person returns.
  • PKCE with S256 is 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/v1 or https://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

Shell
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)
JSON
{
  "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.

Note

Dynamic client registration (RFC 7591) is not offered. Every client is a registered developer app with a named publisher and fixed redirect URIs.

Generated from the product's own registries, so the reference matches the API.