# Retrieve a phone number

`GET https://api.morevoice.ai/v1/phone_numbers/{id}`

Returns a phone number: its E.164 form, where it comes from (`source`: a number of one of your SIP connections, a number provisioned through the platform, or a test-mode sandbox number), whether it answers inbound calls (and the route that answers them) and whether it can be the caller ID of outbound calls.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `phone_numbers_retrieve`.

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A phone number ID (`pn_…`). |

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |

## Responses

### 200 OK

OK Returns `PhoneNumber`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The number's ID (stable). |
| `object` | `"phone_number"` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `e164` | `string` | The number in E.164. |
| `country` | `string \| null` | ISO 3166-1 alpha-2, when known. |
| `source` | `"provisioned" \| "connection" \| "sandbox"` | `provisioned`: bought through the platform. `connection`: a number of your own SIP connection (its caller IDs and the numbers your inbound routes match). `sandbox`: a test-mode number. |
| `provider` | `string \| null` | The carrier of a provisioned number; null for your own connections. |
| `status` | `string` | `active`; provisioned numbers can also be `pending`, `pending_kyc`, `porting_in`, `suspended`, `releasing` or `released`. |
| `connection_id` | `string \| null` | `conn_…` ID. |
| `inbound_route_id` | `string \| null` | `rte_…` ID. |
| `label` | `string \| null` | — |
| `inbound` | `boolean` | Calls to the number are answered here (a route or connection matches it). |
| `outbound_caller_id` | `boolean` | The number can be presented as caller ID on outbound calls. |
| `created` | `string \| null` | When the number was added (null for numbers derived from a connection). |

Example:

```json
{
  "connection_id": "conn_2Wq8RfLx0bZt7nKp1VdYhC",
  "country": "IL",
  "created": null,
  "e164": "+97231234567",
  "id": "pn_3TzKk4u7Q0Yx9b2LmN8pQr",
  "inbound": true,
  "inbound_route_id": "rte_5Hn3MpO0qR5sT7uW9xY1zA",
  "label": "Main trunk",
  "livemode": true,
  "object": "phone_number",
  "outbound_caller_id": true,
  "provider": null,
  "source": "connection",
  "status": "active"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID (in the path or the body) exists in this organisation and mode. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const phoneNumber = await mv.phoneNumbers.retrieve("pn_7Hk2Lm9Qp");
console.log(phoneNumber);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

phone_number = client.phone_numbers.retrieve("pn_7Hk2Lm9Qp")
print(phone_number)
```

**cURL**

```sh
curl https://api.morevoice.ai/v1/phone_numbers/pn_7Hk2Lm9Qp \
  -H "Authorization: Bearer $MOREVOICE_API_KEY"
```
