{
"success": true,
"numbers": [
{
"phone_number": "<string>",
"country_code": "<string>",
"capabilities": {},
"provider": "<string>",
"friendly_name": "<string>",
"locality": "<string>",
"region": "<string>",
"cost": "<string>",
"setup_cost": "<string>"
}
],
"total_found": 123,
"provider": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Phone Number Management
Search Phone Numbers
Search available Twilio or Telnyx phone numbers by country, area code, locality, region, pattern, provider, and result limit.
POST
/
api
/
v1
/
phone-numbers
/
search
{
"success": true,
"numbers": [
{
"phone_number": "<string>",
"country_code": "<string>",
"capabilities": {},
"provider": "<string>",
"friendly_name": "<string>",
"locality": "<string>",
"region": "<string>",
"cost": "<string>",
"setup_cost": "<string>"
}
],
"total_found": 123,
"provider": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}This endpoint allows you to search for available phone numbers for purchase from Twilio or Telnyx. You can filter results by country, area code, location, or number patterns to find the perfect number for your assistant.
Common causes:
How It Works
- Provider Selection: Choose between Twilio or Telnyx as your search provider
- Filter Application: Apply location, pattern, or feature-based filters
- Results with Pricing: Get available numbers with cost information and capabilities
- Direct Purchase: Use the returned phone numbers in the purchase endpoint
Multi-Provider Comparison: Search both Twilio and Telnyx separately to compare pricing and availability across providers for the same region.
Request Body
The request body is a JSON object containing search criteria.country_code(string, optional): Country code to search in. Defaults to"US"area_code(string, optional): Specific area code to search withincontains(string, optional): Pattern or digits the number should containlocality(string, optional): City or locality name to search inregion(string, optional): State or region to search withinlimit(integer, optional): Maximum number of results (1-50). Defaults to10provider(string, optional): Provider to search ("twilio"or"telnyx"). Defaults to"telnyx"
Request
{
"country_code": "US",
"area_code": "415",
"locality": "San Francisco",
"region": "CA",
"limit": 20,
"provider": "telnyx"
}
Response
A successful request returns a200 OK status with available phone numbers.
Response
{
"success": true,
"numbers": [
{
"phone_number": "+14155551234",
"friendly_name": "+14155551234",
"locality": "San Francisco",
"region": "CA",
"country_code": "US",
"capabilities": {
"voice": true,
"sms": true,
"mms": true,
"fax": false
},
"cost": "$1.00",
"setup_cost": "$0.00",
"provider": "telnyx"
}
],
"total_found": 15,
"provider": "telnyx"
}
Response Fields
success(boolean): Whether the search completed successfullynumbers(array): List of available phone numbers with detailsphone_number(string): The phone number in E.164 formatfriendly_name(string): Display name for the numberlocality(string): City/locality where the number is locatedregion(string): State/region where the number is locatedcountry_code(string): Country codecapabilities(object): Features supported by this numbervoice(boolean): Supports voice callssms(boolean): Supports SMS messagesmms(boolean): Supports MMS messagesfax(boolean): Supports fax transmissions
cost(string): Monthly cost for the number (Telnyx only)setup_cost(string): One-time setup fee (Telnyx only)provider(string): Provider name (“twilio” or “telnyx”)
total_found(integer): Total number of results foundprovider(string): Provider used for the search
Error Responses
400 Bad Request
Returned when the request contains invalid parameters.{
"detail": "Provider must be 'twilio' or 'telnyx'"
}
- Invalid
providervalue limitoutside of 1-50 range- Invalid country code format
500 Internal Server Error
Returned when the provider API fails or is unavailable.{
"detail": "Internal error: Provider API unavailable"
}
Search Examples
Basic Area Code Search
Search for numbers in the 415 area code:{
"area_code": "415",
"provider": "telnyx",
"limit": 10
}
Location-Based Search
Find numbers in a specific city:{
"locality": "New York",
"region": "NY",
"country_code": "US",
"provider": "twilio"
}
Pattern-Based Search
Search for numbers containing specific digits:{
"contains": "777",
"area_code": "212",
"provider": "telnyx"
}
International Search
Search for numbers in other countries:{
"country_code": "GB",
"locality": "London",
"provider": "telnyx",
"limit": 5
}
Provider Comparison
Twilio vs Telnyx
| Feature | Twilio | Telnyx |
|---|---|---|
| Search Filters | Area code, locality, region, contains | Area code, locality, region, contains |
| Pricing Info | Not included in search | Monthly + setup costs shown |
| Global Coverage | Provider-dependent and changes by product | Provider-dependent and changes by product |
| API Speed | Fast | Very fast |
| Features | Voice, SMS, MMS, Fax | Voice, SMS, MMS |
Cost Optimization Tips
- Compare Providers: Search both providers for the same criteria
- Check Setup Fees: Telnyx shows setup costs upfront
- Consider Features: Ensure the number supports required capabilities
- Location Matters: Local numbers may have better rates
# Compare pricing between providers
curl -X POST "https://api.burki.dev/api/v1/phone-numbers/search" \
-H "Content-Type: application/json" \
-d '{"area_code": "415", "provider": "telnyx"}'
curl -X POST "https://api.burki.dev/api/v1/phone-numbers/search" \
-H "Content-Type: application/json" \
-d '{"area_code": "415", "provider": "twilio"}'
Use Cases
Sales Team Numbers
Search for memorable numbers for sales teams:{
"contains": "SALE",
"area_code": "800",
"provider": "telnyx"
}
Local Presence
Establish local presence in multiple markets:{
"locality": "Chicago",
"region": "IL",
"limit": 5,
"provider": "twilio"
}
Toll-Free Numbers
Search for toll-free numbers:{
"area_code": "800",
"country_code": "US",
"provider": "telnyx"
}
Integration Examples
Node.js
const axios = require('axios');
async function searchPhoneNumbers(criteria) {
try {
const response = await axios.post('https://api.burki.dev/api/v1/phone-numbers/search', {
...criteria,
provider: 'telnyx'
}, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
return response.data.numbers;
} catch (error) {
console.error('Search failed:', error.response.data);
throw error;
}
}
// Usage
const numbers = await searchPhoneNumbers({
area_code: '415',
locality: 'San Francisco',
limit: 10
});
Python
import requests
def search_phone_numbers(criteria, provider='telnyx'):
url = "https://api.burki.dev/api/v1/phone-numbers/search"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {**criteria, "provider": provider}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
return response.json()['numbers']
else:
raise Exception(f"Search failed: {response.json()['detail']}")
# Usage
numbers = search_phone_numbers({
'area_code': '415',
'locality': 'San Francisco',
'limit': 10
})
PHP
<?php
function searchPhoneNumbers($criteria, $provider = 'telnyx') {
$url = 'https://api.burki.dev/api/v1/phone-numbers/search';
$headers = [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
];
$data = array_merge($criteria, ['provider' => $provider]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
return json_decode($response, true)['numbers'];
} else {
throw new Exception("Search failed: " . $response);
}
}
// Usage
$numbers = searchPhoneNumbers([
'area_code' => '415',
'locality' => 'San Francisco',
'limit' => 10
]);
?>
Best Practices
Search Strategy
- Start Broad: Begin with area code only, then add filters
- Multiple Searches: Try different combinations to find the best options
- Provider Comparison: Always compare both Twilio and Telnyx
- Capability Check: Verify the number supports your required features
Performance Tips
- Reasonable Limits: Use appropriate limit values (10-20 for UI, 5 for automation)
- Cache Results: Cache search results for a few minutes to avoid repeated calls
- Parallel Searches: Search multiple providers simultaneously for comparison
Error Handling
Always implement proper error handling for provider outages:async function robustSearch(criteria) {
const providers = ['telnyx', 'twilio'];
for (const provider of providers) {
try {
return await searchPhoneNumbers({...criteria, provider});
} catch (error) {
console.warn(`${provider} search failed, trying next provider`);
}
}
throw new Error('All providers failed');
}
Rate Limits: Search requests are subject to rate limits. For high-volume applications, implement appropriate throttling and retry logic.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Request model for searching available phone numbers.
Country code (e.g., US, GB)
Area code to search in
Pattern the number should contain
City/locality to search in
State/region to search in
Maximum number of results
Required range:
1 <= x <= 50Provider to search ('twilio', 'telnyx', or 'byo-sip-trunk')
⌘I