Skip to content

Authentication

Estia API runs on Keycloak (OAuth 2.0 / OIDC). Your backend gets a JWT via the client_credentials flow and sends it on every call.

Flow overview

sequenceDiagram
    participant App as Your backend
    participant KC as Keycloak
    participant API as Estia API

    App->>KC: POST /token<br/>grant_type=client_credentials<br/>client_id + client_secret
    KC-->>App: access_token, expires_in
    App->>API: Request with Authorization: Bearer <token>
    API->>API: Validate signature, issuer, audience, expiry
    API-->>App: Response payload

Why client_credentials

Machine-to-machine integration. No end-user login, so client_credentials is the right flow for server-side calls, scheduled jobs, and internal services.

Get a token

curl -X POST "https://auth.insurancegateway.gr/realms/estia/protocol/openid-connect/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=<your-client-id>" \
  -d "client_secret=<your-client-secret>"

Response:

{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "not-before-policy": 0,
  "scope": "openid profile"
}

Token lifetime

Usually 5 minutes to 1 hour — depends on the environment.

In client_credentials flow there's no refresh_token. When it's near expiry, request a new one.

In practice:

  • cache the token in your service layer
  • refresh a few minutes before expiry
  • don't refresh on every request

This keeps Keycloak traffic low and avoids edge cases with tokens expiring mid-flight.

JWT claims worth knowing

Claim What it is
sub Service-account user ID
azp Your client_id — useful for auditing/per-client limits
iss https://auth.insurancegateway.gr/realms/estia
aud estia-api
exp Expiry
iat Issued at
scope Granted scopes

Insurer accounts per client

Every client (every client_id) uses its own insurer accounts. Your calls to an insurer always use the credentials configured for your own client_id — there is no shared set and another client's credentials are never used.

If no credentials have been configured yet for the insurer you call, for your client, you get:

  • 403 Forbidden with category: "client_credentials_missing" (title "Client credentials missing"), and provider and clientId in the response.

Contact us so we can set up that insurer's credentials for your client. See the Error reference.

What the API checks

  1. JWT signature
  2. Issuer
  3. Audience
  4. Expiry
  5. not before, when present

Any failure → 401 Unauthorized.

Common auth failures

HTTP What it means What to check
401 Unauthorized Token missing, expired, or invalid Fresh token, correct header
401 invalid_token Signature/issuer/audience mismatch Realm config, token source
403 Forbidden Token OK but missing permission Contact us about roles/scopes
403 with category: "client_credentials_missing" No credentials configured for that insurer for your client Contact us to set them up

Implementation tip

Most common mistake: a new token on every call. Build token caching from day one.

Working examples in Code samples.

Docs use a different login

Browser login for Scalar is separate — only for browsing the spec. Your integration keeps using the service-account credentials.