cURL
curl --request GET \ --url https://api.example.com/calls/{id}
{ "id": "<string>", "trunk_id": "<string>", "from": "<string>", "to": "<string>", "status": "<string>", "duration_seconds": 123, "start_time": "<string>", "end_time": "<string>", "disconnect_reason": "<string>", "metrics": { "carrier_lag_ms": 123, "ai_latency_ms": 123, "gateway_processing_ms": 123, "packet_loss_percent": 123, "jitter_ms": 123, "codec_used": "<string>" }, "turns": [ { "turn_number": 123, "speaker": "<string>", "duration_ms": 123, "processing_time_ms": 123 } ], "sip_trace": "<string>" }
Get detailed information about a specific call
call_abc123xyz
curl -X GET https://api.telepathvoice.com/v1/calls/call_abc123xyz \ -H "Authorization: Bearer sk_live_abc123def456..." \ -H "Content-Type: application/json"
import requests API_KEY = "sk_live_abc123def456..." CALL_ID = "call_abc123xyz" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } response = requests.get( f"https://api.telepathvoice.com/v1/calls/{CALL_ID}", headers=headers ) call_details = response.json()
{ "id": "call_abc123xyz", "trunk_id": "conn_abc123xyz", "from": "+1-555-123-4567", "to": "+1-555-987-6543", "status": "connected", "duration_seconds": 342, "start_time": "2024-03-05T10:30:00Z", "end_time": "2024-03-05T10:36:42Z", "disconnect_reason": "normal_disconnect", "metrics": { "carrier_lag_ms": 85, "ai_latency_ms": 215, "gateway_processing_ms": 22, "packet_loss_percent": 0.2, "jitter_ms": 12, "codec_used": "G.722" }, "turns": [ { "turn_number": 1, "speaker": "caller", "duration_ms": 2340, "processing_time_ms": 0 }, { "turn_number": 2, "speaker": "agent", "duration_ms": 3210, "processing_time_ms": 285 } ], "sip_trace": "SIP/2.0 100 Trying\nVia: SIP/2.0/TLS..." }
{ "error": { "code": "CALL_NOT_FOUND", "message": "Call 'call_abc123xyz' not found" } }
def analyze_failed_call(api_key, call_id): """Diagnose why a call failed""" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } response = requests.get( f"https://api.telepathvoice.com/v1/calls/{call_id}", headers=headers ) call = response.json() print(f"Call {call['id']} Status: {call['status']}") print(f"Disconnect Reason: {call.get('disconnect_reason', 'Unknown')}") # Check metrics metrics = call['metrics'] print(f"\nMetrics:") print(f" Carrier Lag: {metrics['carrier_lag_ms']}ms") print(f" AI Latency: {metrics['ai_latency_ms']}ms") print(f" Packet Loss: {metrics['packet_loss_percent']}%") # Check SIP trace for errors if "500" in call['sip_trace'] or "403" in call['sip_trace']: print(f"\nServer Error detected in SIP trace") print(f"Check AI provider configuration") if metrics['packet_loss_percent'] > 5: print(f"\nHigh packet loss - check network connection")
def compare_latencies(api_key, call_ids): """Compare latency components across calls""" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } for call_id in call_ids: response = requests.get( f"https://api.telepathvoice.com/v1/calls/{call_id}", headers=headers ) call = response.json() metrics = call['metrics'] carrier = metrics['carrier_lag_ms'] ai = metrics['ai_latency_ms'] gateway = metrics['gateway_processing_ms'] total = carrier + ai + gateway print(f"{call['id']}:") print(f" Carrier: {carrier:4d}ms ({carrier/total*100:5.1f}%)") print(f" AI: {ai:4d}ms ({ai/total*100:5.1f}%)") print(f" Gateway: {gateway:4d}ms ({gateway/total*100:5.1f}%)") print(f" Total: {total:4d}ms")
def generate_call_diagnostics(api_key, call_id): """Generate comprehensive diagnostic report for support""" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } response = requests.get( f"https://api.telepathvoice.com/v1/calls/{call_id}", headers=headers ) call = response.json() report = f""" CALL DIAGNOSTICS REPORT ======================= Call ID: {call['id']} Status: {call['status']} Duration: {call['duration_seconds']}s TIME Start: {call['start_time']} End: {call['end_time']} PARTICIPANTS From: {call['from']} To: {call['to']} PERFORMANCE METRICS Carrier Lag: {call['metrics']['carrier_lag_ms']}ms AI Latency: {call['metrics']['ai_latency_ms']}ms Gateway Processing: {call['metrics']['gateway_processing_ms']}ms Packet Loss: {call['metrics']['packet_loss_percent']}% Jitter: {call['metrics']['jitter_ms']}ms Codec: {call['metrics']['codec_used']} CONVERSATION TURNS: {len(call['turns'])} """ for turn in call['turns']: report += f"\nTurn {turn['turn_number']}: {turn['speaker']} - {turn['duration_ms']}ms" return report