# Mint a provider RTC token

Operation ID: `telehealth.createProviderToken`

Mint an Agora RTC token that lets the calling provider join the given `channel_id` as a publisher. The caller's Bearer JWT must resolve to the provider Cognito pool; a token from any other pool is rejected.

## Public method

`createProviderToken`

Signature: `telehealth.createProviderToken(request)`

Return type: `Promise<TelehealthTokenResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /telehealth/tokens/provider`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "channel_id": "hc-00000000000000000000000000000000",
  "uid": 1001
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`TelehealthToken`](../models/TelehealthToken.md) | application/json | Provider RTC token minted successfully |

## Success response examples

### 200

```json
{
  "app_id": "00000000000000000000000000000000",
  "channel_id": "hc-00000000000000000000000000000000",
  "expires_at": "2026-01-01T10:00:00Z",
  "role": "provider",
  "rtc_token": "EXAMPLE-AGORA-RTC-TOKEN-0000000000000000000000000000000000",
  "ttl_seconds": 3600,
  "uid": 1001
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`telehealth.ErrorResponse`](../models/telehealth.ErrorResponse.md) | application/json | The request body failed validation, or the Agora service is not configured |
| `401` | [`telehealth.ErrorResponse`](../models/telehealth.ErrorResponse.md) | application/json | Authentication required — missing or invalid Bearer JWT |
| `403` | [`telehealth.ErrorResponse`](../models/telehealth.ErrorResponse.md) | application/json | Authenticated caller is not from the provider Cognito pool |

## Error examples

### 400 — Agora credentials are not configured for this environment

```json
{
  "error": "AGORA_APP_ID and AGORA_APP_CERTIFICATE are required"
}
```

### 400 — The request body is missing a required field

```json
{
  "error": "1 validation error for CreateTelehealthTokenRequest\nchannel_id\n  Field required [type=missing, input_value={'uid': 1}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/missing"
}
```

### 401 — No Authorization header was supplied

```json
{
  "error": "Missing Authorization header"
}
```

### 403 — Caller authenticated from the patient pool instead of provider

```json
{
  "error": "Provider token requires provider pool type, got patient"
}
```

## NodeJS / TypeScript implementation

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

```ts
const request = {
  "channel_id": "hc-00000000000000000000000000000000",
  "uid": 1001
};

const result = await telehealth.createProviderToken(request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"channel_id":"hc-00000000000000000000000000000000","uid":1001}' \
  'https://dev-api-telehealth.health.cloud/telehealth/tokens/provider'
```

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