OTP
Primary flow: POST /v1/otp/send → user enters code → POST /v1/otp/verify. Default delivery_mode=auto tries WhatsApp then SMS.
Send (SEED generates the code)
// SEED generates a 6-digit code, tries WhatsApp then SMS
const otp = await client.otp.send({
to: "+22890000000",
reference: "login-1",
deliveryMode: "auto", // auto | whatsapp | sms
requestMessagingConsent: false,
});
console.log(otp.challengeId, otp.channel, otp.expiresAt, otp.fallbackUsed);
// Store challengeId server-side until the user submits the code
Send (you supply the code)
// You own the code (must be 4-8 digits)
const otp = await client.otp.send({
to: "+22890000000",
code: "482917",
reference: "checkout-42",
deliveryMode: "auto",
requestMessagingConsent: false,
});
Verify
const result = await client.otp.verify({
challengeId: otp.challengeId,
code: "482917",
});
console.log(result.verified, result.status); // true, "verified"
Poll challenge status
const status = await client.otp.get(otp.challengeId);
console.log(status.status, status.attempts, status.channel, status.expiresAt);
WhatsApp only (no SMS fallback)
Requires a client-supplied code. Prefer otp.send with delivery_mode=auto for production.
// No SMS fallback - code is required
const wa = await client.whatsapp.otp.send({
to: "+22890000000",
code: "482917",
reference: "login-wa-only",
});
console.log(wa.challengeId, wa.wamid);
Email
Send from a verified domain (or SEED shared domains). Maps to POST /v1/emails. At least text or html is required.
Send plain text
const email = await client.email.send({
to: ["[email protected]"],
fromEmail: "[email protected]",
subject: "Welcome to SEED",
text: "Thanks for joining us.",
reference: "welcome-1",
});
console.log(email.id, email.status);
Send with HTML
Bulk send
const bulk = await client.email.sendBulk({
messages: [
{
to: ["[email protected]"],
fromEmail: "[email protected]",
subject: "Hello A",
text: "Message A",
},
{
to: ["[email protected]"],
fromEmail: "[email protected]",
subject: "Hello B",
text: "Message B",
},
],
});
for (const item of bulk.results) {
console.log(item.id, item.status);
}