Two auth tiers — User-facing endpoints (preview, create, get, list) use JWT Bearer. Admin endpoints (list all, update) require an
admin-api-key header.Overview
An insurance policy ties a primary user to an insurance-type benefit and a set of dependants to be covered. The SELF dependant (the primary user themselves) is always auto-included in the covered members — you do not need to add it manually todependant_ids. Premiums are calculated per member (including SELF) based on age and gender, stored in minor units (INR paise).
The purchase flow has two steps:
- Preview — compute the premium breakdown without creating a record
- Create — purchase the policy; status starts as
pending
metadata.dependant_mrn_map.
Activation (status → active) is done by an admin once the external insurer issues a policy number.
Purchase Flow
Auth Guards by Endpoint
| Endpoint | JWT user | Admin key | Notes |
|---|---|---|---|
POST /users/{id}/insurance_policies/preview | ✓ | — | Dependants must belong to the token user |
POST /users/{id}/insurance_policies | ✓ | — | One active policy per user+benefit |
GET /users/{id}/insurance_policies/{pid} | ✓ | — | Returns 404 for wrong user |
GET /users/{id}/insurance_policies | ✓ | — | Filters by status, benefit_id |
GET /insurance_policies | — | ✓ | Filter by user, benefit, status, time range |
PATCH /insurance_policies/{pid} | — | ✓ | Set status, external_policy_id, dates |
Key Concepts
Premium Calculation
Premiums are calculated per dependant based on age bracket and gender:| Age bracket | Monthly (INR) |
|---|---|
| 0–18 | ₹150 |
| 19–35 | ₹250 |
| 36–50 | ₹350 |
| 51–65 | ₹500 |
| 66+ | ₹650 |
Policy Status Lifecycle
Endpoints
POST .../preview
Preview the premium breakdown for a set of dependants without creating a policy.
POST .../insurance_policies
Purchase an insurance policy. Status starts as
pending.GET .../insurance_policies/{id}
Fetch a single policy by its internal UUID.
GET .../insurance_policies
List the authenticated user’s policies. Filter by
status or benefit_id.GET /insurance_policies (admin)
Admin: list all policies with full filtering including time range and user.
PATCH /insurance_policies/{id} (admin)
Admin: set status, external policy ID, start/end dates.
Request / Response Examples
The SELF dependant is always auto-included in
dependant_ids — you do not need to add it. The members array in the preview response and dependant_ids in the create response will both include SELF automatically.nominee_details — Tagged Union
The nominee_details field is a JSONB tagged union. Use one of two variants:
| Variant | Fields | Description |
|---|---|---|
dependant | type, dependant_id | Nominee is an existing dependant on the user’s profile |
external | type, name, relationship, date_of_birth, gender, phone | Nominee is a person not registered as a dependant |
Preview members Array
The preview response returns a unified members array of MemberDetail objects instead of separate primary_member and dependants fields:
| Field | Type | Description |
|---|---|---|
dependant_id | uuid | The dependant’s internal ID |
first_name | string | First name |
last_name | string | Last name |
salutation | string | Title (mr, mrs, ms, master) |
age | integer | Age computed from date of birth |
gender | string | male or female |
relationship | string | Relationship to the primary user (self, spouse, child, etc.) |
monthly_premium | Money | Per-member monthly premium in minor units |
MRN Auto-Creation
When a policy is created, the server automatically creates one MRN record per covered dependant at the benefit’s provider. Themetadata.dependant_mrn_map field maps each dependant ID to its newly created MRN ID.
Error Codes
| Code | HTTP | Description |
|---|---|---|
IP-1000 | 500 | Internal server error |
IP-1001 | 404 | Insurance policy not found |
IP-1002 | 404 | Benefit not found or inactive |
IP-1003 | 400 | Benefit is not of type insurance_policy |
IP-1004 | 400 | Benefit is missing a required insurance field |
IP-1005 | 404 | Dependant not found or inactive |
IP-1006 | 400 | Dependant does not belong to the requesting user |
IP-1007 | 404 | Nominee dependant not found or inactive |
IP-1008 | 409 | User already has an active policy for this benefit |
IP-1009 | 400 | Requested dependant count exceeds benefit’s max_dependants |
IP-1010 | 400 | Validation error |
IP-1011 | 400 | Invalid UUID in request |
IP-1012 | 403 | Forbidden |