Configure a Trunk Group

A detailed guide to configuring a trunk group through the CarrierX Portal and programmatically.



Overview


Trunk groups route phone numbers to their assigned endpoints. When calls are placed, the phone number is matched with the trunk group, which then routes the call to the proper endpoint. Multiple endpoints can be assigned to a single trunk group. Logic can also be implemented to accomodate for failures and distribute traffic for trunk groups with multiple endpoints. Trunk groups can be configured through the Portal and programmatically.



Initial Setup Through the Portal



In this section, we will configure a trunk group through the Portal. Note that this can also be done programmatically, as is covered in a later section of this guide.

1. Follow the instructions on the Configure an Application Endpoint Quick Start Guide to create an endpoint. However, on the Add New Endpoint form, do not check the Provision Trunk Group box. You can create any type of endpoint that you would like. In our example, we are assigning a Third-Party endpoint to the trunk group.

2. Once your endpoint is created, navigate to the Configure menu and click Trunk Groups .



3. Click Add New Trunk Group .



4. Enter a name for the new trunk group. This is a friendly name that is used for internal reference.



5. Select the endpoint you would like to assign the trunk group to from the Assign Endpoint dropdown menu.



6. Click Create Trunk Group .



7. Once you have created the trunk group, you will be redirected to the Configure Trunk Groups page. From here, click on the new trunk group that you created to view trunk group details.



8. If you would like to edit the trunk group, click Edit .



9. Once you are finished changing values, click Update .



Now you are ready to assign an endpoint and phone number to the trunk group. Refer to the Endpoints and Phone Numbers sections of the Core API for more information.



Programmatically Configure a Trunk Group



In this section, we will configure a trunk group programmatically. For more information, refer to the Trunk Groups section of the Core API Reference Guide.

1. Form a POST request. To create a trunk alongside the trunk group, pass the with_trunks field in the query URL with the value true . In the request body, pass the field name with a chosen name for the new trunk group. Also pass the array trunks with the fields name and endpoint_sid .

curl -X POST \
'https://api.carrierx.com/core/v2/trunk_groups?with_trunks=true' \
-H 'Content-Type:application/json' \
--data-binary '{"name":"new_trunk_group", "trunks":[{"name":"new_trunk", "endpoint_sid": "6a898445-62c1-46cf-be8b-25c2a3c87ec7"}]}' \
-u '[your_user_name]:[your_password]'


A successful request will return a 200 status code along with a response that looks like the following:

{
    "acls": [],
    "name": "new_trunk_group",
    "partner_sid": "77354609-bd20-4ed0-a523-8c00792f15b8",
    "routing_data": null,
    "routing_type": "failover",
    "soft_failure_codes": "408;",
    "soft_failure_cooldown": 120,
    "transformations": [],
    "trunk_group_sid": "c6a721ab-c3f4-4e0c-b320-e014e0eefc29",
    "trunks": [
        {
            "allow_forward": "disable",
            "call_type": "regular",
            "codec": null,
            "endpoint_sid": "6a898445-62c1-46cf-be8b-25c2a3c87ec7",
            "in_capacity": 0,
            "name": "new_trunk",
            "out_capacity": 0,
            "relay_sip_headers": [],
            "transformations": [],
            "trunk_sid": "8f34d2b7-cc20-4ebe-8f7d-090c74c42a20"
        }
    ]
}


Configure a Trunk Group with Two Endpoints


In this section, we will go over assigning two endpoints to one trunk group. This would be done to accomodate for service outages or to disperse phone traffic among multiple centers. The two routing types that can be assigned when working with multiple endpoints on a single trunk group are failover and round_robin .

1. Navigate to Configure and click Trunk Groups .



2. Click Add New Trunk Group .



2. Enter a name for the new trunk group. This is a friendly name that is used for internal reference.



3. Select the first third-party endpoint that you would like to assign to the trunk group from the dropdown menu.



4. Click Add another trunk .



5. Select the second third-party endpoint that you would like to assign to the trunk group from the dropdown menu.



6. Click Create Trunk Group .



7. Once you create the new trunk group, you will be redirected to the new endpoint details. You can access trunk group details at any time by clicking on the trunk group and scrolling down.



8. The default routing type when there are multiple endpoints is failover . Failover means that if the first endpoint is not reachable, the system will try to reach the second endpoint instead. You can change the routing type to round_robin by clicking Edit .



9. Select round_robin from the Routing Type dropdown menu if you want the system to evenly distribute traffic to both endpoints.



10. Click Update .