Skip to main content
The Trunks API lets you create and manage SIP trunks that route voice traffic between your infrastructure and Plivo’s network.

API Endpoint

https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/

The Trunk Object

A trunk represents a SIP connection between your infrastructure and Plivo’s network. Trunks can be inbound (receiving calls from Plivo) or outbound (sending calls to Plivo).

Attributes

trunk_id
string
Unique identifier for the trunk.
trunk_domain
string
Unique address on Plivo to route SIP traffic (e.g., 21784177241578.zt.plivo.com).
name
string
Friendly name for the trunk.
trunk_status
string
Status of the trunk: enabled or disabled.
trunk_direction
string
Direction of the trunk: inbound or outbound.
secure
boolean
Whether SRTP (media) and TLS (signaling) encryption is enabled.
ipacl_uuid
string
IP access control list UUID (for outbound trunks).
credential_uuid
string
Credentials list UUID (for outbound trunks).
primary_uri_uuid
string
Primary origination URI UUID (for inbound trunks).
fallback_uri_uuid
string
Fallback origination URI UUID (for inbound trunks).

Example Object

{
  "name": "trunk_name_1",
  "trunk_id": "21784177241578",
  "trunk_domain": "21784177241578.zt.plivo.com",
  "trunk_status": "enabled",
  "secure": true,
  "trunk_direction": "outbound",
  "ipacl_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb",
  "credential_uuid": "eb07-796c-4d86-a4fd-44ed11667ddb",
  "primary_uri_uuid": null,
  "fallback_uri_uuid": null
}

List All Trunks

Get all trunks with optional filtering.

HTTP Request

GET https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/

Query Parameters

ParameterTypeRequiredDefaultDescription
trunk_statusstringNo-Filter by status: enabled, disabled
trunk_directionstringNo-Filter by direction: inbound, outbound
securebooleanNo-Filter by encryption: true, false
ipacl_uuidstringNo-Filter by IP ACL
credential_uuidstringNo-Filter by credentials
primary_uri_uuidstringNo-Filter by primary URI
fallback_uri_uuidstringNo-Filter by fallback URI
limitintegerNo20Results per page (1-20)
offsetintegerNo0Pagination offset

Response

{
  "api_id": "a04ad809-3b78-4bbe-9baf-acfc7800b10f",
  "meta": {
    "limit": 2,
    "offset": 0,
    "total_count": 10,
    "previous": null,
    "next": "v1/Account/{auth_id}/Zentrunk/Trunk/?limit=2&offset=2"
  },
  "objects": [
    {
      "name": "trunk_name_1",
      "trunk_id": "21784177241578",
      "trunk_domain": "21784177241578.zt.plivo.com",
      "trunk_status": "enabled",
      "secure": true,
      "trunk_direction": "outbound",
      "ipacl_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb",
      "credential_uuid": "eb07-796c-4d86-a4fd-44ed11667ddb",
      "primary_uri_uuid": null,
      "fallback_uri_uuid": null
    },
    {
      "name": "trunk_name_2",
      "trunk_id": "31784177241575",
      "trunk_domain": "31784177241575.zt.plivo.com",
      "trunk_status": "enabled",
      "secure": false,
      "trunk_direction": "inbound",
      "ipacl_uuid": null,
      "credential_uuid": null,
      "primary_uri_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb",
      "fallback_uri_uuid": "796c-4d86-a4fd-44ed11667ddb-eb07"
    }
  ]
}

Example

curl -i --user AUTH_ID:AUTH_TOKEN \
    "https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/?trunk_direction=outbound&limit=10"

Retrieve a Trunk

Get details of a specific trunk.

HTTP Request

GET https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/{trunk_id}/

Response

