# Portability resource

> \[!IMPORTANT]
>
> The Porting API is are in Public Beta. The information in this document could change. We might add or update features before the product becomes Generally Available. Beta products don't have a Service Level Agreement (SLA). Learn more about [beta product support](https://help.twilio.com/articles/115002413087-Twilio-Beta-product-support).

Use the Portability resource to check if you can port a number to Twilio before you start the porting process. This resource also provides details about why you can't port a number or what manual actions you need to take to facilitate porting that number.

## PhoneNumber Properties

```json
{"type":"object","refName":"numbers.v1.porting_portability","modelName":"numbers_v1_porting_portability","properties":{"phone_number":{"type":"string","format":"phone-number","nullable":true,"description":"The phone number which portability is to be checked. Phone numbers are in E.164 format (e.g. +16175551212).","x-twilio":{"pii":{"handling":"standard","deleteSla":0}}},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"Account Sid that the phone number belongs to in Twilio. This is only returned for phone numbers that already exist in Twilio’s inventory and belong to your account or sub account."},"portable":{"type":"boolean","nullable":true,"description":"Boolean flag indicates if the phone number can be ported into Twilio through the Porting API or not."},"pin_and_account_number_required":{"type":"boolean","nullable":true,"description":"Indicates if the port in process will require a personal identification number (PIN) and an account number for this phone number. If this is true you will be required to submit both a PIN and account number from the losing carrier for this number when opening a port in request. These fields will be required in order to complete the port in process to Twilio."},"not_portable_reason":{"type":"string","nullable":true,"description":"Reason why the phone number cannot be ported into Twilio, `null` otherwise."},"not_portable_reason_code":{"type":"integer","nullable":true,"description":"The Portability Reason Code for the phone number if it cannot be ported into Twilio, `null` otherwise."},"number_type":{"type":"string","enum":["LOCAL","UNKNOWN","MOBILE","TOLL-FREE"],"description":"The type of the requested phone number. One of `LOCAL`, `UNKNOWN`, `MOBILE`, `TOLL-FREE`.","refName":"porting_portability_enum_number_type","modelName":"porting_portability_enum_number_type"},"country":{"type":"string","format":"iso-country-code","nullable":true,"description":"Country the phone number belongs to."},"url":{"type":"string","format":"uri","nullable":true,"description":"This is the url of the request that you're trying to reach out to locate the resource."}}}
```

## Not portable reason codes

When Twilio can't port a phone number, the HTTP 400 (BAD REQUEST) response body includes one of the following portability reason codes in the `not_portable_reason` and `not_portable_reason_code` properties.

