Skip to content
Go To Dashboard

Quick Start

In this guide, you’ll verify a phone number using Sapiom — no Prelude account required.

  1. Sign in to the Sapiom Dashboard and generate an API key.

    Add your API key to your environment:

    Terminal window
    export SAPIOM_API_KEY="your_api_key_here"
  2. Terminal window
    npm install @sapiom/axios axios
  3. Create a file called verify.ts and add the following code:

    import axios from 'axios';
    import { withSapiom } from '@sapiom/axios';
    const client = withSapiom(axios.create(), {
    apiKey: process.env.SAPIOM_API_KEY!,
    });
    async function sendVerificationCode(phoneNumber: string) {
    const response = await client.post(
    'https://prelude.services.sapiom.ai/verifications',
    {
    target: {
    type: 'phone_number',
    value: phoneNumber,
    },
    }
    );
    console.log('Verification sent!');
    console.log('Verification ID:', response.data.id);
    return response.data.id;
    }
    // Replace with your phone number (E.164 format)
    sendVerificationCode('+15551234567');

    Run it:

    Terminal window
    npx tsx verify.ts

    You’ll receive a text message with a verification code.

  4. Update your file to check the code:

    import axios from 'axios';
    import { withSapiom } from '@sapiom/axios';
    const client = withSapiom(axios.create(), {
    apiKey: process.env.SAPIOM_API_KEY!,
    });
    async function checkVerificationCode(verificationId: string, code: string) {
    const response = await client.post(
    'https://prelude.services.sapiom.ai/verifications/check',
    {
    verificationRequestId: verificationId,
    code: code,
    }
    );
    if (response.data.status === 'success') {
    console.log('Phone number verified!');
    } else {
    console.log('Verification failed:', response.data.status);
    }
    }
    // Use the verification ID from step 3 and the code you received
    checkVerificationCode('your-verification-id', '123456');

    Run it with your verification ID and the code from your text message:

    Terminal window
    npx tsx verify.ts
  5. Open the Sapiom Dashboard to see your verification transaction.

    You just verified a phone number with zero Prelude account setup. That’s the power of Sapiom.

Now that you’ve accessed your first paid service, explore what else you can do: