Overview
Send one-time passcodes with the same endpoints you use for any message. Generate the code in your backend, send it with POST /sms/sendSms (or as a WhatsApp authentication template with POST /whatsapp/message/sendbulk), and check what the user types against the code you stored. For code generation and validation as a managed service, see the OTP product page.
Example
Copy, paste, replace the placeholders — these examples call the production API as written.
import { randomInt } from "node:crypto";
import { Configuration, SMSSMSApi } from "@broadnet/cpaas-sdk";
const sms = new SMSSMSApi(
new Configuration({
basePath: "https://api.broadnet.me",
accessToken: process.env.BROADNET_TOKEN!,
}),
);
// 1. Generate and store the code (hash it, with an expiry).
const code = String(randomInt(100000, 1000000));
await otpStore.save("447700900123", code, { ttlSeconds: 300 });
// 2. Send it as a normal SMS.
await sms.smsSendsmsPost({
sMSSmsRequest: {
senderId: "BroadNet",
destinationNumber: "447700900123",
message: `Your verification code is ${code}`,
messageType: "TEXT",
},
});
// 3. Later: compare the code the user typed with the stored one.