Skip to main content
Version: Node.js

Your First Verification

This guide will help you get started with the Number Verify API by going through the steps to perform your first verification.

Prerequisites

Before you begin, you need to have the following:

Step 1: Get your API Credentials

To get your API Credentials, you can go to the Number Verify Product Page and click on "Manage on Provider" to access the service dashboard. For a full guide on how to get your credentials, you can refer to the Registration guide.

Step 2: Create a new project

Create a new folder and enter the folder from a terminal.

mkdir number-verify-test
cd number-verify-test

Step 3: Initialize the SDK and Web Server

npm init -y
npm install glide-sdk

Step 4: Perform a Verification

index.ts
import { GlideClient } from "glide-sdk";

async function main() {
const glide = new GlideClient({
"clientId": <GLIDE_CLIENT_ID>,
"clientSecret": <GLIDE_CLIENT_SECRET>
});

const phoneNumber = '+555123456789';

// Authenticate and get session token
const authURL = await glide.numberVerify.getAuthUrl({
useDevNumber: phoneNumber,
printCode: true
});

const res = await fetch(authURL);
const { code } = await res.json();

const userClient = await glide.numberVerify.forUser({
code, phoneNumber
});

// Verify phone number
const verificationRes = await userClient.verifyNumber();
console.log(verificationRes);
}

main();

The code starts by generating an authentication URL to be used by the user's device to identify the device. printCode is used to print the code for testing instead of the auth server redirecting to the registered callback URL.

The code then fetches the URL and extracts the code from the response. This code is then used to create a user client to verify the phone number. The verification response is then logged to the console.

info

Since we are using the test number +555123456789, the authentication url can be simply fetched from the script instead of running from the user's device.

To execute this you can run the following from a terminal in the directory of your code:

npx tsx index.ts

Next Steps

Congratulations! You have successfully performed your first verification using the Number Verify API. Next, you can follow our 5-minute quickstart to deploying a test application using the Number Verify API.