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 phoneNumbers = await client.phoneNumber.list();
console.log(phoneNumbers.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
)
phone_numbers = client.phone_number.list()
print(phone_numbers.has_more)curl --request GET \
--url https://api.retellai.com/v2/list-phone-numbers \
--header 'Authorization: Bearer <token>'<?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 => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.retellai.com/v2/list-phone-numbers"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.retellai.com/v2/list-phone-numbers")
.header("Authorization", "Bearer <token>")
.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::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"pagination_key": "<string>",
"has_more": true,
"items": [
{
"phone_number": "+14157774444",
"phone_number_type": "retell-twilio",
"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,
"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"
},
"fallback_number": "+14155551234"
}
]
}{
"status": "error",
"message": "API key is missing or invalid."
}{
"status": "error",
"message": "An unexpected server error occurred."
}Phone Number
List Phone Numbers
List phone numbers with pagination
GET
/
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 phoneNumbers = await client.phoneNumber.list();
console.log(phoneNumbers.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
)
phone_numbers = client.phone_number.list()
print(phone_numbers.has_more)curl --request GET \
--url https://api.retellai.com/v2/list-phone-numbers \
--header 'Authorization: Bearer <token>'<?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 => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.retellai.com/v2/list-phone-numbers"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.retellai.com/v2/list-phone-numbers")
.header("Authorization", "Bearer <token>")
.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::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"pagination_key": "<string>",
"has_more": true,
"items": [
{
"phone_number": "+14157774444",
"phone_number_type": "retell-twilio",
"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,
"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"
},
"fallback_number": "+14155551234"
}
]
}{
"status": "error",
"message": "API key is missing or invalid."
}{
"status": "error",
"message": "An unexpected server error occurred."
}Authorizations
Authentication header containing API key (find it in dashboard). The format is "Bearer YOUR_API_KEY"
Query Parameters
Maximum number of items to return.
Required range:
x <= 1000Sort order for results.
Available options:
ascending, descending Pagination key for fetching the next page.
Was this page helpful?
⌘I

