Sample application demonstrating how to use the Open Gateway SIM Swap API.
- Node.js 18 or newer (for the native
fetchAPI). - Open Gateway credentials with access to the SIM Swap API.
- Run
npm installonce to install thedotenvdependency (already listed inpackage.json)
- Sign up for a free account at Open Gateway Partner Program
- Access our Sandbox environment at Open Gateway Sandbox
- Create an application subscribing to the SIM Swap API to obtain your
client_idandclient_secret.
Set the following variables before running the CLI:
| Variable | Description |
|---|---|
OG_CLIENT_ID |
OAuth client ID issued for your application. |
OG_CLIENT_SECRET |
OAuth client secret. |
OG_API_GATEWAY |
Full URL of the Open Gateway API Gateway endpoint. |
OG_SIMSWAP_SCOPE |
Scope for the SIM Swap API (e.g. dpv:FraudPreventionAndDetection sim-swap). |
OG_COUNTRY_CODE |
Country code (e.g., 34 for Spain) to be included in the SIM Swap request payload for the provided phone number. |
You can create a .env file in the project root with the following content:
OG_CLIENT_ID=your-client-id
OG_CLIENT_SECRET=your-client-secret
OG_API_GATEWAY=https://sandbox.opengateway.telefonica.com/apigateway
OG_SIMSWAP_SCOPE="dpv:FraudPreventionAndDetection sim-swap"
OG_COUNTRY_CODE=+34node simswap.jsThe script prompts for a phone number, authenticates your application and the end-user by their phone number, and retrieves the SIM swap date.
$ node simswap.js
[[email protected]] injecting env (5) from .env -- tip: 🗂️ backup and recover secrets: https://dotenvx.com/ops
Open Gateway SIM Swap Sample App
Enter phone number: (+34) 600123456
SIM Swap Date: 19 de agosto de 2025You can easily try out this sample application in a GitHub Codespace without needing to fork the repository or set up your local environment. Just follow these steps:
- Open the repository in GitHub Codespaces by appending
/codespacesto the repository URL. - Create a
.envfile in the root of the project and add your Open Gateway credentials and configuration as described above. - In the terminal panel, run the application using
node simswap.jsand follow the prompts to test the SIM Swap API functionality.