Returns the trunk object.
{
  "name": "trunk_name_1",
  "trunk_id": "21784177241578",
  "trunk_domain": "21784177241578.zt.plivo.com",
  "trunk_status": "enabled",
  "secure": true,
  "trunk_direction": "outbound",
  "ipacl_uuid": "90b6eb07-796c-4d86-a4fd-44ed11667ddb",
  "credential_uuid": "eb07-796c-4d86-a4fd-44ed11667ddb",
  "primary_uri_uuid": null,
  "fallback_uri_uuid": null
}

Example

curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/21784177241578/

Create a Trunk

Create a new SIP trunk for inbound or outbound traffic.

HTTP Request

POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/

Request Parameters

ParameterTypeRequiredDefaultDescription
namestringNo-Friendly name for the trunk
trunk_directionstringYes-Direction: inbound or outbound
trunk_statusstringNoenabledStatus: enabled or disabled
securebooleanNofalseEnable SRTP/TLS encryption
ipacl_uuidstringConditional-IP ACL UUID. Required for outbound trunks
credential_uuidstringConditional-Credentials UUID. Required for outbound trunks
primary_uri_uuidstringConditional-Primary origination URI. Required for inbound trunks
fallback_uri_uuidstringNo-Fallback origination URI for inbound trunks

Response

{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "Trunk created successfully.",
  "trunk_id": "986908123123411213"
}

Error Codes

CodeDescription
400Invalid request parameters
401Authentication failed
422Missing required parameters (e.g., ipacl_uuid for outbound trunk)

Outbound Trunk Example

For outbound trunks (calls from your PBX to Plivo), you need either ipacl_uuid or credential_uuid for authentication.
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "outbound-trunk",
      "trunk_direction": "outbound",
      "trunk_status": "enabled",
      "ipacl_uuid": "1c13de4c-423d-11e3-9899-22000abfa5d5"
    }' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/

Inbound Trunk Example

For inbound trunks (calls from Plivo to your PBX), you need a primary_uri_uuid pointing to your server.
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{
      "name": "inbound-trunk",
      "trunk_direction": "inbound",
      "trunk_status": "enabled",
      "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/

Update a Trunk

Modify an existing trunk’s properties.

HTTP Request

POST https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/{trunk_id}/

Request Parameters

ParameterTypeRequiredDefaultDescription
namestringNo-New name for the trunk
trunk_statusstringNo-Status: enabled or disabled
trunk_directionstringNo-Direction: inbound or outbound
securebooleanNo-Enable/disable SRTP/TLS encryption
ipacl_uuidstringNo-New IP ACL UUID
credential_uuidstringNo-New credentials UUID
primary_uri_uuidstringNo-New primary origination URI
fallback_uri_uuidstringNo-New fallback origination URI

Response

{
  "api_id": "4e1f954c-baf3-11ec-bafe-0242ac110003",
  "message": "Trunk updated successfully.",
  "trunk_id": "986908123123411213"
}

Example

curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"name": "updated-trunk-name", "trunk_status": "disabled"}' \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/{trunk_id}/

Delete a Trunk

Permanently delete a trunk.

HTTP Request

DELETE https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/{trunk_id}/

Response

HTTP 204 No Content

Example

curl -X DELETE -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Zentrunk/Trunk/{trunk_id}/

Trunk Types

Trunk TypePurposeCan Attach to Phone Numbers?
InboundRoute calls from Plivo to your PBX/infrastructureYes
OutboundRoute calls from your PBX/infrastructure to PlivoNo
Only inbound trunks can be attached to phone numbers. If you create an outbound trunk, it will not appear in the phone number configuration dropdown. To receive calls on a Plivo number via SIP, you must create an inbound trunk.

Outbound Trunks

Route calls from your PBX/infrastructure to Plivo:
  • Your system sends SIP INVITE to the trunk domain
  • Authentication via IP ACL or credentials
  • Calls terminate on PSTN via Plivo

Inbound Trunks

Route calls from Plivo to your PBX/infrastructure:
  • Calls arrive at Plivo (from PSTN or Plivo numbers)
  • Plivo forwards to your origination URI
  • Fallback URI used if primary fails
  • Can be attached to purchased phone numbers