# Testing SIM Swap with Magic Numbers

> \[!WARNING]
>
> Please review the [Magic Numbers for Lookup](/docs/lookup/magic-numbers-for-lookup) and use your testing credentials for the correct Region when testing phone numbers. If you use your production credentials then the phone numbers don't display the correct responses shown below.
>
> Note: Your testing credentials are region specific so make sure you have selected the region you want to test in the top right corner of the [Auth Tokens page of your Console](https://console.twilio.com/us1/account/keys-credentials/api-keys?frameUrl=%2Fconsole%2Fproject%2Fapi-keys%3Fx-target-region%3Dus1) before testing phone numbers.

## SIM Swap Magic Numbers

These phone numbers have simulated information for the following inputs which is for testing the [SIM Swap](/docs/lookup/v2-api/sim-swap) feature. Testing SIM Swap with Magic Numbers works just like SIM Swap in Production and only requires you to submit the phone number with your query.
*Note: These phone numbers are examples only and do not include real time data.*

### Below are the Magic Numbers for SIM Swap, along with their Inputs/Outputs:

These phone number examples show the inputs (phone numbers) and their outputs (LastSimSwapDate, SwappedPeriod and SwappedinPeriod).

| Phone Number   | LastSimSwapDate        | SwappedPeriod | SwappedInPeriod |
| -------------- | ---------------------- | ------------- | --------------- |
| +12345678900   | null                   | PT48H         | FALSE           |
| +12345678901   | null                   | PT24H         | FALSE           |
| +12345678904   | null                   | PT48H         | FALSE           |
| +12345678907   | null                   | PT24H         | FALSE           |
| +12345678924   | null                   | PT24H         | TRUE            |
| +441234567890  | "2018-07-25T11:47:40Z" | PT48H         | FALSE           |
| +491534567890  | "2018-07-25T11:47:40Z" | PT48H         | FALSE           |
| +3933444567890 | null                   | PT48H         | FALSE           |
| +31223456780   | "2018-07-25T11:47:40Z" | PT48H         | FALSE           |
| +34712345670   | "2018-07-25T11:47:40Z" | PT48H         | FALSE           |
| +551234567890  | null                   | PT48H         | FALSE           |
| +573394567890  | null                   | PT48H         | FALSE           |
| +441234567891  | "2020-04-27T10:18:50Z" | PT48H         | TRUE            |
| +491534567891  | "2020-04-27T10:18:50Z" | PT48H         | TRUE            |
| +3933444567891 | null                   | PT48H         | TRUE            |
| +31223456781   | "2020-04-27T10:18:50Z" | PT48H         | TRUE            |
| +34712345671   | "2020-04-27T10:18:50Z" | PT48H         | TRUE            |
| +551234567891  | null                   | PT48H         | TRUE            |
| +573394567891  | null                   | PT48H         | TRUE            |

These phone number examples show different types of errors when using SIM Swap.

| Phone Number | Error Code                      |
| ------------ | ------------------------------- |
| +12345678905 | [60004](/docs/api/errors/60004) |
| +12345678906 | [60005](/docs/api/errors/60005) |
| +12345678909 | [60008](/docs/api/errors/60008) |
| +12345678910 | [60601](/docs/api/errors/60601) |
| +12345678911 | [60606](/docs/api/errors/60606) |
| +12345678912 | [60608](/docs/api/errors/60608) |
| +12345678913 | [60614](/docs/api/errors/60614) |
| +12345678915 | [60619](/docs/api/errors/60619) |
| +12345678916 | [60620](/docs/api/errors/60620) |

SIM Swap Lookup

```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.lookups.v2
    .phoneNumbers("+447772000001")
    .fetch({ fields: "sim_swap" });

  console.log(phoneNumber.simSwap);
}

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.lookups.v2.phone_numbers("+447772000001").fetch(
    fields="sim_swap"
)

print(phone_number.sim_swap)
```

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

using System;
using Twilio;
using Twilio.Rest.Lookups.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: "+447772000001", fields: "sim_swap");

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

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

import com.twilio.Twilio;
import com.twilio.rest.lookups.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("+447772000001").setFields("sim_swap").fetch();

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

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	lookups "github.com/twilio/twilio-go/rest/lookups/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 := &lookups.FetchPhoneNumberParams{}
	params.SetFields("sim_swap")

	resp, err := client.LookupsV2.FetchPhoneNumber("+447772000001",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.SimSwap != (lookups.SimSwapInfo{}) {
			fmt.Println(resp.SimSwap)
		} else {
			fmt.Println(resp.SimSwap)
		}
	}
}
```

```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->lookups->v2
    ->phoneNumbers("+447772000001")
    ->fetch(["fields" => "sim_swap"]);

print $phone_number->simSwap;
```

```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
               .lookups
               .v2
               .phone_numbers('+447772000001')
               .fetch(fields: 'sim_swap')

puts phone_number.sim_swap
```

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

twilio api:lookups:v2:phone-numbers:fetch \
   --phone-number +447772000001 \
   --fields sim_swap
```

```bash
curl -X GET "https://lookups.twilio.com/v2/PhoneNumbers/%2B447772000001?Fields=sim_swap" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "calling_country_code": "44",
  "country_code": "GB",
  "phone_number": "+447772000001",
  "national_format": "07772 000001",
  "valid": true,
  "validation_errors": null,
  "caller_name": null,
  "sim_swap": {
    "last_sim_swap": {
      "last_sim_swap_date": "2020-04-27T10:18:50Z",
      "swapped_period": "PT48H",
      "swapped_in_period": true
    },
    "carrier_name": "Vodafone UK",
    "mobile_country_code": "276",
    "mobile_network_code": "02",
    "error_code": null
  },
  "call_forwarding": null,
  "line_status": null,
  "line_type_intelligence": null,
  "identity_match": null,
  "reassigned_number": null,
  "sms_pumping_risk": null,
  "phone_number_quality_score": null,
  "pre_fill": null,
  "url": "https://lookups.twilio.com/v2/PhoneNumbers/+447772000001"
}
```
