Skip to main content

Get the Backend SDK

We provide backend SDKs for Node.js, Python, Go, Kotlin/Java and Ruby 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 All Services > Configure > Keys page of the Prelude dashboard.
import Prelude from "@prelude.so/sdk";

const client = new Prelude({
  apiToken: "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",
    },
    // Optional signals dispatchId value, captured in the frontend SDKs
    dispatch_id: "client dispatchId",
  });

  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 Verifications 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 Verify API > Configure > Numbers tab.
2

Add fraud signals

Add Signals such as ip, device_id and device_model 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:

Verification Lifecycle

Understand the verification lifecycle and how it allows you to build a fully-functional OTP flow in your application.

Prevent Fraud

Prevent fraud and only let real users through.

Message Content

Learn the various customization options for your verification messages.

Webhook

Act on events coming from the Verification API.