# Get a field agent photo

Operation ID: `fieldagent.getAgentPhoto`

Retrieve a field agent's photo as a FHIR Binary resource. If ?binary_id= is omitted, it is auto-resolved from the agent's stored photo_binary_id extension, then from a Binary search by security context — either resolution fails with 400 if the agent has never uploaded a photo via fieldagent.uploadAgentPhoto. Only the agent themselves may read their own photo.

## Public method

`getPhoto`

Signature: `fieldAgent.getPhoto(fhirPersonId, query)`

Return type: `Promise<GetPhotoResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /agents/{agent_id}/photo`

## Path parameters

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

## Query parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `binary_id` | `string` | Yes |  |  |  | No | Optional binary_id returned by upload_agent_photo. If omitted, the stored agent photo is used. |

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`GetAgentPhotoResponse`](../models/GetAgentPhotoResponse.md) | application/json | Field Agent photo |

## Success response examples

### 200

```json
{
  "binary_id": "photo-example-001",
  "content_type": "image/png",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No binary_id was supplied and none could be auto-resolved |
| `401` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `403` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | The authenticated caller does not own this agent profile |
| `404` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No FHIR Binary exists for the resolved binary_id |

## Error examples

### 400 — The agent has no stored photo and no binary_id was supplied

```json
{
  "error": "binary_id query parameter is required or the agent must already have a stored photo"
}
```

### 401 — Missing or invalid access token

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

### 403 — The JWT caller's cognito_sub does not match the agent's

```json
{
  "error": "You may only access your own agent profile"
}
```

### 404 — No FHIR Person exists for agent_id

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

### 404 — The FHIR Binary resource does not exist (sanitized example)

```json
{
  "error": "Not Found"
}
```

## NodeJS / TypeScript implementation

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

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

const query = {
  "binary_id": "<BINARY_ID>"
};

const result = await fieldAgent.getPhoto(fhirPersonId, query);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-fieldagent.health.cloud/agents/%3CAGENT_ID%3E/photo?binary_id=%3CBINARY_ID%3E'
```

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