### Identity Match lookup in Go Source: https://www.twilio.com/docs/lookup/v2-api/identity-match.md Go example using the Twilio Lookups v2 API to perform an identity_match lookup. Requires the twilio-go helper library and environment variables TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET. The example fetches a phone number with identity_match fields and prints the calling country code, handling errors by exiting with status 1. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) params := &lookups.FetchPhoneNumberParams{} params.SetFields("identity_match") params.SetFirstName("John") params.SetLastName("Doe") params.SetAddressLine1("321 Main Street") params.SetAddressLine2("Suite 2") params.SetCity("New York") params.SetState("NY") params.SetPostalCode("10021") params.SetAddressCountryCode("US") params.SetNationalId("YZ3456883") params.SetDateOfBirth("19901214") resp, err := client.LookupsV2.FetchPhoneNumber("+14159929960", params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { if resp.CallingCountryCode != nil { fmt.Println(*resp.CallingCountryCode) } else { fmt.Println(resp.CallingCountryCode) } } } ``` -------------------------------- ### Fetch Caller Name (Go) Source: https://www.twilio.com/docs/lookup/v2-api/caller-name.md Example using the Twilio Go helper library to fetch the caller name for a phone number via the Lookup v2 API. ```APIDOC ## Fetch Caller Name (Go) ### Description Fetches the caller name for a phone number using the Twilio Lookup v2 API with the Go helper library. ### Method GET ### Endpoint /lookups/v2/phoneNumbers/{phoneNumber} ### Parameters #### Path Parameters - **phoneNumber** (string) - Required - The phone number to look up, e.g., "+14159929960". #### Query Parameters - **fields** (string) - Required - Comma-separated list of fields to retrieve, e.g., "caller_name". ### Request Example ```go params := &lookups.FetchPhoneNumberParams{} params.SetFields("caller_name") resp, err := client.LookupsV2.FetchPhoneNumber("+14159929960", params) ``` ### Response #### Success Response (200) - **CallerName** (string) - The caller name associated with the phone number. #### Response Example ```go fmt.Println(resp.CallerName) ``` ``` -------------------------------- ### Fetch call forwarding with twilio-cli Source: https://www.twilio.com/docs/lookup/v2-api/call-forwarding.md Uses the twilio-cli to fetch call forwarding details. Requires twilio-cli installed from https://twil.io/cli. The command specifies the phone number and fields. ```bash # Install the twilio-cli from https://twil.io/cli twilio api:lookups:v2:phone-numbers:fetch \ --phone-number +447772000001 \ --fields call_forwarding ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/identity-match.md Code example for Identity Match lookup using the Twilio Lookup API. ```APIDOC ## [GET] /v2/PhoneNumbers/{PhoneNumber} ### Description Fetches a phone number with the identity_match field to perform an Identity Match lookup. ### Method GET ### Endpoint /v2/PhoneNumbers/{PhoneNumber} ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, e.g., +14159929960. #### Query Parameters - **Fields** (string) - Required - Set to "identity_match" to request identity match data. - **FirstName** (string) - Optional - The first name of the person to match. - **LastName** (string) - Optional - The last name of the person to match. - **AddressLine1** (string) - Optional - The first line of the address. - **AddressLine2** (string) - Optional - The second line of the address. - **City** (string) - Optional - The city of the address. - **State** (string) - Optional - The state or region of the address. - **PostalCode** (string) - Optional - The postal code of the address. - **AddressCountryCode** (string) - Optional - The ISO country code of the address. - **NationalId** (string) - Optional - The national ID of the person. - **DateOfBirth** (string) - Optional - The date of birth in YYYYMMDD format. ### Request Example GET /v2/PhoneNumbers/+14159929960?Fields=identity_match&FirstName=John&LastName=Doe&AddressLine1=321%20Main%20Street&AddressLine2=Suite%202&City=New%20York&State=NY&PostalCode=10021&AddressCountryCode=US&NationalId=YZ3456883&DateOfBirth=19901214 ### Response #### Success Response (200) - **CallingCountryCode** (string) - The calling country code of the phone number. #### Response Example { "calling_country_code": "US" } ``` -------------------------------- ### Fetch SIM Swap with Twilio Lookups v2 in Go Source: https://www.twilio.com/docs/lookup/v2-api/sim-swap.md Go example using the Twilio Lookups v2 API to fetch SIM swap information for a phone number. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Prints the simSwap object or an error message to the console. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) 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 { fmt.Println(resp.SimSwap) } } ``` -------------------------------- ### Fetch phone number with data packages in C# Source: https://www.twilio.com/docs/lookup/v2-api.md C# / .NET example using the Twilio helper library to fetch phone number data with the sim_swap and call_forwarding fields. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY"); string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET"); string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); TwilioClient.Init(apiKey, apiSecret, accountSid); var phoneNumber = await PhoneNumberResource.FetchAsync( pathPhoneNumber: "+447772000001", fields: "sim_swap,call_forwarding"); Console.WriteLine(phoneNumber.Valid); } } ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/identity-match.md This snippet documents the Lookup v2 PhoneNumber fetch operation with identity match fields, as shown in the source code examples. ```APIDOC ## [GET] /v2/PhoneNumbers/{PhoneNumber} ### Description Fetches phone number information with identity match fields for a given phone number. ### Method GET ### Endpoint /v2/PhoneNumbers/{PhoneNumber} ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, e.g., "+14159929960". #### Query Parameters - **fields** (string) - Required - Set to "identity_match" to include identity match data. - **firstName** (string) - Optional - First name for identity match. - **lastName** (string) - Optional - Last name for identity match. - **addressLine1** (string) - Optional - First line of address. - **addressLine2** (string) - Optional - Second line of address. - **city** (string) - Optional - City name. - **state** (string) - Optional - State or region. - **postalCode** (string) - Optional - Postal code. - **addressCountryCode** (string) - Optional - Country code for address. - **nationalId** (string) - Optional - National ID number. - **dateOfBirth** (string) - Optional - Date of birth in YYYYMMDD format. ### Request Example GET /v2/PhoneNumbers/+14159929960?fields=identity_match&firstName=John&lastName=Doe&addressLine1=321%20Main%20Street&addressLine2=Suite%202&city=New%20York&state=NY&postalCode=10021&addressCountryCode=US&nationalId=YZ3456883&dateOfBirth=19901214 ### Response #### Success Response (200) - **callingCountryCode** (string) - The calling country code of the phone number. #### Response Example { "callingCountryCode": "US" } ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/magic-numbers-for-lookup/testing-sim-swap-with-magic-numbers.md This snippet documents the Lookups v2 PhoneNumbers fetch operation for retrieving SIM swap information. It includes the HTTP endpoint, parameters, and an example request. ```APIDOC ## [GET] /v2/PhoneNumbers/{PhoneNumber} ### Description Fetches SIM swap information for a phone number using the Lookups v2 API. This endpoint returns details about whether the phone number has been swapped to a new SIM card. ### Method GET ### Endpoint https://lookups.twilio.com/v2/PhoneNumbers/{PhoneNumber} ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, in E.164 format (e.g., +447772000001). #### Query Parameters - **Fields** (string) - Required - A comma-separated list of fields to include in the response. Set to `sim_swap` to retrieve SIM swap information. ### Request Example ``` curl -X GET "https://lookups.twilio.com/v2/PhoneNumbers/%2B447772000001?Fields=sim_swap" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN ``` ### Response #### Success Response (200) - **sim_swap** (object) - Contains SIM swap information for the phone number. #### Response Example ``` { "sim_swap": { "carrier_name": "Example Carrier", "last_swapped_at": "2023-01-01T00:00:00Z", "swapped_period": "P1D" } } ``` ``` -------------------------------- ### Fetch SIM Swap with Twilio Lookups v2 in C# Source: https://www.twilio.com/docs/lookup/v2-api/sim-swap.md C# / .NET example using the Twilio Lookups v2 API to fetch SIM swap information for a phone number. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Outputs the simSwap object to the console. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY"); string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET"); string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); TwilioClient.Init(apiKey, apiSecret, accountSid); var phoneNumber = await PhoneNumberResource.FetchAsync( pathPhoneNumber: "+447772000001", fields: "sim_swap"); Console.WriteLine(phoneNumber._SimSwap); } } ``` -------------------------------- ### Fetch phone number with data packages in Java Source: https://www.twilio.com/docs/lookup/v2-api.md Java example using the Twilio helper library to fetch phone number data with the sim_swap and call_forwarding fields. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token public static final String API_KEY = System.getenv("TWILIO_API_KEY"); public static final String API_SECRET = System.getenv("TWILIO_API_SECRET"); public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); public static void main(String[] args) { Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID); PhoneNumber phoneNumber = PhoneNumber.fetcher("+447772000001").setFields("sim_swap,call_forwarding").fetch(); System.out.println(phoneNumber.getValid()); } } ``` -------------------------------- ### Make a SIM Swap API request with curl Source: https://www.twilio.com/docs/lookup/lookup-sim-swap.md Sends a GET request to the Lookup API with the sim_swap field to retrieve SIM swap information for a phone number. The response includes the last_sim_swap object with fields like last_sim_swap_date, swapped_period, and swapped_in_period. The example uses the Ireland region (IE1) and requires a Twilio API key and secret. ```bash curl -X GET \ 'https://lookups.dublin.ie1.twilio.com/v2/PhoneNumbers/+447772000001?Fields=sim_swap' \ -u $TWILIO_API_KEY:$TWILIO_API_KEY_SECRET ``` ```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": "PT15282H33M44S", "swapped_in_period": false }, "carrier_name": "Vodafone UK", "mobile_country_code": "276", "mobile_network_code": "02", "error_code": null }, "call_forwarding": null, "line_type_intelligence": null, "url": "https://lookups.dublin.ie1.twilio.com/v2/PhoneNumbers/+447772000001" } ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/sim-swap.md Check a phone number's SIM swap status by making a GET request with the Fields=sim_swap query parameter. ```APIDOC ## GET /v2/PhoneNumbers/{PhoneNumber} ### Description Check a phone number's SIM swap status by making a GET request with the `Fields=sim_swap` query parameter. ### Method GET ### Endpoint `https://lookups.twilio.com/v2/PhoneNumbers/{PhoneNumber}` ### Parameters #### Query Parameters - **Fields** (string) - Required - Set to `sim_swap` to request SIM swap information. #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to check, URL-encoded (e.g., `%2B15017122661`). ### Request Example ```bash curl -X GET "https://lookups.twilio.com/v2/PhoneNumbers/%2B15017122661?Fields=sim_swap" \ -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **MobileCountryCode** (string) - The three-digit mobile country code of the carrier. - **MobileNetworkCode** (string) - The two- or three-digit mobile network code of the carrier. - **CarrierName** (string) - The name of the carrier. - **LastSimSwap** (object) - An object containing information on the last date the SIM was changed. - **ErrorCode** (string) - The error code, if any, associated with the request. #### Response Example ```json { "MobileCountryCode": "string", "MobileNetworkCode": "string", "CarrierName": "string", "LastSimSwap": { "LastSimSwapDate": "string", "SwappedPeriod": "string", "SwappedInPeriod": "boolean" }, "ErrorCode": "string" } ``` ### LastSimSwap Properties - **LastSimSwapDate** (string) - The ISO-8601 date and timestamp for when the SIM was last changed. Only returned for GB, DE, ES, and NL. - **SwappedPeriod** (string) - A threshold the customer has chosen during which `SwappedInPeriod` indicates if the SIM was changed within the threshold. - **SwappedInPeriod** (boolean) - A Boolean indicating whether the SIM was changed during the trailing `SwappedPeriod`. ``` -------------------------------- ### Fetch phone number with data packages in Python Source: https://www.twilio.com/docs/lookup/v2-api.md Python example using the Twilio helper library to fetch phone number data with the sim_swap and call_forwarding fields. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID at twilio.com/console # Provision API Keys at twilio.com/console/runtime/api-keys # and set the environment variables. See http://twil.io/secure # For local testing, you can use your Account SID and Auth token api_key = os.environ["TWILIO_API_KEY"] api_secret = os.environ["TWILIO_API_SECRET"] account_sid = os.environ["TWILIO_ACCOUNT_SID"] client = Client(api_key, api_secret, account_sid) phone_number = client.lookups.v2.phone_numbers("+447772000001").fetch( fields="sim_swap,call_forwarding" ) print(phone_number.valid) ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/caller-name.md This snippet documents the GET /v2/PhoneNumbers/{PhoneNumber} endpoint for retrieving caller name information using the Twilio Lookup API. ```APIDOC ## GET /v2/PhoneNumbers/{PhoneNumber} ### Description Retrieve the caller name and type for a US mobile phone number using the Twilio Lookup API. This endpoint requires the `Fields=caller_name` query parameter. ### Method GET ### Endpoint `https://lookups.twilio.com/v2/PhoneNumbers/{PhoneNumber}` ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, in E.164 format (e.g., `+14159929960`). #### Query Parameters - **Fields** (string) - Required - Set to `caller_name` to request caller name data. ### Request Example ```bash curl -X GET "https://lookups.twilio.com/v2/PhoneNumbers/%2B14159929960?Fields=caller_name" \ -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **CallerName** (string) - The name of the owner of the phone number. If not available, this will be `null`. - **CallerType** (string) - The caller type. Possible values are `BUSINESS` and `CONSUMER`. If not available, this will be `null`. - **ErrorCode** (string) - The error code, if any, associated with your request. #### Response Example ```json { "CallerName": "John Doe", "CallerType": "CONSUMER", "ErrorCode": null } ``` ``` -------------------------------- ### Basic Lookup with Fields in Go, PHP, and Ruby Source: https://www.twilio.com/docs/lookup/v2-api.md Basic Lookup request using the Twilio Lookups v2 API with the sim_swap and call_forwarding data packages. Each example uses the Twilio helper library for its language and requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. The response's valid field is printed. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) params := &lookups.FetchPhoneNumberParams{} params.SetFields("sim_swap,call_forwarding") resp, err := client.LookupsV2.FetchPhoneNumber("+447772000001", params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { fmt.Println(resp.Valid) } } ``` ```php lookups->v2 ->phoneNumbers("+447772000001") ->fetch(["fields" => "sim_swap,call_forwarding"]); print $phone_number->valid; ``` ```ruby # Download the helper library from https://www.twilio.com/docs/ruby/install require 'twilio-ruby' # Find your Account SID at twilio.com/console # Provision API Keys at twilio.com/console/runtime/api-keys # and set the environment variables. See http://twil.io/secure # For local testing, you can use your Account SID and Auth token api_key = ENV['TWILIO_API_KEY'] api_secret = ENV['TWILIO_API_SECRET'] account_sid = ENV['TWILIO_ACCOUNT_SID'] @client = Twilio::REST::Client.new(api_key, api_secret, account_sid) phone_number = @client .lookups .v2 .phone_numbers('+447772000001') .fetch(fields: 'sim_swap,call_forwarding') puts phone_number.valid ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/sms-pumping-risk.md Retrieves the SMS Pumping Risk Score for a phone number by making a GET request to the Lookup v2 API with the Fields=sms_pumping_risk query parameter. ```APIDOC ## GET /v2/PhoneNumbers/{PhoneNumber} ### Description Retrieves the SMS Pumping Risk Score for a phone number by making a GET request to the Lookup v2 API with the Fields=sms_pumping_risk query parameter. ### Method GET ### Endpoint /v2/PhoneNumbers/{PhoneNumber} ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, e.g., +447772000001. #### Query Parameters - **Fields** (string) - Required - Set to `sms_pumping_risk` to include the SMS Pumping Risk Score in the response. ### Request Example GET /v2/PhoneNumbers/+447772000001?Fields=sms_pumping_risk ### Response #### Success Response (200) - **smsPumpingRisk** (object) - Contains the SMS Pumping Risk Score details. #### Response Example { "smsPumpingRisk": { "riskScore": 0 } } ``` -------------------------------- ### Fetch SIM Swap with Twilio Lookups v2 in Java Source: https://www.twilio.com/docs/lookup/v2-api/sim-swap.md Java example using the Twilio Lookups v2 API to fetch SIM swap information for a phone number. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Prints the simSwap object to the console. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token public static final String API_KEY = System.getenv("TWILIO_API_KEY"); public static final String API_SECRET = System.getenv("TWILIO_API_SECRET"); public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID"); public static void main(String[] args) { Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID); PhoneNumber phoneNumber = PhoneNumber.fetcher("+447772000001").setFields("sim_swap").fetch(); System.out.println(phoneNumber.getSimSwap()); } } ``` -------------------------------- ### GET /v2/PhoneNumbers/{PhoneNumber} Source: https://www.twilio.com/docs/lookup/v2-api/call-forwarding.md Retrieves call forwarding information for a specified phone number. Use the Fields query parameter set to 'call_forwarding' to get the call forwarding status. ```APIDOC ## GET /v2/PhoneNumbers/{PhoneNumber} ### Description Retrieves call forwarding information for a specified phone number. Use the Fields query parameter set to 'call_forwarding' to get the call forwarding status. ### Method GET ### Endpoint https://lookups.twilio.com/v2/PhoneNumbers/{PhoneNumber} ### Parameters #### Path Parameters - **PhoneNumber** (string) - Required - The phone number to look up, in E.164 format (e.g., +14159929960). #### Query Parameters - **Fields** (string) - Required - Set to 'call_forwarding' to request call forwarding information. ### Request Example ```bash curl -X GET "https://lookups.twilio.com/v2/PhoneNumbers/%2B14159929960?Fields=call_forwarding" \ -u $TWILIO_API_KEY:$TWILIO_API_SECRET ``` ### Response #### Success Response (200) - **CallForwardingStatus** (boolean) - Indicates whether unconditional call forwarding is set for the requested mobile phone number. - **ErrorCode** (string) - The error code, if any, associated with your request. #### Response Example (No explicit response example provided in the source.) ``` -------------------------------- ### Fetch SIM Swap with Twilio Lookups v2 in Python Source: https://www.twilio.com/docs/lookup/v2-api/sim-swap.md Python example using the Twilio Lookups v2 API to fetch SIM swap information for a phone number. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Prints the simSwap object to the console. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client # Find your Account SID at twilio.com/console # Provision API Keys at twilio.com/console/runtime/api-keys # and set the environment variables. See http://twil.io/secure # For local testing, you can use your Account SID and Auth token api_key = os.environ["TWILIO_API_KEY"] api_secret = os.environ["TWILIO_API_SECRET"] account_sid = os.environ["TWILIO_ACCOUNT_SID"] client = Client(api_key, api_secret, account_sid) phone_number = client.lookups.v2.phone_numbers("+447772000001").fetch( fields="sim_swap" ) print(phone_number.sim_swap) ``` -------------------------------- ### Identity Match API Response Example Source: https://www.twilio.com/docs/lookup/magic-numbers-for-lookup/testing-identity-match-with-magic-numbers.md Example JSON response from the Lookups API v2 identity_match request. Shows match results for each field, including exact_match, high_partial_match, no_match, and no_data_available, with a summary_score of 90. ```json { "calling_country_code": "1", "country_code": "US", "phone_number": "+14159929960", "national_format": "(415) 992-9960", "valid": true, "validation_errors": [], "caller_name": null, "sim_swap": null, "call_forwarding": null, "line_status": null, "line_type_intelligence": null, "identity_match": { "first_name_match": "exact_match", "last_name_match": "high_partial_match", "address_lines_match": "no_match", "city_match": "no_match", "state_match": "high_partial_match", "postal_code_match": "no_data_available", "address_country_match": "exact_match", "national_id_match": "exact_match", "date_of_birth_match": "exact_match", "summary_score": 90, "error_code": null, "error_message": null }, "reassigned_number": null, "sms_pumping_risk": null, "phone_number_quality_score": null, "pre_fill": null, "url": "https://lookups.twilio.com/v2/PhoneNumbers/+14159929960" } ``` -------------------------------- ### Fetch caller name with Twilio Lookups v2 in Go Source: https://www.twilio.com/docs/lookup/v2-api/caller-name.md Go example using the Twilio helper library to fetch caller name information for a phone number via the Lookups v2 API. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Outputs the caller name to the console or an error message on failure. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) params := &lookups.FetchPhoneNumberParams{} params.SetFields("caller_name") resp, err := client.LookupsV2.FetchPhoneNumber("+14159929960", params) if err != nil { fmt.Println(err.Error()) os.Exit(1) } else { fmt.Println(resp.CallerName) } } ``` -------------------------------- ### Update override with Twilio C# Source: https://www.twilio.com/docs/lookup/v2-api/line-type-override.md C# example using the Twilio helper library to update a line type override. It requires the `TWILIO_API_KEY`, `TWILIO_API_SECRET`, and `TWILIO_ACCOUNT_SID` environment variables. The example updates the override for phone number `+14159929960` with `line_type` set to `mobile` and prints the phone number. ```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; using System.Collections.Generic; class Program { public static async Task Main(string[] args) { // Find your Account SID at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY"); string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET"); string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); TwilioClient.Init(apiKey, apiSecret, accountSid); var lookupOverride = await LookupOverrideResource.UpdateAsync( new UpdateLookupOverrideOptions("line_type_intelligence", "+14159929960") { OverridesRequest = new LookupOverrideResource.OverridesRequest.Builder() .WithLineType("mobile") .Build() }); Console.WriteLine(lookupOverride.PhoneNumber); } } ``` -------------------------------- ### Fetch phone number with Twilio Lookups v2 in C# Source: https://www.twilio.com/docs/lookup/v2-api.md C# example using the Twilio Lookups v2 API to fetch phone number details. Requires the Twilio C#/.NET helper library and environment variables TWILIO_API_KEY, TWILIO_API_SECRET, and TWILIO_ACCOUNT_SID. Outputs the national format of the phone number. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY"); string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET"); string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); TwilioClient.Init(apiKey, apiSecret, accountSid); var phoneNumber = await PhoneNumberResource.FetchAsync(pathPhoneNumber: "+141599299600"); Console.WriteLine(phoneNumber.NationalFormat); } } ``` -------------------------------- ### Fetch caller name with Twilio Lookups v2 in C# Source: https://www.twilio.com/docs/lookup/v2-api/caller-name.md C# / .NET example using the Twilio helper library to fetch caller name information for a phone number via the Lookups v2 API. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. Outputs the caller name to the console. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY"); string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET"); string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); TwilioClient.Init(apiKey, apiSecret, accountSid); var phoneNumber = await PhoneNumberResource.FetchAsync( pathPhoneNumber: "+14159929960", fields: "caller_name"); Console.WriteLine(phoneNumber._CallerName); } } ``` -------------------------------- ### Update override with Twilio Python Source: https://www.twilio.com/docs/lookup/v2-api/line-type-override.md Python example using the Twilio helper library to update a line type override. It requires the `TWILIO_API_KEY`, `TWILIO_API_SECRET`, and `TWILIO_ACCOUNT_SID` environment variables. The example updates the override for phone number `+14159929960` with `line_type` set to `mobile` and prints the phone number. ```python # Download the helper library from https://www.twilio.com/docs/python/install import os from twilio.rest import Client from twilio.rest.lookups.v2 import LookupOverrideList # Find your Account SID at twilio.com/console # Provision API Keys at twilio.com/console/runtime/api-keys # and set the environment variables. See http://twil.io/secure # For local testing, you can use your Account SID and Auth token api_key = os.environ["TWILIO_API_KEY"] api_secret = os.environ["TWILIO_API_SECRET"] account_sid = os.environ["TWILIO_ACCOUNT_SID"] client = Client(api_key, api_secret, account_sid) lookup_phone_number_overrides = client.lookups.v2.lookup_overrides( "+14159929960", "line_type_intelligence" ).update( overrides_request=LookupOverrideList.OverridesRequest( {"line_type": "mobile"} ) ) print(lookup_phone_number_overrides.phone_number) ``` -------------------------------- ### Update override with Twilio Node.js Source: https://www.twilio.com/docs/lookup/v2-api/line-type-override.md Node.js example using the Twilio helper library to update a line type override. It requires the `TWILIO_ACCOUNT_SID`, `TWILIO_API_KEY`, and `TWILIO_API_SECRET` environment variables. The example updates the override for phone number `+14159929960` with `line_type` set to `mobile` and logs the phone number. ```javascript // 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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token const accountSid = process.env.TWILIO_ACCOUNT_SID; const apiKey = process.env.TWILIO_API_KEY; const apiSecret = process.env.TWILIO_API_SECRET; const client = twilio(apiKey, apiSecret, { accountSid: accountSid }); async function updateLookupPhoneNumberOverrides() { const lookupOverride = await client.lookups.v2 .lookupOverrides("+14159929960", "line_type_intelligence") .update({ line_type: "mobile", }); console.log(lookupOverride.phoneNumber); } updateLookupPhoneNumberOverrides(); ``` -------------------------------- ### Fetch phone number with data packages in Node.js Source: https://www.twilio.com/docs/lookup/v2-api.md Node.js example using the Twilio helper library to fetch phone number data with the sim_swap and call_forwarding fields. Requires TWILIO_ACCOUNT_SID, TWILIO_API_KEY, and TWILIO_API_SECRET environment variables. ```javascript // 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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token const accountSid = process.env.TWILIO_ACCOUNT_SID; const apiKey = process.env.TWILIO_API_KEY; const apiSecret = process.env.TWILIO_API_SECRET; const client = twilio(apiKey, apiSecret, { accountSid: accountSid }); async function fetchPhoneNumber() { const phoneNumber = await client.lookups.v2 .phoneNumbers("+447772000001") .fetch({ fields: "sim_swap,call_forwarding" }); console.log(phoneNumber.valid); } fetchPhoneNumber(); ``` -------------------------------- ### Identity Match lookup in PHP Source: https://www.twilio.com/docs/lookup/v2-api/identity-match.md PHP example using the Twilio Lookups v2 API to perform an identity_match lookup. Requires the Twilio PHP helper library and environment variables TWILIO_API_KEY, TWILIO_API_SECRET, and TWILIO_ACCOUNT_SID. The example fetches a phone number with identity_match fields and prints the calling country code. ```php lookups->v2->phoneNumbers("+14159929960")->fetch([ "fields" => "identity_match", "firstName" => "John", "lastName" => "Doe", "addressLine1" => "321 Main Street", "addressLine2" => "Suite 2", "city" => "New York", "state" => "NY", "postalCode" => "10021", "addressCountryCode" => "US", "nationalId" => "YZ3456883", "dateOfBirth" => "19901214", ]); print $phone_number->callingCountryCode; ``` -------------------------------- ### Perform a Basic Lookup with Go Source: https://www.twilio.com/docs/lookup/quickstart.md Uses the Twilio Go helper library to fetch phone number information from the Lookups v2 API. Requires the TWILIO_API_KEY, TWILIO_API_SECRET, and TWILIO_ACCOUNT_SID environment variables. Prints the phone number or an error message. ```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 at twilio.com/console // Provision API Keys at twilio.com/console/runtime/api-keys // and set the environment variables. See http://twil.io/secure // For local testing, you can use your Account SID and Auth token accountSid := os.Getenv("TWILIO_ACCOUNT_SID") apiKey := os.Getenv("TWILIO_API_KEY") apiSecret := os.Getenv("TWILIO_API_SECRET") client := twilio.NewRestClientWithParams(twilio.ClientParams{ Username: apiKey, Password: apiSecret, AccountSid: accountSid, }) params := &lookups.FetchPhoneNumberParams{} resp, err := client.LookupsV2.FetchPhoneNumber("+14159929960", 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) } } } ``` -------------------------------- ### Perform a Basic Lookup with twilio-cli Source: https://www.twilio.com/docs/lookup/quickstart.md Uses the twilio-cli to fetch phone number information from the Lookups v2 API. Requires the twilio-cli to be installed and configured with your credentials. The --phone-number flag specifies the phone number to look up. ```bash # Install the twilio-cli from https://twil.io/cli twilio api:lookups:v2:phone-numbers:fetch \ --phone-number +14159929960 ```