Auth guards vary by endpoint — Create, Update, and Delete are admin-only. Get and List accept both JWT users (active only) and the admin key.
Overview
A benefit is a specific offering — a free consultation session, an insurance policy, a diagnostic test — provided by a Benefit Provider. Benefits carry abenefit_type enum and a benefit_details JSONB object whose variant must match the type.
Responses always include provider_name via a JOIN, so callers never need a separate lookup to display who offers the benefit.
Benefit Types
benefit_type | benefit_details variant | Description |
|---|---|---|
consultation | Consultation { description } | Free or subsidised doctor consultation |
insurance_policy | InsurancePolicy { description } | Health or accident insurance |
benefit_type = consultation with InsurancePolicy details returns 400 BenefitTypeMismatch.
Visibility Rules
| Actor | Active benefits | Inactive benefits |
|---|---|---|
JWT user (active status) | ✓ visible | Hidden — returned as 404 |
| Admin key | ✓ visible | ✓ visible |
onboarding cannot call benefit endpoints — GET /benefits requires status = active.
Endpoints
POST /benefits
Admin only. Create a benefit. Provider must exist and be active. Name must be unique within that provider.
GET /benefits
List benefits. JWT users see only
active ones regardless of filters. Supports provider_id, benefit_type, status, pagination.GET /benefits/{benefit_id}
Fetch a benefit by UUID. JWT users receive 404 for inactive benefits.
PATCH /benefits/{benefit_id}
Admin only. Update
name, benefit_details, or status. All fields optional; omitting all is a no-op.DELETE /benefits/{benefit_id}
Admin only. Soft-delete a benefit (sets
status = inactive). No child-record check.Request / Response Examples
Error Codes
| Code | HTTP | Description |
|---|---|---|
BE_500 | 500 | Internal server error |
BE_501 | 404 | Benefit not found |
BE_502 | 409 | Name already exists for this provider |
BE_503 | 400 | benefit_type / benefit_details mismatch |
BE_504 | 404 | Benefit provider not found or inactive |
BE_505 | 400 | Validation error (e.g. empty name) |