# Add insurance coverage

Operation ID: `patient.addInsurance`

Create a new FHIR Coverage resource for the authenticated patient. Requires a patient Bearer JWT.

## Public method

`createInsurance`

Signature: `patient.createInsurance(request)`

Return type: `Promise<CreateInsuranceResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/insurance`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`AddInsuranceRequest`](../models/AddInsuranceRequest.md) | Yes |  |  |  | No |  |

Request model: [`AddInsuranceRequest`](../models/AddInsuranceRequest.md)

## Request example

```json
{
  "member_id": "string",
  "payer_id": "string",
  "payer_name": "string",
  "priority": "primary",
  "relationship": "self",
  "state": "string"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`AddInsuranceResponse`](../models/AddInsuranceResponse.md) | application/json | Coverage created |

## Success response examples

### 201

```json
{
  "athena_best_match": {},
  "athena_insurance_error": "string",
  "athena_insurance_status": "string",
  "coverages_created": 0,
  "fhir_patient_id": "string",
  "openloop_best_match": {},
  "openloop_insurance_error": "string",
  "openloop_insurance_status": "string",
  "patient_id": "string"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Bad request — required fields missing or FHIR rejected the coverage |
| `401` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Authorization required — missing, invalid, expired, or non-patient Bearer JWT |
| `404` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The authenticated patient has no FHIR Patient record |

## Error examples

### 400 — Required insurance fields are missing

```json
{
  "error": "'payer_name'"
}
```

### 401 — Missing or invalid access token

```json
{
  "error": "Authorization required"
}
```

### 404 — Patient not found

```json
{
  "error": "Patient not found"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { CreateInsuranceRequest } from "@healthcloudai/hc-sdk";
```

```ts
const request = {
  "member_id": "string",
  "payer_id": "string",
  "payer_name": "string",
  "priority": "primary",
  "relationship": "self",
  "state": "string"
};

const result = await patient.createInsurance(request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"member_id":"string","payer_id":"string","payer_name":"string","priority":"primary","relationship":"self","state":"string"}' \
  'https://dev-api-patient.health.cloud/patients/insurance'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
