# Update a practitioner's phone number

Operation ID: `provider.updatePhone`

Update the phone number on both Cognito (for the authenticated caller) and the FHIR Practitioner identified by {practitioner_id}, then send an SMS OTP to the new number. Call provider.verifySms with the OTP to confirm it. Note: {practitioner_id} is not verified to belong to the authenticated caller — the Cognito phone update always targets the JWT subject, while the FHIR update targets {practitioner_id} directly.

## Public method

`updatePhone`

Signature: `provider.updatePhone(fhirPractitionerId, request)`

Return type: `Promise<PhoneUpdateResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /practitioners/{practitioner_id}/phone`

## Path parameters

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

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "phone": "+15550100001"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`provider.UpdatePhoneResponse`](../models/provider.UpdatePhoneResponse.md) | application/json | OTP sent to the new phone number |

## Success response examples

### 200

```json
{
  "sms_otp_sent": true
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`provider.ErrorResponse`](../models/provider.ErrorResponse.md) | application/json | phone was not supplied, is not a dialable number, or the update/OTP dispatch was rejected because of it |
| `401` | [`provider.ErrorResponse`](../models/provider.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `502` | [`provider.ErrorResponse`](../models/provider.ErrorResponse.md) | application/json | The SMS provider could not be reached or rejected our credentials. The phone number itself was accepted; this is a server-side fault, so the request may be retried unchanged. |

## Error examples

### 400 — Not E.164 format

```json
{
  "error": "phone: 'abc-def-ghij' is not a valid phone number. Expected E.164 format (e.g. +12065551234)"
}
```

### 400 — Required field is missing

```json
{
  "error": "phone is required"
}
```

### 400 — The number is well-formed but the SMS provider will not deliver to it

```json
{
  "error": "Twilio error 21614: 'To' number is not a valid mobile number"
}
```

### 400 — Correct length and E.164, but not a dialable US/Canada number

```json
{
  "error": "phone: '+11234123412' is not a dialable US/Canada number — the area code and exchange code must each start with 2-9 and must not be a service code like 411 (e.g. +12065551234)"
}
```

### 401 — Missing or invalid access token

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

### 502 — Our SMS provider credentials are invalid or expired

```json
{
  "error": "Twilio error 20003: Authentication Error - invalid username"
}
```

### 502 — The SMS provider returned a server error

```json
{
  "error": "Twilio error: Internal Server Error"
}
```

## NodeJS / TypeScript implementation

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

```ts
const fhirPractitionerId = "<FHIR_PRACTITIONER_ID>";

const request = {
  "phone": "+15550100001"
};

const result = await provider.updatePhone(fhirPractitionerId, request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"phone":"+15550100001"}' \
  'https://dev-api-provider.health.cloud/practitioners/%3CPRACTITIONER_ID%3E/phone'
```

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