Phone Number
List Phone Numbers
List phone numbers with filters and pagination.
POST
/
v2
/
list-phone-numbers
JavaScript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: process.env['RETELL_API_KEY'], // This is the default and can be omitted
});
const response = await client.phoneNumber.search();
console.log(response.has_more);import os
from retell import Retell
client = Retell(
api_key=os.environ.get("RETELL_API_KEY"), # This is the default and can be omitted
)
response = client.phone_number.search()
print(response.has_more)curl --request POST \
--url https://api.retellai.com/v2/list-phone-numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter_criteria": {
"query": "<string>",
"inbound_agents": [
{
"agent_id": "<string>",
"version": [
123
]
}
],
"outbound_agents": [
{
"agent_id": "<string>",
"version": [
123
]
}
]
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.retellai.com/v2/list-phone-numbers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filter_criteria' => [
'query' => '<string>',
'inbound_agents' => [
[
'agent_id' => '<string>',
'version' => [
123
]
]
],
'outbound_agents' => [
[
'agent_id' => '<string>',
'version' => [
123
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.retellai.com/v2/list-phone-numbers"
payload := strings.NewReader("{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.retellai.com/v2/list-phone-numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.retellai.com/v2/list-phone-numbers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"has_more": true,
"items": [
{
"phone_number": "+14157774444",
"phone_number_type": "retell-twilio",
"custom_sms_enabled": false,
"last_modification_timestamp": 1703413636133,
"phone_number_pretty": "+1 (415) 777-4444",
"allowed_inbound_country_list": [
"US",
"CA",
"GB"
],
"allowed_outbound_country_list": [
"US",
"CA"
],
"area_code": 415,
"sms_enabled": true,
"spam_status": "clean",
"spam_check_enabled": true,
"inbound_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"outbound_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"inbound_sms_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"outbound_sms_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"nickname": "Frontdesk Number",
"inbound_webhook_url": "https://example.com/inbound-webhook",
"inbound_sms_webhook_url": "https://example.com/inbound-sms-webhook",
"sip_outbound_trunk_config": {
"termination_uri": "someuri.pstn.twilio.com",
"auth_username": "username",
"transport": "TCP",
"codecs": [
"PCMU",
"PCMA",
"G.722"
]
},
"fallback_number": "+14155551234",
"inbound_fallback_enabled": false
}
],
"pagination_key": "<string>"
}{
"status": "error",
"message": "Invalid request format, please check API reference."
}{
"status": "error",
"message": "API key is missing or invalid."
}{
"status": "error",
"message": "Account rate limited, please throttle your requests."
}{
"status": "error",
"message": "An unexpected server error occurred."
}POST /v2/list-phone-numbers is the recommended way to list phone numbers. It takes the same limit, sort_order, and pagination_key query parameters as GET /v2/list-phone-numbers and returns the same response. It also accepts optional filter_criteria in the request body.GET /v2/list-phone-numbers still works, and Retell isn’t removing it soon. Don’t use it for new integrations. In the SDKs, phoneNumber.list() (Python: phone_number.list()) calls the GET, and phoneNumber.search() (Python: phone_number.search()) calls the POST.Authorizations
Query Parameters
Body
application/json
Was this page helpful?
⌘I
JavaScript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: process.env['RETELL_API_KEY'], // This is the default and can be omitted
});
const response = await client.phoneNumber.search();
console.log(response.has_more);import os
from retell import Retell
client = Retell(
api_key=os.environ.get("RETELL_API_KEY"), # This is the default and can be omitted
)
response = client.phone_number.search()
print(response.has_more)curl --request POST \
--url https://api.retellai.com/v2/list-phone-numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter_criteria": {
"query": "<string>",
"inbound_agents": [
{
"agent_id": "<string>",
"version": [
123
]
}
],
"outbound_agents": [
{
"agent_id": "<string>",
"version": [
123
]
}
]
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.retellai.com/v2/list-phone-numbers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'filter_criteria' => [
'query' => '<string>',
'inbound_agents' => [
[
'agent_id' => '<string>',
'version' => [
123
]
]
],
'outbound_agents' => [
[
'agent_id' => '<string>',
'version' => [
123
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.retellai.com/v2/list-phone-numbers"
payload := strings.NewReader("{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.retellai.com/v2/list-phone-numbers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.retellai.com/v2/list-phone-numbers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filter_criteria\": {\n \"query\": \"<string>\",\n \"inbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ],\n \"outbound_agents\": [\n {\n \"agent_id\": \"<string>\",\n \"version\": [\n 123\n ]\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"has_more": true,
"items": [
{
"phone_number": "+14157774444",
"phone_number_type": "retell-twilio",
"custom_sms_enabled": false,
"last_modification_timestamp": 1703413636133,
"phone_number_pretty": "+1 (415) 777-4444",
"allowed_inbound_country_list": [
"US",
"CA",
"GB"
],
"allowed_outbound_country_list": [
"US",
"CA"
],
"area_code": 415,
"sms_enabled": true,
"spam_status": "clean",
"spam_check_enabled": true,
"inbound_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"outbound_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"inbound_sms_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"outbound_sms_agents": [
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"weight": 0.5,
"agent_version": "latest_published"
}
],
"nickname": "Frontdesk Number",
"inbound_webhook_url": "https://example.com/inbound-webhook",
"inbound_sms_webhook_url": "https://example.com/inbound-sms-webhook",
"sip_outbound_trunk_config": {
"termination_uri": "someuri.pstn.twilio.com",
"auth_username": "username",
"transport": "TCP",
"codecs": [
"PCMU",
"PCMA",
"G.722"
]
},
"fallback_number": "+14155551234",
"inbound_fallback_enabled": false
}
],
"pagination_key": "<string>"
}{
"status": "error",
"message": "Invalid request format, please check API reference."
}{
"status": "error",
"message": "API key is missing or invalid."
}{
"status": "error",
"message": "Account rate limited, please throttle your requests."
}{
"status": "error",
"message": "An unexpected server error occurred."
}
