# Upload a patient photo

Operation ID: `fieldagent.uploadPatientPhoto`

Store a base64-encoded photo, captured by the field agent, as a FHIR Binary resource for the patient, and stamp a photo_binary_id extension on the Patient resource. Reuses the same Binary + extension persistence pattern as POST /patients/photo on the Patient API, so photos uploaded here are visible through the same photo_binary_id field the Patient API and fieldagent.listPatients already return. Independent of fieldagent.patientPhotoUploadUrl's presigned-URL flow.

## Public method

`uploadPatientPhoto`

Signature: `fieldAgent.uploadPatientPhoto(patientId, request)`

Return type: `Promise<PhotoUploadResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/{patient_id}/photo`

## Path parameters

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

## Query parameters

None.

## Body parameters

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

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

## Request example

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

## Success responses

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

## Success response examples

### 201

```json
{
  "binary_id": "photo-example-002"
}
```

## Common errors

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

## Error examples

### 400 — Required body field is missing

```json
{
  "error": "data (base64) is required"
}
```

### 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 { PhotoUploadRequest } from "@healthcloudai/hc-sdk";
```

```ts
const patientId = "<PATIENT_ID>";

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

const result = await fieldAgent.uploadPatientPhoto(patientId, request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"content_type":"image/png","data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="}' \
  'https://dev-api-fieldagent.health.cloud/patients/%3CPATIENT_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.
