# PortIn PhoneNumber subresource

> \[!IMPORTANT]
>
> The Porting API is 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).

The PhoneNumber subresource represents a single phone number within a port-in request. PhoneNumber is a subresource of the PortIn resource. You can get the `phoneNumberSid` of a phone number by [fetching a port-in request](/docs/phone-numbers/port-in/port-in-request-api#fetch-a-port-in-request).

## PhoneNumber Properties

```json
{"type":"object","refName":"numbers.v1.porting_port_in_phone_number","modelName":"numbers_v1_porting_port_in_phone_number","properties":{"port_in_request_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^KW[0-9a-fA-F]{32}$","nullable":true,"description":"The unique identifier for the port in request that this phone number is associated with."},"phone_number_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^PU[0-9a-fA-F]{32}$","nullable":true,"description":"The unique identifier for this phone number associated with this port in request."},"url":{"type":"string","format":"uri","nullable":true,"description":"URL reference for this resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"Account Sid or subaccount where the phone number(s) will be Ported."},"phone_number_type":{"type":"string","nullable":true,"description":"The number type of the phone number. This can be: toll-free, local, mobile or unknown. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The timestamp for when this port in phone number was created."},"country":{"type":"string","format":"iso-country-code","nullable":true,"description":"The ISO country code that this number is associated with. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated."},"missing_required_fields":{"type":"boolean","nullable":true,"description":"Indicates if the phone number is missing required fields such as a PIN or account number. This field may be null if the number is not portable or if the portability for a number has not yet been evaluated."},"last_updated":{"type":"string","format":"date-time","nullable":true,"description":"Timestamp indicating when the Port In Phone Number resource was last modified."},"phone_number":{"type":"string","format":"phone-number","nullable":true,"description":"Phone number to be ported. This will be in the E164 Format."},"portable":{"type":"boolean","nullable":true,"description":"If the number is portable by Twilio or not. This field may be null if the number portability has not yet been evaluated. If a number is not portable reference the `not_portability_reason_code` and `not_portability_reason` fields for more details"},"not_portability_reason":{"type":"string","nullable":true,"description":"The not portability reason code description. This field may be null if the number is portable or if the portability for a number has not yet been evaluated."},"not_portability_reason_code":{"type":"integer","nullable":true,"description":"The not portability reason code. This field may be null if the number is portable or if the portability for a number has not yet been evaluated."},"port_in_phone_number_status":{"type":"string","nullable":true,"description":"The status of the port in phone number."},"port_out_pin":{"type":"integer","nullable":true,"description":"The pin required by the losing carrier to do the port out."},"rejection_reason":{"type":"string","nullable":true,"description":"The description of the rejection reason provided by the losing carrier. This field may be null if the number has not been rejected by the losing carrier."},"rejection_reason_code":{"type":"integer","nullable":true,"description":"The code for the rejection reason provided by the losing carrier. This field may be null if the number has not been rejected by the losing carrier."},"port_date":{"type":"string","format":"date-time","nullable":true,"description":"The timestamp the phone number will be ported. This will only be set once a port date has been confirmed. Not all carriers can guarantee a specific time on the port date. Twilio will try its best to get the port completed by this time on the port date. Please subscribe to webhooks for confirmation on when a port has actually been completed."}}}
```

Every phone number in a port-in request has its own status. To learn more about the possible statuses, see the [list of statuses](/docs/phone-numbers/port-in#port-in-phone-number-statuses).

## Fetch a phone number from a port-in request

`GET https://numbers.twilio.com/v1/Porting/PortIn/{PortInRequestSid}/PhoneNumber/{PhoneNumberSid}`

### Path parameters

```json
[{"name":"PortInRequestSid","in":"path","description":"The SID of the Port In request. This is a unique identifier of the port in request.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^KW[0-9a-fA-F]{32}$"},"required":true},{"name":"PhoneNumberSid","in":"path","description":"The SID of the Phone number. This is a unique identifier of the phone number.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^PU[0-9a-fA-F]{32}$"},"required":true}]
```

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 fetchPortingPortInPhoneNumber() {
  const portingPortInPhoneNumber = await client.numbers.v1
    .portingPortInPhoneNumber(
      "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    .fetch();

  console.log(portingPortInPhoneNumber.portInRequestSid);
}

fetchPortingPortInPhoneNumber();
```

```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_port_in_phone_number = client.numbers.v1.porting_port_in_phone_number(
    "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).fetch()

print(porting_port_in_phone_number.port_in_request_sid)
```

```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 portingPortInPhoneNumber = await PortingPortInPhoneNumberResource.FetchAsync(
            pathPortInRequestSid: "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathPhoneNumberSid: "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(portingPortInPhoneNumber.PortInRequestSid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.numbers.v1.PortingPortInPhoneNumber;

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);
        PortingPortInPhoneNumber portingPortInPhoneNumber =
            PortingPortInPhoneNumber.fetcher("KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .fetch();

        System.out.println(portingPortInPhoneNumber.getPortInRequestSid());
    }
}
```

```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.NumbersV1.FetchPortingPortInPhoneNumber("KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.PortInRequestSid != nil {
			fmt.Println(*resp.PortInRequestSid)
		} else {
			fmt.Println(resp.PortInRequestSid)
		}
	}
}
```

```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_port_in_phone_number = $twilio->numbers->v1
    ->portingPortInPhoneNumber(
        "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    ->fetch();

print $porting_port_in_phone_number->portInRequestSid;
```

```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_port_in_phone_number = @client
                               .numbers
                               .v1
                               .porting_port_in_phone_number('KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                               .fetch

puts porting_port_in_phone_number.port_in_request_sid
```

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

twilio api:numbers:v1:porting:port-in:phone-number:fetch \
   --port-in-request-sid KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --phone-number-sid PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://numbers.twilio.com/v1/Porting/PortIn/KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumber/PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "port_in_request_sid": "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "phone_number_type": "LOCAL",
  "date_created": "2024-04-10T06:52:21Z",
  "country": "US",
  "missing_required_fields": false,
  "last_updated": "2024-03-12T06:52:21Z",
  "phone_number": "+15024953384",
  "portable": true,
  "not_portability_reason": "ALREADY_IN_TWILIO_DIFFERENT_OWNER",
  "not_portability_reason_code": 22132,
  "port_in_phone_number_status": "in_review",
  "phone_number_sid": "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "port_out_pin": 1234,
  "rejection_reason": null,
  "rejection_reason_code": null,
  "port_date": "2024-05-17T00:00:00Z",
  "url": "https://numbers.twilio.com/v1/Porting/PortIn/KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumber/PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete a phone number from a port-in request

`DELETE https://numbers.twilio.com/v1/Porting/PortIn/{PortInRequestSid}/PhoneNumber/{PhoneNumberSid}`

Make a `DELETE` request to this endpoint to cancel a single phone number in a port-in request.

There are some restrictions on when you can cancel the port of a phone number. Twilio is only able to accept cancellations that occur more than 72 hours before the port in date.

### Path parameters

```json
[{"name":"PortInRequestSid","in":"path","description":"The SID of the Port In request. This is a unique identifier of the port in request.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^KW[0-9a-fA-F]{32}$"},"required":true},{"name":"PhoneNumberSid","in":"path","description":"The SID of the Port In request phone number. This is a unique identifier of the phone number.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^PU[0-9a-fA-F]{32}$"},"required":true}]
```

Delete 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 deletePortingPortInPhoneNumber() {
  await client.numbers.v1
    .portingPortInPhoneNumber(
      "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    .remove();
}

deletePortingPortInPhoneNumber();
```

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

client.numbers.v1.porting_port_in_phone_number(
    "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).delete()
```

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

        await PortingPortInPhoneNumberResource.DeleteAsync(
            pathPortInRequestSid: "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathPhoneNumberSid: "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.numbers.v1.PortingPortInPhoneNumber;

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);
        PortingPortInPhoneNumber.deleter("KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
            .delete();
    }
}
```

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

	err := client.NumbersV1.DeletePortingPortInPhoneNumber("KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

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

$twilio->numbers->v1
    ->portingPortInPhoneNumber(
        "KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    ->delete();
```

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

@client
  .numbers
  .v1
  .porting_port_in_phone_number('KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:numbers:v1:porting:port-in:phone-number:remove \
   --port-in-request-sid KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --phone-number-sid PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://numbers.twilio.com/v1/Porting/PortIn/KWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumber/PUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Error codes

### Porting rejection reasons

| Status code                     | Name                                  | Description                                                                                                     |
| ------------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [22150](/docs/api/errors/22150) | Contact Support Required              | Reach out to support as an error has occurred during the porting process.                                       |
| [22151](/docs/api/errors/22151) | Phone Number with Carrier Restriction | The phone number has carrier restrictions with the losing carrier that must be resolved before it can be ported |
| [22152](/docs/api/errors/22152) | Phone Number Inactive or Disconnected | The phone number is inactive or disconnected on the losing carrier and cannot be ported                         |
| [22153](/docs/api/errors/22153) | Invalid End User Name                 | The Company Name submitted in the request does not match the losing carrier’s information                       |
| [22154](/docs/api/errors/22154) | Invalid Address                       | The address submitted in the request does not match the losing carrier's information for this phone number      |
| [22155](/docs/api/errors/22155) | Invalid Pin                           | The PIN submitted in the request does not match the losing carrier's information for this phone number          |
| [22156](/docs/api/errors/22156) | Invalid Account Number                | The account number in the request does not match the losing carrier's information for this phone number         |
| [22157](/docs/api/errors/22157) | Invalid Subscription Right            | The subscription in the request does not match the losing carrier's information for this phone number           |
| [22158](/docs/api/errors/22158) | Port Date Rejected                    | The port date for this request was rejected                                                                     |
| [22159](/docs/api/errors/22159) | Not Portable                          | This phone number is in a country, rate center, or on an SID that is not supported by Twilio                    |
| [22171](/docs/api/errors/22171) | Missing Required Fields               | There are required fields in the request that are missing information                                           |
| [400](/docs/api/errors/400)     | Bad Request                           | There is a missing/invalid entry in the request.                                                                |
| [410](/docs/api/errors/410)     | Unknown Error                         | The error does not fall within known Porting Reject Reasons. Please contact support for further help.           |

### HTTP responses

An HTTP 201 response status code indicates an accepted cancellation request. Unsuccessful requests have the following error codes:

| HTTP status code            | Next steps                                                                                                                                                              |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [404](/docs/api/errors/404) | The requested port-in phone number doesn't exist on your account. Check that you have the correct port-in request SID. All port-in request SIDs should begin with `KW`. |
| [500](/docs/api/errors/500) | An error occurred within Twilio while trying to cancel the port-in request. Please try again and contact support if the issue persists.                                 |
