# Inbound Processing Region API - PhoneNumber

In the context of the Inbound Processing Region API, a `PhoneNumber` resource represents the routing configuration for a particular [IncomingPhoneNumber](/docs/phone-numbers/api/incomingphonenumber-resource).

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 phone number.

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

## PhoneNumber Properties

```json
{"type":"object","refName":"routes.v2.phone_number","modelName":"routes_v2_phone_number","properties":{"phone_number":{"type":"string","nullable":true,"description":"The phone number in E.164 format"},"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 phone number."},"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 phone number, up to 64 characters."},"voice_region":{"type":"string","nullable":true,"description":"The Inbound Processing Region used for this phone number for voice."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this phone number 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 phone number, given in ISO 8601 format."}}}
```

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

`GET https://routes.twilio.com/v2/PhoneNumbers/{PhoneNumber}`

### Path parameters

```json
[{"name":"PhoneNumber","in":"path","description":"The phone number in E.164 format","schema":{"type":"string"},"required":true}]
```

Fetch a PhoneNumber'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 fetchPhoneNumber() {
  const phoneNumber = await client.routes.v2
    .phoneNumbers("+18001234567")
    .fetch();

  console.log(phoneNumber.phoneNumber);
}

fetchPhoneNumber();
```

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

phone_number = client.routes.v2.phone_numbers("+18001234567").fetch()

print(phone_number.phone_number)
```

```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 phoneNumber = await PhoneNumberResource.FetchAsync(pathPhoneNumber: "+18001234567");

        Console.WriteLine(phoneNumber.PhoneNumber);
    }
}
```

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

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

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);
        PhoneNumber phoneNumber = PhoneNumber.fetcher("+18001234567").fetch();

        System.out.println(phoneNumber.getPhoneNumber());
    }
}
```

```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.FetchPhoneNumber("+18001234567")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.PhoneNumber != nil {
			fmt.Println(*resp.PhoneNumber)
		} else {
			fmt.Println(resp.PhoneNumber)
		}
	}
}
```

```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);

$phone_number = $twilio->routes->v2->phoneNumbers("+18001234567")->fetch();

print $phone_number->phoneNumber;
```

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

phone_number = @client
               .routes
               .v2
               .phone_numbers('+18001234567')
               .fetch

puts phone_number.phone_number
```

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

twilio api:routes:v2:phone-numbers:fetch \
   --phone-number +18001234567
```

```bash
curl -X GET "https://routes.twilio.com/v2/PhoneNumbers/%2B18001234567" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "phone_number": "+18001234567",
  "url": "https://routes.twilio.com/v2/PhoneNumbers/+18001234567",
  "sid": "QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "friendly_name",
  "voice_region": "au1",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z"
}
```

## Update a PhoneNumber's Inbound Processing Region configuration

`POST https://routes.twilio.com/v2/PhoneNumbers/{PhoneNumber}`

### Path parameters

```json
[{"name":"PhoneNumber","in":"path","description":"The phone number in E.164 format","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdatePhoneNumberRequest","properties":{"VoiceRegion":{"type":"string","description":"The Inbound Processing Region used for this phone number 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 PhoneNumber'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 updatePhoneNumber() {
  const phoneNumber = await client.routes.v2
    .phoneNumbers("+18001234567")
    .update({ voiceRegion: "au1" });

  console.log(phoneNumber.voiceRegion);
}

updatePhoneNumber();
```

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

phone_number = client.routes.v2.phone_numbers("+18001234567").update(
    voice_region="au1"
)

print(phone_number.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 phoneNumber = await PhoneNumberResource.UpdateAsync(
            voiceRegion: "au1", pathPhoneNumber: "+18001234567");

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

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

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

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);
        PhoneNumber phoneNumber = PhoneNumber.updater("+18001234567").setVoiceRegion("au1").update();

        System.out.println(phoneNumber.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.UpdatePhoneNumberParams{}
	params.SetVoiceRegion("au1")

	resp, err := client.RoutesV2.UpdatePhoneNumber("+18001234567",
		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);

$phone_number = $twilio->routes->v2
    ->phoneNumbers("+18001234567")
    ->update(["voiceRegion" => "au1"]);

print $phone_number->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)

phone_number = @client
               .routes
               .v2
               .phone_numbers('+18001234567')
               .update(voice_region: 'au1')

puts phone_number.voice_region
```

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

twilio api:routes:v2:phone-numbers:update \
   --phone-number +18001234567 \
   --voice-region au1
```

```bash
curl -X POST "https://routes.twilio.com/v2/PhoneNumbers/%2B18001234567" \
--data-urlencode "VoiceRegion=au1" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "phone_number": "+18001234567",
  "url": "https://routes.twilio.com/v2/PhoneNumbers/+18001234567",
  "sid": "QQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "friendly_name": "friendly_name",
  "voice_region": "au1",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z"
}
```
