Skip to main content
Connect AI voice agent platforms (ElevenLabs, LiveKit, Vapi) to Plivo’s telephony network via SIP trunking.

Summary

DirectionSetup StepsUse Case
Outbound (AI → Phone)1. Create Credentials or IP ACL → 2. Create Outbound TrunkYour AI agent calls phone numbers
Inbound (Phone → AI)1. Create Origination URI → 2. Create Inbound Trunk → 3. Assign phone numberCallers reach your AI agent

Outbound Calls (AI Agent → Phone)

Route calls from your AI agent platform to phone numbers via PSTN.

Step 1: Create Authentication

Choose one authentication method:
Use when your AI platform has dynamic IPs or you need SIP digest authentication.Endpoint: POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Credential/
ParameterTypeRequiredDescription
namestringNoFriendly name
usernamestringYesSIP authentication username
passwordstringYesSIP authentication password
cURL
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "elevenlabs-credentials",
      "username": "elevenlabs_user",
      "password": "securepassword123!"
    }' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Credential/
Response:
{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "credential created successfully.",
  "credential_uuid": "f19c4773-4ae6-4b75-92ea-9cf3ea4227d6"
}
Save the credential_uuid for trunk creation.

Step 2: Create Outbound Trunk

Endpoint: POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/
ParameterTypeRequiredDescription
namestringNoFriendly name
trunk_directionstringYesMust be outbound
trunk_statusstringNoenabled (default) or disabled
securebooleanNoEnable SRTP/TLS. Default: false
credential_uuidstringConditionalFrom Step 1 (if using credentials)
ipacl_uuidstringConditionalFrom Step 1 (if using IP ACL)
cURL
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "elevenlabs-outbound",
      "trunk_direction": "outbound",
      "credential_uuid": "f19c4773-4ae6-4b75-92ea-9cf3ea4227d6"
    }' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/
Response:
{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "Trunk created successfully.",
  "trunk_id": "21784177241578",
  "trunk_domain": "21784177241578.zt.plivo.com"
}

Step 3: Configure Your AI Platform

Use the trunk_domain (e.g., 21784177241578.zt.plivo.com) in your AI platform’s SIP configuration. Your platform sends SIP INVITE to this domain to place outbound calls.

Inbound Calls (Phone → AI Agent)

Route incoming phone calls to your AI agent platform.

Step 1: Create Origination URI

Define where Plivo sends inbound calls (your AI platform’s SIP endpoint). Endpoint: POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/URI/
ParameterTypeRequiredDescription
namestringNoFriendly name
uristringYesYour AI platform’s SIP address
authentication_neededbooleanNoRequire auth. Default: false
usernamestringConditionalUsername (if auth enabled)
passwordstringConditionalPassword (if auth enabled)
cURL
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "livekit-primary",
      "uri": "sip.livekit.cloud:5060"
    }' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/URI/
Response:
{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "Origination URI created successfully.",
  "uri_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb"
}
Save the uri_uuid for trunk creation. Optionally create a second URI for failover.

URI Format Examples

FormatExample
FQDN with portsip.example.com:5060
FQDNsip.example.com
IP with port192.168.1.100:5060
IP address192.168.1.100

Step 2: Create Inbound Trunk

Endpoint: POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/
ParameterTypeRequiredDescription
namestringNoFriendly name
trunk_directionstringYesMust be inbound
trunk_statusstringNoenabled (default) or disabled
securebooleanNoEnable SRTP/TLS. Default: false
primary_uri_uuidstringYesFrom Step 1
fallback_uri_uuidstringNoBackup URI (optional)
cURL
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "livekit-inbound",
      "trunk_direction": "inbound",
      "primary_uri_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb",
      "fallback_uri_uuid": "796c-4d86-a4fd-44ed11667ddb-eb07"
    }' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/
Response:
{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "Trunk created successfully.",
  "trunk_id": "986908123123411213"
}

Step 3: Assign Phone Number to Trunk

  1. Go to Phone Numbers in the Plivo Console
  2. Select your phone number
  3. Under Voice Configuration, select SIP Trunk
  4. Choose your inbound trunk from the dropdown
  5. Save changes
Calls to this number now route to your AI agent.

Call Records

To retrieve call detail records (CDRs) and call quality insights for SIP trunk calls, see SIP Trunking API - Calls.

Additional API Operations

For retrieving, listing, updating, and deleting resources:
ResourceFull API Reference
TrunksSIP Trunking API - Trunks
CredentialsSIP Trunking API - Credentials
Origination URIsSIP Trunking API - Origination URIs
IP Access Control ListsSIP Trunking API - IP ACLs