# Compare a selfie to the stored reference photo

Operation ID: `patient.faceMatch`

Compare a submitted selfie against a stored FHIR Binary photo via AWS Rekognition CompareFaces. Requires a patient Bearer JWT.

## Public method

`compareFaceMatch`

Signature: `patient.compareFaceMatch(request)`

Return type: `Promise<FaceMatchResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/face-match`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "reference_binary_id": "0e4a51dd-93ec-4f72-a6a2-018036ae326d",
  "selfie_data": "c3ludGhldGljLXNlbGZpZQ==",
  "similarity_threshold": 80
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`FaceMatchResponse`](../models/FaceMatchResponse.md) | application/json | Face comparison result |

## Success response examples

### 200

```json
{
  "confidence": 100,
  "face_detected_in_selfie": true,
  "match": true,
  "similarity_threshold": 80
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | selfie_data or reference_binary_id is missing |
| `401` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `404` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The reference photo Binary has no data |
| `500` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Internal server error |

## Error examples

### 400 — Required fields are missing

```json
{
  "error": "selfie_data and reference_binary_id are required"
}
```

### 401 — Missing or invalid access token

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

### 404 — The reference photo could not be read

```json
{
  "error": "Reference photo has no data"
}
```

### 500 — Unexpected service failure (sanitized example)

```json
{
  "error": "Internal server error"
}
```

## NodeJS / TypeScript implementation

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

```ts
const request = {
  "reference_binary_id": "0e4a51dd-93ec-4f72-a6a2-018036ae326d",
  "selfie_data": "c3ludGhldGljLXNlbGZpZQ==",
  "similarity_threshold": 80
};

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

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"reference_binary_id":"0e4a51dd-93ec-4f72-a6a2-018036ae326d","selfie_data":"c3ludGhldGljLXNlbGZpZQ==","similarity_threshold":80}' \
  'https://dev-api-patient.health.cloud/patients/face-match'
```

## 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.
