Send SMS

Send transactional SMS messages globally using the YourSend API.

Basic SMS

send-sms.ts
import { YourSend } from 'yoursend';

const ys = new YourSend('ys_live_...');

await ys.send({
  channel: 'sms',
  to: '+14155551234',
  body: 'Your order #1234 has shipped! Track it here: https://track.example.com/1234',
});

OTP via SMS

Send a one-time password via SMS. YourSend generates a 6-digit code automatically.

otp-sms.ts
const { data } = await ys.send({
  channel: 'sms',
  to: '+14155551234',
  otp: true,
});

// Later, verify the code
const { data: result } = await ys.check({
  message_id: data.message_id,
  code: '123456', // user-provided code
});

console.log(result.valid); // true or false

Parameters

ParameterTypeRequiredDescription
channelstringYes"sms"
tostringYesPhone number in E.164 format (+1...)
bodystringYes*Message content (max 480 chars)
otpbooleanNoSet to true to send an OTP code
template_idstringYes*Template ID (alternative to body)
tagsobjectNoMerge tag values

* Either body, template_id, or otp: true is required.