# Upload a person photo

Operation ID: `person.uploadPhoto`

Store a base64-encoded photo as a FHIR Binary resource for the person, and stamp a photo_binary_id extension on their Person resource so person.getPhoto can find it without a binary_id. Independent of person.getPhotoUploadUrl's presigned-URL flow.

## Public method

`uploadPhoto`

Signature: `person.uploadPhoto(fhirPersonId, request)`

Return type: `Promise<UploadPersonPhotoResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /persons/{person_id}/photo`

## Path parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `person_id` | `string` | Yes |  |  |  | No |  |

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "content_type": "image/jpeg",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
  "photo": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`person.UploadPhotoResponse`](../models/person.UploadPhotoResponse.md) | application/json | Person photo stored |

## Success response examples

### 201

```json
{
  "binary_id": "photo-example-001",
  "content_type": "image/jpeg"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`person.ErrorResponse`](../models/person.ErrorResponse.md) | application/json | The base64 photo data was not supplied |
| `401` | [`person.ErrorResponse`](../models/person.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `500` | [`person.ErrorResponse`](../models/person.ErrorResponse.md) | application/json | Internal server error |

## Error examples

### 400 — Required body field is missing

```json
{
  "error": "Missing photo data (base64)"
}
```

### 401 — Missing or invalid access token

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

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

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

## NodeJS / TypeScript implementation

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

```ts
const fhirPersonId = "<FHIR_PERSON_ID>";

const request = {
  "content_type": "image/jpeg",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
  "photo": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
};

const result = await person.uploadPhoto(fhirPersonId, request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"content_type":"image/jpeg","data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==","photo":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="}' \
  'https://dev-api-person.health.cloud/persons/%3CPERSON_ID%3E/photo'
```

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