# Refresh field-agent access tokens

Operation ID: `fieldagent.refreshToken`

Exchange a field-agent Cognito refresh token for new access/ID tokens. No Bearer JWT is required. tenant_id selects the tenant's field-agent pool; invalid tenants and invalid/expired refresh tokens intentionally return the same 401 response.

## Public method

`refreshToken`

Signature: `fieldAgent.refreshToken(request)`

Return type: `Promise<RefreshTokenResponse>`

## Authentication

Classification: **PUBLIC**

## Prerequisites

None documented.

## HTTP

`POST /auth/refresh`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "refresh_token": "example-refresh-token",
  "tenant_id": "tenant-example-001"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`fieldagent.RefreshTokenResponse`](../models/fieldagent.RefreshTokenResponse.md) | application/json | Refreshed field-agent tokens |

## Success response examples

### 200

```json
{
  "access_token": "example-access-token-refreshed",
  "expires_in": 3600,
  "id_token": "example-id-token-refreshed",
  "refresh_token": null,
  "token_type": "Bearer"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | tenant_id or refresh_token is missing |
| `401` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | The refresh token is invalid or expired |

## Error examples

### 400 — Required fields are missing

```json
{
  "error": "tenant_id and refresh_token are required"
}
```

### 401 — Refresh failed

```json
{
  "error": "Invalid or expired refresh token"
}
```

## NodeJS / TypeScript implementation

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

```ts
const request = {
  "refresh_token": "example-refresh-token",
  "tenant_id": "tenant-example-001"
};

const result = await fieldAgent.refreshToken(request);
```

## cURL

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"refresh_token":"example-refresh-token","tenant_id":"tenant-example-001"}' \
  'https://dev-api-fieldagent.health.cloud/auth/refresh'
```

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