Get the SDK

We provide SDKs for many popular languages to make your life easier.

npm add @ding-live/ding

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 and YOUR_CUSTOMER_UUID from the Settings > API page of your Dashboard.

import { Ding } from "@ding-live/ding";

const ding = new Ding({
  apiKey: "YOUR_API_KEY",
});

Send a code

Call the Authentication endpoint with your phone number. You will receive a code by SMS.

const result = await ding.otp.createAuthentication({
  customerUuid: "YOUR_CUSTOMER_UUID",
  phoneNumber: "+1234567890",
});

In production, we recommend storing the authentication_uuid in a distributed cache like Redis between send and check calls if you use a stateless backend.

Verify the code

Call the Check endpoint with the authentication_uuid returned by the previous call and the code you received.

const result = await ding.otp.check({
  customerUuid: "YOUR_CUSTOMER_UUID",
  authenticationUuid: "AUTHENTICATION_UUID",
  checkCode: "123456",
});

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_address, app_version and is_returning_user to your Authentication requests to better prevent fraud and reduce your expenses.

3

Plug your webhook

Listen to Webhook events to get notified when an OTP is sent or billed.


Next steps

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

API Reference

Learn more about Prelude’s API endpoints.