Skip to content
DashboardRequest access

SMS

client.sms sends and tracks text messages. Back to the SDK Reference.

MethodSignature
sendsend(input: SendSmsInput, options?: SendOptions): Promise<SmsMessageResponse>
sendBatchsendBatch(messages: SendSmsInput[], options?: SendOptions): Promise<BatchSmsResponse>
getget(id: string): Promise<SmsMessageResponse>
listlist(query?: SmsListQuery): Promise<SmsListResponse>
const sms = await client.sms.send({
  to: '+15551234567',
  body: 'Your code is 481516.',
  tags: ['otp'],
});

const { results, created, errors } = await client.sms.sendBatch([
  { to: '+15551234567', body: 'Hello' },
  { to: '+15557654321', templateName: 'reminder', variables: { name: 'Sam' } },
]);

const page = await client.sms.list({ status: 'delivered', limit: 50 });
const next = await client.sms.list({ cursor: page.nextCursor ?? undefined });

A failed batch item is { index, error, code }. code is one of invalid_request, no_from_number, daily_sms_limit_exceeded, sms_quota_exceeded, template_not_found, body_too_long, or send_failed for anything else.

Input rules

Idempotency

send and sendBatch each generate an Idempotency-Key unless you pass options.idempotencyKey. SMS keys are namespaced separately from email keys, so the same key on /v1/emails and /v1/sms doesn't collide.

Suppressed numbers

Sending to a suppressed number doesn't fail. The API answers 200 (rather than 201) with status: 'suppressed', and nothing is sent.

Segments

Every SmsMessageResponse carries segments, the number of billable segments the body uses. A GSM-7 body fits 160 characters in one segment (153 each when split); any character outside GSM-7, such as an emoji, switches the whole body to UCS-2 (70 per segment, 67 each when split). The GSM-7 extension characters ^ { } \ [ ] ~ | € count as two characters each, so a body that leans on them splits sooner than its length suggests.

Monthly segment quota

Each plan includes a monthly allowance of SMS segments, counted per organization and only when SMS is enabled for the account. When the next send would pass the allowance, the API answers 429 and sends nothing:

{
  "statusCode": 429,
  "error": "sms_quota_exceeded",
  "message": "Monthly SMS segment quota exceeded",
  "limit": 1000,
  "used": 1000
}

Retry-After is the number of seconds until the quota resets at the start of the next month, and the body includes upgrade_url when billing is enabled. It is a hard limit with no overage billing. In a batch, the affected item is { index, error, code: 'sms_quota_exceeded' }.

Statuses

SMS_STATUSES / SmsStatus lists every status: queued, sending, sent, delivered, deferred, failed and suppressed.