# Get a field agent profile

Operation ID: `fieldagent.getAgent`

Get a field agent's profile by FHIR Person ID. Only the agent themselves may access it — the JWT caller's cognito_sub must match the record's stored cognito_sub, or the request is rejected.

## Public method

`getAgent`

Signature: `fieldAgent.getAgent(fhirPersonId)`

Return type: `Promise<FieldAgentResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /agents/{agent_id}`

## Path parameters

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

## Query parameters

None.

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`FieldAgentProfileResponse`](../models/FieldAgentProfileResponse.md) | application/json | Field-agent profile |

## Success response examples

### 200

```json
{
  "address": {
    "city": "Springfield",
    "country": "US",
    "is_primary": true,
    "state": "IL",
    "street1": "100 Health Avenue",
    "street2": "Suite 200",
    "type": "work",
    "zip_code": "62701"
  },
  "agent_id": "agent-example-001"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `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 agent profile exists for the given agent_id |

## Error examples

### 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"
}
```

## NodeJS / TypeScript implementation

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

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

const result = await fieldAgent.getAgent(fhirPersonId);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-fieldagent.health.cloud/agents/%3CAGENT_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.
