# List numbers you can buy

`GET https://api.morevoice.ai/v1/phone_numbers/available`

The numbers on offer to your organisation, in number order, with your monthly price (and a setup fee, if any). Buy one with `POST /v1/phone_numbers` and its `id` as `available_id` (or its `number`). Needs a live key, and number purchases enabled for the organisation (otherwise 403 `feature_unavailable`). An empty list means nothing matches right now.

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

Operation ID: `phone_numbers_list_available`.

## Parameters

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `country` | `string` | no | ISO 3166-1 alpha-2, e.g. `IL`. |
| `area_code` | `string` | no | Only numbers with this area code (`073`, `03`; the leading 0 is optional). |
| `contains` | `string` | no | Only numbers whose digits contain this sequence. |

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

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"list"` | — |
| `data` | `AvailablePhoneNumber[]` | — |
| `has_more` | `boolean` | Whether more objects follow in the requested direction. |
| `next_cursor` | `string \| null` | Pass as starting_after (or ending_before, when paging backwards) to continue; null on the last page. |
| `url` | `string` | The list's path. |

Example:

```json
{
  "data": [
    {
      "area_code": "03",
      "country": "IL",
      "e164": "+97231234567",
      "id": "avn_3bTYALgeKSjG4kJ3X",
      "monthly_price": {
        "amount": 800,
        "currency": "ILS"
      },
      "object": "available_phone_number",
      "setup_price": null,
      "type": "national"
    }
  ],
  "has_more": false,
  "next_cursor": null,
  "object": "list",
  "url": "/v1/phone_numbers/available"
}
```

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

for await (const phoneNumber of mv.phoneNumbers.listAvailable()) {
	console.log(phoneNumber);
}
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

for phone_number in client.phone_numbers.list_available():
    print(phone_number)
```

**cURL**

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