Node.js

Send SMS in Node.js with @taysend/sdk

Use the official Taysend SDK for typed sends, bulk helpers, and network lookup — or call https://api.taysend.com directly with fetch. Start with a sms_test_ key and simulated numbers.

Setup

Install

npm
npm install @taysend/sdk

Send

Send SMS

messages.send
import { SmsClient, isBulkSend } from "@taysend/sdk";

const sms = new SmsClient({
  apiKey: process.env.TAYSEND_KEY,
  baseUrl: process.env.API_URL ?? "https://api.taysend.com",
});

// Single transactional SMS
const one = await sms.messages.send({
  to: "+233200000001",
  senderId: "TAYSEND",
  message: "Hello from Taysend",
  type: "transactional",
});
console.log(one.id);

// Bulk send with template
const many = await sms.messages.send({
  recipients: ["+233244000001", "+233201234567"],
  senderId: "TAYSEND",
  templateId: "tpl_01...",
  variables: { order_id: "TS-18429" },
});
if (isBulkSend(many)) console.log(many.count);

// Network lookup by prefix
const check = await sms.lookup("+233244123456");
console.log(check.estimated_network);

OTP

OTP verification

OTP uses POST /v1/verify/send and POST /v1/verify/check. Full reference at /developers/otp.

verify/send
// OTP — use fetch if you prefer raw HTTP
const res = await fetch("https://api.taysend.com/v1/verify/send", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TAYSEND_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ to: "+233200000001", locale: "en" }),
});
console.log(await res.json());

DLR

Delivery report

Poll GET /v1/messages/:id or subscribe to signed webhooks (t=, v1=). See delivery reports.

Explore

Related

Each page answers a different question. They are not copies of this one.

Next

Create a TEST key and send to +233200000001.