Auth guard: all endpoints require a first-party Keycloak OIDC bearer token (
Authorization: Bearer <token>). Provider CRUD is open to any trusted-backend actor (admin or benefit-provider, human or service); the credentials and dashboard-user sub-resources are scoped per provider (admin, or a benefit-provider human user belonging to that provider). No app-user (mobile JWT) path.Overview
A benefit provider is a company or entity (e.g. a diagnostic chain, insurer, or telemedicine platform) that offers one or more benefits to Aarokya users. Providers are the top-level catalogue entry — everyBenefit row has a provider_id FK referencing a provider.
- Name uniqueness is global. No two active providers may share the same name. Soft-deleted providers free their name immediately (status flips to
INACTIVE). - Delete is guarded. A provider with any associated benefit (active or inactive) cannot be deleted — soft-delete the benefits first.
- Each provider can mint machine credentials (Basic-auth tokens backed by a Keycloak service-account client) and provision dashboard users scoped to itself.
Data Flow
Auth Guards by Endpoint
Provider Endpoints
POST /benefit_providers
Create a provider. Requires
name (globally unique) and a URL-safe slug.GET /benefit_providers
Paginated list. Filter by
status; supports sort_on/sort_by, start_time/end_time, limit/offset.GET /benefit_providers/{id}
Fetch a single provider by UUID.
PATCH /benefit_providers/{id}
Rename a provider. Only
name is updatable; slug is immutable. New name must not conflict.DELETE /benefit_providers/{id}
Soft-delete (
status → INACTIVE). Fails with 409 if the provider has benefits.slug is a lowercase URL/Keycloak-safe identifier ([a-z0-9-], 2–40 chars) used as part of the service-account clientId. It is set at creation and is immutable thereafter.Credentials Sub-resource
Each provider can hold multiple machine credentials. A credential is a Keycloak service-account client returning abasic_token (HTTP Basic auth) the provider’s backend uses to call Aarokya.
POST /benefit_providers/{id}/credentials
Mint a new credential. The
basic_token is returned once and is never retrievable afterwards.GET /benefit_providers/{id}/credentials
List
credential_ids for this provider. Never returns secrets.DELETE /benefit_providers/{id}/credentials/{credential_id}
Revoke one credential. Idempotent:
revoked: false if no such credential existed.Dashboard Users Sub-resource
Provision human dashboard users scoped to a single provider.POST /benefit_providers/{id}/users
Provision a dashboard user (
email, first_name, last_name). The temporary_password is shown once.GET /benefit_providers/{id}/users
List dashboard users scoped to this provider.
DELETE /benefit_providers/{id}/users/{keycloak_user_id}
Disable a dashboard user. Idempotent:
disabled: false if no matching user.