SMS
client.sms sends and tracks text messages. Back to the
SDK Reference.
| Method | Signature |
|---|---|
send | send(input: SendSmsInput, options?: SendOptions): Promise<SmsMessageResponse> |
sendBatch | sendBatch(messages: SendSmsInput[], options?: SendOptions): Promise<BatchSmsResponse> |
get | get(id: string): Promise<SmsMessageResponse> |
list | list(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 });Input rules
to(andfrom, when given) must be E.164, for example+15551234567.bodyis 1–1600 characters. PasstemplateNameandvariablesinstead to render from a template.listis cursor-paginated;limitis at most 200 andnextCursorisnullon the last page.
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.
Statuses
SMS_STATUSES / SmsStatus lists every status: queued, sending, sent,
delivered, deferred, failed and suppressed.