# Inbound Processing Region API - Trunk

In the context of the Inbound Processing Region API, a `Trunk` resource represents the routing configuration for a particular [Elastic SIP Trunk](/docs/sip-trunking).

By adjusting the value of the `voice_region` property, you can control which [Twilio Region](/docs/global-infrastructure/understanding-twilio-regions) will process and store data related to inbound calls for the Trunk.

> \[!WARNING]
>
> Changes to this resource may take up to 5 minutes to take effect.

## Trunk properties

```json
{"type":"object","refName":"routes.v2.trunks","modelName":"routes_v2_trunks","properties":{"sip_trunk_domain":{"type":"string","nullable":true,"description":"The absolute URL of the SIP Trunk"},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the resource."},"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^QQ[0-9a-fA-F]{32}$","nullable":true,"description":"A 34 character string that uniquely identifies the Inbound Processing Region assignments for this SIP Trunk."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Account."},"friendly_name":{"type":"string","nullable":true,"description":"A human readable description of the Inbound Processing Region assignments for this SIP Trunk, up to 64 characters."},"voice_region":{"type":"string","nullable":true,"description":"The Inbound Processing Region used for this SIP Trunk for voice."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this SIP Trunk was assigned an Inbound Processing Region, given in ISO 8601 format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date that the Inbound Processing Region was updated for this SIP Trunk, given in ISO 8601 format."}}}
```

## Fetch a Trunk's current Inbound Processing Region configuration

`GET https://routes.twilio.com/v2/Trunks/{SipTrunkDomain}`

### Path parameters

```json
[{"name":"SipTrunkDomain","in":"path","description":"The absolute URL of the SIP Trunk","schema":{"type":"string"},"required":true}]
```

Fetch a Trunk's current Inbound Processing Region configuration

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchTrunks() {
  const trunk = await client.routes.v2
    .trunks("example.pstn.twilio.com")
    .fetch();

  console.log(trunk.voiceRegion);
}

fetchTrunks();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

trunk = client.routes.v2.trunks("example.pstn.twilio.com").fetch()

print(trunk.voice_region)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Routes.V2;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var trunk = await TrunkResource.FetchAsync(pathSipTrunkDomain: "example.pstn.twilio.com");

        Console.WriteLine(trunk.VoiceRegion);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.routes.v2.Trunk;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Trunk trunk = Trunk.fetcher("example.pstn.twilio.com").fetch();

        System.out.println(trunk.getVoiceRegion());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.RoutesV2.FetchTrunks("example.pstn.twilio.com")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.VoiceRegion != nil {
			fmt.Println(*resp.VoiceRegion)
		} else {
			fmt.Println(resp.VoiceRegion)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$trunk = $twilio->routes->v2->trunks("example.pstn.twilio.com")->fetch();

print $trunk->voiceRegion;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

trunk = @client
        .routes
        .v2
        .trunks('example.pstn.twilio.com')
        .fetch

puts trunk.voice_region
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:routes:v2:trunks:fetch \
   --sip-trunk-domain example.pstn.twilio.com
```

```bash
curl -X GET "https://routes.twilio.com/v2/Trunks/example.pstn.twilio.com" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sip_trunk_domain": "example.pstn.twilio.com",
  "url": "https://routes.twilio.com/v2/Trunks/test.pstn.twilio.com",
  "account_sid": "AC00000000000000000000000000000000",
  "sid": "QQ00000000000000000000000000000000",
  "friendly_name": "string",
  "voice_region": "string",
  "date_created": "2022-06-02T22:33:47Z",
  "date_updated": "2022-06-02T22:33:47Z"
}
```

## Update a Trunk's Inbound Processing Region configuration

`POST https://routes.twilio.com/v2/Trunks/{SipTrunkDomain}`

### Path parameters

```json
[{"name":"SipTrunkDomain","in":"path","description":"The absolute URL of the SIP Trunk","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateTrunksRequest","properties":{"VoiceRegion":{"type":"string","description":"The Inbound Processing Region used for this SIP Trunk for voice"},"FriendlyName":{"type":"string","description":"A human readable description of this resource, up to 64 characters."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"FriendlyName\": \"friendly_name\",\n  \"VoiceRegion\": \"au1\"\n}","meta":"","code":"{\n  \"FriendlyName\": \"friendly_name\",\n  \"VoiceRegion\": \"au1\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"friendly_name\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"VoiceRegion\"","#7EE787"],[":","#C9D1D9"]," ",["\"au1\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a Trunk's Inbound Processing Region configuration

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateTrunks() {
  const trunk = await client.routes.v2
    .trunks("example.pstn.twilio.com")
    .update({ voiceRegion: "au1" });

  console.log(trunk.voiceRegion);
}

updateTrunks();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

trunks = client.routes.v2.trunks("example.pstn.twilio.com").update(
    voice_region="au1"
)

print(trunks.voice_region)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Routes.V2;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var trunk = await TrunkResource.UpdateAsync(
            voiceRegion: "au1", pathSipTrunkDomain: "example.pstn.twilio.com");

        Console.WriteLine(trunk.VoiceRegion);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.routes.v2.Trunk;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Trunk trunk = Trunk.updater("example.pstn.twilio.com").setVoiceRegion("au1").update();

        System.out.println(trunk.getVoiceRegion());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	routes "github.com/twilio/twilio-go/rest/routes/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &routes.UpdateTrunksParams{}
	params.SetVoiceRegion("au1")

	resp, err := client.RoutesV2.UpdateTrunks("example.pstn.twilio.com",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.VoiceRegion != nil {
			fmt.Println(*resp.VoiceRegion)
		} else {
			fmt.Println(resp.VoiceRegion)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$trunks = $twilio->routes->v2
    ->trunks("example.pstn.twilio.com")
    ->update(["voiceRegion" => "au1"]);

print $trunks->voiceRegion;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

trunk = @client
        .routes
        .v2
        .trunks('example.pstn.twilio.com')
        .update(voice_region: 'au1')

puts trunk.voice_region
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:routes:v2:trunks:update \
   --sip-trunk-domain example.pstn.twilio.com \
   --voice-region au1
```

```bash
curl -X POST "https://routes.twilio.com/v2/Trunks/example.pstn.twilio.com" \
--data-urlencode "VoiceRegion=au1" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sip_trunk_domain": "example.pstn.twilio.com",
  "url": "https://routes.twilio.com/v2/Trunks/test.pstn.twilio.com",
  "sid": "QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "friendly_name",
  "voice_region": "au1",
  "date_created": "2020-08-07T22:29:24Z",
  "date_updated": "2020-08-07T22:29:24Z"
}
```
