cURL
curl --request GET \ --url https://api.example.com/trunks
{ "trunks": [ { "id": "<string>", "name": "<string>", "status": "<string>", "ai_provider": "<string>", "sip_username": "<string>", "created_at": "<string>", "updated_at": "<string>", "metrics": { "calls_today": 123, "success_rate": 123, "avg_latency_ms": 123 } } ], "pagination": { "limit": 123, "offset": 123, "total": 123 } }
Get all SIP trunks (connections)
active
inactive
error
curl -X GET "https://api.telepathvoice.com/v1/trunks?limit=10&status=active" \ -H "Authorization: Bearer sk_live_abc123def456..." \ -H "Content-Type: application/json"
import requests API_KEY = "sk_live_abc123def456..." headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } response = requests.get( "https://api.telepathvoice.com/v1/trunks", headers=headers, params={ "limit": 10, "status": "active" } ) trunks = response.json()
conn_abc123xyz
openai
elevenlabs
custom
{ "trunks": [ { "id": "conn_abc123xyz", "name": "Customer Support", "status": "active", "ai_provider": "openai", "sip_username": "support-01", "created_at": "2024-02-15T10:30:00Z", "updated_at": "2024-03-05T14:22:15Z", "metrics": { "calls_today": 142, "success_rate": 97.2, "avg_latency_ms": 245 } }, { "id": "conn_def456abc", "name": "Billing Bot", "status": "active", "ai_provider": "elevenlabs", "sip_username": "billing-bot", "created_at": "2024-01-20T09:15:00Z", "updated_at": "2024-03-04T11:45:30Z", "metrics": { "calls_today": 89, "success_rate": 98.9, "avg_latency_ms": 312 } } ], "pagination": { "limit": 10, "offset": 0, "total": 2 } }
{ "error": { "code": "INVALID_API_KEY", "message": "The API key provided is invalid" } }
{ "error": { "code": "INVALID_PARAMS", "message": "Invalid limit parameter. Must be between 1 and 100" } }
def get_all_trunks(api_key): """Get all trunks, handling pagination""" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } all_trunks = [] offset = 0 limit = 50 while True: response = requests.get( "https://api.telepathvoice.com/v1/trunks", headers=headers, params={"limit": limit, "offset": offset} ) data = response.json() all_trunks.extend(data['trunks']) if len(data['trunks']) < limit: break # Got all trunks offset += limit return all_trunks
def get_active_trunks(api_key): """Get only active trunks""" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } response = requests.get( "https://api.telepathvoice.com/v1/trunks", headers=headers, params={"status": "active"} ) return response.json()['trunks']
def get_trunk_performance(api_key): """Get performance metrics for all trunks""" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } response = requests.get( "https://api.telepathvoice.com/v1/trunks", headers=headers ) trunks = response.json()['trunks'] for trunk in trunks: print(f"{trunk['name']}: {trunk['metrics']['success_rate']}% success") print(f" Latency: {trunk['metrics']['avg_latency_ms']}ms") print(f" Calls today: {trunk['metrics']['calls_today']}")