Get the SDK

We provide SDKs for Node.js, Python, and Go to make your life easier.

npm add @prelude.so/sdk

Want to see another language make its way to the list? Tell us

Initialize the SDK

Initialize the SDK by pasting the snippet below.

Get your API_KEY from the Settings > Keys page of your Dashboard.

import Prelude from "@prelude.so/sdk";

const client = new Prelude({
  apiKey: "YOUR_API_KEY",
});

Send a code

Call the Create Verification endpoint to send a verification code to a phone number. You will receive a code by SMS.

import Prelude from "@prelude.so/sdk";

const client = new Prelude();

async function main() {
  const verification = await client.verification.create({
    target: {
      type: "phone_number",
      value: "+30123456789",
    },
  });

  console.log(verification.id);
}

main();

Verify the code

Call the Check endpoint with the same phone number and the code you received.

import Prelude from "@prelude.so/sdk";

const client = new Prelude();

async function main() {
  const check = await client.verification.check({
    target: {
      type: "phone_number",
      value: "+30123456789",
    },
    code: "123456",
  });

  console.log(check.id);
}

main();

Congratulations, you’ve just integrated Prelude! Now, you can go to the Dashboard and see your OTP codes in the Authentications tab.


Going further

Here are a few more steps before moving on to production:

1

Test your integration

To make sure your integration is correct, use test numbers in your automated tests. Add them in the Settings > API tab.

2

Add fraud signals

Add Signals such as ip, device_id and is_trusted_user to your Verification requests to better prevent fraud and reduce your expenses.


Next steps

Get more in-depth with our guides to prepare your integration for production:

API Reference

Learn more about Prelude’s API endpoints.