SIM Swap

Network as Code provides identity and security capabilities that allow your applications to prevent or proactively react to fraud by using resources that go beyond traditional 2FA authentication processes. The SIM Swap feature allows you to check SIM swapping events in real-time. It strengthens the security of SIM-based authentication methods, such as SMS One-Time Passwords, which can help mitigate the severity of account takeover fraud. This is particularly important due to fraudulent transactions employing SIM swapping techniques to intercept SMS messages, enabling fraudsters to reset passwords or obtain verification codes to gain unauthorized access to secured accounts.

You can easily integrate the SIM Swap functionalities to your applications and shield them with an extra layer of security against fraudulent attempts, such as SIM swapping.

What does this feature do?

  1. It tells when a SIM was swapped with precision by providing the latest date and time it happened.

    If a SIM swap has not happened, it can return a null value or the SIM activation date.

  2. Allows you to check if a SIM was swapped recently with a specific time span that you can define. So, you can answer the question: Has the event occurred within the last n hours?

Terminology and acronymsheader link

What's behind this technology?header link

The SIM Swap functionality follows CAMARA definitions, which is an open-source project within Linux foundation. Network as Code bridges the gap between your application and the Operator platform making the connection seamless so you can retrieve SIM swap data. After you register on Network as Code Developer Portal and get consent & authorization for devices, you will be able to easily use and integrate this API into your applications.

SIM Swap SDKheader link

Here's a hypothetical scenario of a SIM-swap fraud: Someone received a message seemingly from their bank requesting to verify personal account details. The person clicks the link, assuming it's legitimate, and provides the details. In the meanwhile, a fraudster contacts the victim's mobile carrier requesting a SIM swap and providing the personal account details provided in the phishing link sent before. Once the fraudster transfers the victim's phone number to a new SIM card they can control, they can illicitly gain access to accounts, personal data, or commit other identity-theft related crimes.

Retrieving latest SIM Swap dateheader link

With the SIM Swap SDK, you can easily retrieve the latest date for when a SIM was swapped.

import network_as_code as nac

from network_as_code.models.device import Device

# Initialize the client object with your application key
client = nac.NetworkAsCodeClient(
    token="<your-application-key-here>"
)

# Then, create a device object for the phone number you want to check
my_device = client.devices.get(
    # The phone number does not accept spaces or parentheses
    phone_number="+99999991000"
)

# The date of the last SIM Swap can be retrieved like so:
sim_swap_date = my_device.get_sim_swap_date()

# Otherwise it behaves like a regular datetime object
print(f"Last SIM swap (or activation) happened on {sim_swap_date.isoformat()}")

Get SIM Swap date responsesheader link

ResponseTypeDescription
2025-06-19 09:51:44.271000+00:00stringThe latest date for when a SIM Swap has occurred. If no SIM Swap has occured the response can be the SIM activation date.
NoneNoneTypeIf no SIM Swap has occurred, the response can be None.

Checking SIM Swap occurrenceheader link

If you want to verify if a SIM was swapped within the default time period of 240 hours, you can do this with the verify sim swap method with no parameters passed.

if my_device.verify_sim_swap():
    print("A SIM swap has occurred!")

Also, in case you suspect a SIM swap attempt occurred in the last n hours, you can pass this value as a parameter to the verify sim swap method, and precisely check if the fraudulent attempt happened during this time.

if my_device.verify_sim_swap(max_age=1):
    print("A SIM swap has occurred within the past hour!")

Verify SIM Swap parametersheader link

ParameterTypeDescriptionMandatory or Optional
max_ageintegerTime amount in hours, from one hour up to 2400. Can be added as a parameter to the verify sim swap method to check if a SIM swap has occurred within the last n hours. For example .verify_sim_swap(max_age=2)Optional

Verify SIM Swap responsesheader link

ResponseTypeDescription
TruebooleanIndicates, that a SIM swap has occurred. If a max age parameter of n hours was given, indicates that a SIM swap occurred within the last n hours.
FalsebooleanIndicates, that a SIM swap has not occurred. If a max age parameter of n hours was given, indicates that a SIM swap has not occurred within the last n hours.

Simulated SIM swap scenario responsesheader link

The Network as Code simulators have been configured to provide specific SIM swap results for specific simulated devices based on their device identifier. This will be helpful in testing your code against the different responses, including possible errors, by simply substituting the device identifier in your code.

The device identifiers and their responses can be found in the following table:

Device identifier typeDevice identifierHTTP status codeHTTP status code descriptionResponse description
Phone Number+99999991000200SuccessSIM swap has occurred
Phone Number+99999991001200SuccessSIM swap has not occurred

Last updated November 05, 2025