> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 列出电话号码页

GET https://api.elevenlabs.io/v1/convai/v2/phone-numbers

获取一页电话号码。

Reference: https://elevenlabs.io/docs/api-reference/phone-numbers/list-v-2

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Query parameters

- `page_size` (integer, optional, default: 100) — 每页电话号码数量
- `search` (string, optional, nullable) — 按电话号码 ID、标签或电话号码筛选。电话号码 ID 必须精确匹配；标签和电话号码支持不区分大小写的子字符串匹配。
- `label` (string, optional, nullable) — 按标签筛选。匹配不区分大小写，且支持子字符串匹配。
- `phone_number` (string, optional, nullable) — 按电话号码筛选
- `provider` (enum, optional, nullable) — 按电话服务提供商筛选
  - Allowed values: `twilio`, `sip_trunk`, `exotel`
- `supports_outbound` (boolean, optional, nullable) — 按电话号码是否可拨打外呼电话筛选
- `agent_id` (string, optional, nullable) — 按分配的智能体 ID 筛选
- `branch_id` (string, optional, nullable) — 按分配的分支 ID 筛选
- `sort_by` (enum, optional, nullable) — 用于排序结果的字段
  - Allowed values: `label`, `phone_number`
- `sort_direction` (enum, optional) — 结果排序方向
  - Allowed values: `asc`, `desc`
- `cursor` (string, optional, nullable) — 用于获取下一页。响应中会返回游标。

## Response

### 200

成功响应

- `phone_numbers` (list of GetPhoneNumbersPageResponseModelPhoneNumbersItems, required) — 此页面上的电话号码
- `next_cursor` (string, optional, nullable) — 将此值作为 `cursor` 传递以获取下一页。没有更多结果时为 Null。
- `has_more` (boolean, optional, default: false) — 是否还有更多可用结果

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### GetPhoneNumbersPageResponseModelPhoneNumbersItems

- `provider`: `exotel` (GetPhoneNumberExotelResponseModel)
  - `label` (string, required) — 电话号码标签
  - `phone_number` (string, required) — 电话号码
  - `phone_number_id` (string, required) — 电话号码的 ID
  - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 分配给该电话号码的智能体
  - `supports_inbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼入电话。
  - `supports_outbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼出电话。
- `provider`: `sip_trunk` (GetPhoneNumberSIPTrunkResponseModel)
  - `label` (string, required) — 电话号码标签
  - `livekit_stack` (enum, required, default: standard) — 此号码使用的 Livekit 栈类型。
    - Allowed values: `standard`, `static`
  - `phone_number` (string, required) — 电话号码
  - `phone_number_id` (string, required) — 电话号码的 ID
  - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 分配给该电话号码的智能体
  - `inbound_trunk` (GetPhoneNumberInboundSIPTrunkConfigResponseModel, optional, nullable) — Configuration of the Inbound SIP trunk - if configured.
  - `outbound_trunk` (GetPhoneNumberOutboundSIPTrunkConfigResponseModel, optional, nullable) — Configuration of the Outbound SIP trunk - if configured.
  - `store_sip_messages` (boolean, optional, default: true) — 是否存储此电话号码的 SIP 消息。
  - `provider_config` (GetPhoneNumberOutboundSIPTrunkConfigResponseModel, optional, nullable, deprecated) — 电话号码的 SIP 中继配置详情
  - `supports_inbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼入电话。
  - `supports_outbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼出电话。
- `provider`: `twilio` (GetPhoneNumberTwilioResponseModel)
  - `label` (string, required) — 电话号码标签
  - `phone_number` (string, required) — 电话号码
  - `phone_number_id` (string, required) — 电话号码的 ID
  - `assigned_agent` (PhoneNumberAgentInfo, optional, nullable) — 分配给该电话号码的智能体
  - `supports_inbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼入电话。
  - `supports_outbound` (boolean, optional, default: true, deprecated) — 此字段已弃用，将在未来移除。此电话号码是否支持呼出电话。

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### PhoneNumberAgentInfo

- `agent_id` (string, required) — 智能体 ID
- `agent_name` (string, required) — 智能体名称
- `environment` (string, optional, nullable) — 调用此号码时用于解析环境变量的环境。
- `branch_id` (string, optional, nullable) — 呼叫此号码时使用的智能体分支。

### GetPhoneNumberInboundSIPTrunkConfigResponseModel

- `allowed_addresses` (list of string, required) — 允许使用中继的 IP 地址列表。列表中的每项可以是单个 IP 地址，或表示 CIDR 块的无类别域间路由表示法。
- `allowed_numbers` (list of string, required, nullable) — 允许使用中继的电话号码列表。
- `media_encryption` (enum, required, default: allowed)
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — 是否已配置身份验证凭据
- `username` (string, optional, nullable) — SIP 中继用户名（如有）
- `remote_domains` (list of string, optional, nullable) — 用于验证 TLS 证书的远程 SIP 服务器域名。
- `attributes_to_headers` (map from string to string, optional) — 用于 attributes_to_headers 的动态变量名称到请求头名称的映射

### GetPhoneNumberOutboundSIPTrunkConfigResponseModel

电话号码的 SIP 中继配置详情

- `address` (string, required) — 发送 SIP INVITE 的主机名或 IP
- `transport` (enum, required, default: auto) — 用于 SIP 传输的协议
  - Allowed values: `auto`, `udp`, `tcp`, `tls`
- `media_encryption` (enum, required, default: allowed) — 是否加密媒体数据（数据层）。
  - Allowed values: `disabled`, `allowed`, `required`
- `has_auth_credentials` (boolean, required) — 是否已配置身份验证凭据
- `headers` (map from string to string, optional) — INVITE 请求的 SIP 标头
- `attributes_to_headers` (map from string to string, optional) — 用于 attributes_to_headers 的动态变量名称到请求头名称的映射
- `username` (string, optional, nullable) — SIP 中继用户名（如有）
- `has_outbound_trunk` (boolean, optional, default: false) — 是否已配置 LiveKit SIP 出站中继
- `enabled_codecs` (list of enum, optional) — 外呼 SDP 中提供的媒体编解码器。为空时，将提供所有支持的编解码器。
  - Allowed values: `G722/8000`, `PCMU/8000`, `PCMA/8000`

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "phone_numbers": [
    {
      "provider": "twilio",
      "label": "Customer Support",
      "phone_number": "+1234567890",
      "phone_number_id": "phone_123"
    }
  ],
  "next_cursor": "string",
  "has_more": false
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/v2/phone-numbers"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/v2/phone-numbers';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/v2/phone-numbers"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/v2/phone-numbers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/v2/phone-numbers")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/v2/phone-numbers');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/v2/phone-numbers");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/v2/phone-numbers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```