| Status code                     | Portability reason                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [22131](/docs/api/errors/22131) | `ALREADY_IN_THE_TARGET_ACCOUNT`          | The phone number already exists on your Twilio account or is currently being ported to your Twilio account.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [22132](/docs/api/errors/22132) | `ALREADY_IN_TWILIO_DIFFERENT_OWNER`      | The phone number already exists on another Twilio account.<br />Learn more about [moving Twilio phone numbers to another Twilio account](https://help.twilio.com/articles/223135327-Moving-Twilio-Phone-Numbers-to-another-Twilio-Account) in the Twilio Help Center.                                                                                                                                                                                                                                                                                                  |
| [22136](/docs/api/errors/22136) | `ALREADY_IN_ONE_OF_YOUR_TWILIO_ACCOUNTS` | The phone number already exists in one of your accounts or is currently being ported to one of your Twilio accounts.<br />Learn more about [moving Twilio phone numbers to another Twilio account](https://help.twilio.com/articles/223135327-Moving-Twilio-Phone-Numbers-to-another-Twilio-Account) in the Twilio Help Center.                                                                                                                                                                                                                                        |
| [22130](/docs/api/errors/22130) | `UNSUPPORTED`                            | Twilio doesn't support the phone number's country, rate center, or carrier.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [22133](/docs/api/errors/22133) | `MANUAL_PORTING_AVAILABLE`               | You can't port the phone number using the Twilio porting API.<br />If the number is a US phone number, open a porting request through the Console. Learn more about [porting a US phone number to Twilio](https://help.twilio.com/articles/223179348-Porting-a-Phone-Number-to-Twilio) in the Twilio Help Center.<br />Otherwise, create a support ticket to port in a phone number from another country. Learn more about [the international porting process](https://help.twilio.com/articles/115000781088-International-Porting-Process) in the Twilio Help Center. |
| [22102](/docs/api/errors/22102) | `INVALID_PHONE_NUMBER`                   | The portability API requires [E.164 format](/docs/glossary/what-e164) for numbers.<br />Resend the request with an E.164 formatted phone number.                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [22171](/docs/api/errors/22135) | `MISSING_REQUIRED_FIELDS`                | The phone number requires additional fields to be ported, but you haven't provided these fields.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [22135](/docs/api/errors/22135) | `ERROR_INTERNAL_SERVER_ERROR`            | Internal error occurred while determining the portability of this number. Try the request again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [20003](/docs/api/errors/20003) | `UNAUTHORIZED`                           | The account provided isn't valid or you don't have access to the provided account in the query parameter `target_account_sid`.                                                                                                                                                                                                                                                                                                                                                                                                                                         |

## Check Portability

`GET https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/{PhoneNumber}`

To check the portability of a single phone number with the Portability resource, send a `GET` request.
Replace `{phone_number}` with your [E.164 formatted](/docs/glossary/what-e164) phone number and `{target_account_sid}` with the destination Account SID, if it differs from the account you use to call the API.

This example shows how to check portability using a curl command:

```bash
curl --location 'https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/{phone_number}?TargetAccountSid={target_account_sid}'
-u "Account_Sid:Access_token"
```

### Path parameters

```json
[{"name":"PhoneNumber","in":"path","description":"Phone number to check portability in e164 format.","schema":{"type":"string","format":"phone-number"},"x-twilio":{"pii":{"handling":"standard","deleteSla":0}},"required":true}]
```

### Query parameters

```json
[{"name":"TargetAccountSid","in":"query","description":"Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$"},"examples":{"fetch":{"value":"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa02"}}},{"name":"AddressSid","in":"query","description":"Address Sid of customer to which the number will be ported.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AD[0-9a-fA-F]{32}$"},"examples":{"fetch":{"value":"ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa02"}}}]
```

## Example Portability responses

### Portable phone number response

For a portable phone number, the response body looks similar to this JSON example. The `portable` Boolean indicates whether you can port the phone number to Twilio. The `pin_and_account_number_required` field indicates if the phone number requires a PIN from the losing carrier as part of the porting process.

```json
{
   "phone_number": "YOUR_NUMBER",
   "portable": true,
   "url": "https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/YOUR_NUMBER",
   "country": "US",
   "not_portable_reason": null,
   "account_sid": null,
   "pin_and_account_number_required": false,
   "not_portable_reason_code": null,
   "number_type": "LOCAL"
}
```

### Not portable phone number response

For a phone number that isn't portable, the response body looks similar to this JSON example. The `portable` Boolean is `false`. Both the `not_portable_reason_code` and `not_portable_reason` fields provide additional details about why you can't port the phone number.

```json
{
   "phone_number": "YOUR_NUMBER",
   "portable": false,
   "url": "https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/YOUR_NUMBER",
   "country": "CO",
   "not_portable_reason": "UNSUPPORTED",
   "account_sid": null,
   "pin_and_account_number_required": true,
   "not_portable_reason_code": 22130,
   "number_type": "UNKNOWN"
}
```

Fetch a PhoneNumber

```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 fetchPortingPortability() {
  const portingPortability = await client.numbers.v1
    .portingPortabilities("+14155552344")
    .fetch();

  console.log(portingPortability.phoneNumber);
}

fetchPortingPortability();
```

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

porting_portability = client.numbers.v1.porting_portabilities(
    "+14155552344"
).fetch()

print(porting_portability.phone_number)
```

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

using System;
using Twilio;
using Twilio.Rest.Numbers.V1;
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 portingPortability = await PortingPortabilityResource.FetchAsync(
            pathPhoneNumber: new Twilio.Types.PhoneNumber("+14155552344"));

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

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

import com.twilio.type.PhoneNumber;
import com.twilio.Twilio;
import com.twilio.rest.numbers.v1.PortingPortability;

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);
        PortingPortability portingPortability =
            PortingPortability.fetcher(new com.twilio.type.PhoneNumber("+14155552344")).fetch();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	numbers "github.com/twilio/twilio-go/rest/numbers/v1"
	"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 := &numbers.FetchPortingPortabilityParams{}

	resp, err := client.NumbersV1.FetchPortingPortability("+14155552344",
		params)
	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);

$porting_portability = $twilio->numbers->v1
    ->portingPortabilities("+14155552344")
    ->fetch();

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

porting_portability = @client
                      .numbers
                      .v1
                      .porting_portabilities('+14155552344')
                      .fetch

puts porting_portability.phone_number
```

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

twilio api:numbers:v1:porting:portability:phone-number:fetch \
   --phone-number +14155552344
```

```bash
curl -X GET "https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/%2B14155552344" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "phone_number": "+14155552344",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa01",
  "portable": false,
  "pin_and_account_number_required": false,
  "not_portable_reason": "MANUAL_PORTING_AVAILABLE",
  "not_portable_reason_code": 22133,
  "number_type": "TOLL-FREE",
  "country": "US",
  "url": "https://numbers.twilio.com/v1/Porting/Portability/PhoneNumber/+18001234567"
}
```
