Skip to main content
GET
/
trunks
List Trunks
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
  }
}

Overview

Retrieve all SIP trunks configured in your account.

Request

limit
integer
default:"20"
Maximum number of trunks to return (1-100)
offset
integer
default:"0"
Number of trunks to skip for pagination
status
string
Filter by status: active, inactive, error

Example Request

curl -X GET "https://api.telepathvoice.com/v1/trunks?limit=10&status=active" \
  -H "Authorization: Bearer sk_live_abc123def456..." \
  -H "Content-Type: application/json"

Python Example

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()

Response

trunks
array
Array of trunk objects
id
string
Unique trunk identifier (e.g., conn_abc123xyz)
name
string
Friendly name of the trunk
status
string
Current status: active, inactive, error
ai_provider
string
AI provider: openai, elevenlabs, custom
sip_username
string
SIP authentication username
created_at
string
ISO 8601 timestamp when trunk was created
updated_at
string
ISO 8601 timestamp of last update
metrics
object
Performance metrics for this trunk
calls_today
integer
Number of calls today
success_rate
number
Percentage of successful calls (0-100)
avg_latency_ms
integer
Average latency in milliseconds
pagination
object
Pagination information
limit
integer
Items per page
offset
integer
Current offset
total
integer
Total number of trunks

Example Response

{
  "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 Responses

Unauthorized

{
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The API key provided is invalid"
  }
}
Status Code: 401

Invalid Parameters

{
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Invalid limit parameter. Must be between 1 and 100"
  }
}
Status Code: 400

Usage Examples

Pagination

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

Filter by Status

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']

Monitor Performance

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']}")

See Also