Node.js SDK

Install @seed-messages/sdk and send SMS, OTP, and email with one client.

SMS · OTP · Email · package @seed-messages/sdk

Install

1npm install @seed-messages/sdk

Client

Base URL defaults to https://api-messages.seed.tg/v1. Pass sandbox URL for tests.

1import { SeedMessages } from "@seed-messages/sdk";
2
3// Production
4const client = new SeedMessages({ apiKey: "lks_live_xxx" });
5
6// Sandbox (optional)
7// const client = new SeedMessages({
8//   apiKey: "lks_test_xxx",
9//   baseUrl: "https://sandbox-api.seed.tg/v1",
10// });

Recommended API key scopes

sms:sendSMS
otp:sendOTP send
otp:verifyOTP verify
email:sendTransactional email
whatsapp:sendWhatsApp messages (optional)

SMS

Approved Sender ID + E.164 recipient. Maps to POST /v1/messages.

1const sms = await client.sms.send({
2  to: "+22890000000",
3  sender: "SEED",
4  text: "Hello from SEED Messages",
5});
6console.log(sms.id, sms.status);

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)

1// SEED generates a 6-digit code, tries WhatsApp then SMS
2const otp = await client.otp.send({
3  to: "+22890000000",
4  reference: "login-1",
5  deliveryMode: "auto", // auto | whatsapp | sms
6  requestMessagingConsent: false,
7});
8console.log(otp.challengeId, otp.channel, otp.expiresAt, otp.fallbackUsed);
9// Store challengeId server-side until the user submits the code

Send (you supply the code)

1// You own the code (must be 4-8 digits)
2const otp = await client.otp.send({
3  to: "+22890000000",
4  code: "482917",
5  reference: "checkout-42",
6  deliveryMode: "auto",
7  requestMessagingConsent: false,
8});

Verify

1const result = await client.otp.verify({
2  challengeId: otp.challengeId,
3  code: "482917",
4});
5console.log(result.verified, result.status); // true, "verified"

Poll challenge status

1const status = await client.otp.get(otp.challengeId);
2console.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.

1// No SMS fallback - code is required
2const wa = await client.whatsapp.otp.send({
3  to: "+22890000000",
4  code: "482917",
5  reference: "login-wa-only",
6});
7console.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

1const email = await client.email.send({
2  to: ["[email protected]"],
3  fromEmail: "[email protected]",
4  subject: "Welcome to SEED",
5  text: "Thanks for joining us.",
6  reference: "welcome-1",
7});
8console.log(email.id, email.status);

Send with HTML

1const email = await client.email.send({
2  to: ["[email protected]"],
3  fromEmail: "[email protected]",
4  subject: "Your receipt",
5  text: "Thanks for your order.",
6  html: "<p>Thanks for your <strong>order</strong>.</p>",
7  cc: ["[email protected]"],
8});

Bulk send

1const bulk = await client.email.sendBulk({
2  messages: [
3    {
4      to: ["[email protected]"],
5      fromEmail: "[email protected]",
6      subject: "Hello A",
7      text: "Message A",
8    },
9    {
10      to: ["[email protected]"],
11      fromEmail: "[email protected]",
12      subject: "Hello B",
13      text: "Message B",
14    },
15  ],
16});
17for (const item of bulk.results) {
18  console.log(item.id, item.status);
19}