@routa-chat/sdk is the official Routa SDK for Node.js. It gives you a typed client to send WhatsApp messages, create templates and receive delivery events, with retries, idempotency and webhook verification included. The current version is 0.5.0. If you come from an earlier version, see Upgrade the SDK.
Strict types
Types for every request and response, with branded IDs that keep you from swapping a channel for a message.
Safe retries
Exponential backoff with jitter, respect for
Retry-After and an automatic Idempotency-Key.No dependencies
Uses the platform’s
fetch and Web Crypto. ESM and CommonJS, with type declarations.Requirements
Node.js 22 or later (engines.node is >=22). The package ships ESM and CommonJS builds, so it works with import and with require.
Installation
First send
status: 'accepted' means Routa received the message, not that it reached the recipient. Delivery is asynchronous: the message moves on to sent, delivered and read (or failed), and you follow each step through webhooks or routa.events.list().
To send an approved template instead of free-form text, pass template instead of text:
text and template are mutually exclusive: passing both is a compile error. A template with a variable in the header or in a button, or with a media header, asks for more than bodyParameters.
Authentication
The client sends the key asAuthorization: Bearer <key>. Create keys in the dashboard, on the API keys page, in the Developer group of the sidebar. The SDK does not read environment variables on its own: pass the value explicitly.
new Routa('rt_live_...') is a shortcut for new Routa({ apiKey: 'rt_live_...' }). An empty key throws right away, on construction, not on the first request. A partner key (rt_partner_...) is also refused on construction: use RoutaPartner with it.
To check a key with no side effects, call routa.whoami():
Client resources
The Partner API has a separate client,
RoutaPartner, in @routa-chat/sdk/partner. It is experimental. See Partners.
Not supported yet
Know these gaps before you build on the SDK:- Sending media, location or reactions.
messages.send()accepts onlytextandtemplate. A file uploaded withmedia.upload()can be the media header of a template, but not a media message. Inbound and historical messages of these types can be read, but not sent. - Editing, deleting or syncing templates. The SDK creates, retrieves and lists templates. Changing or removing a template is only possible in the dashboard: the API does not offer these operations to an API key.
- Channels. There is no
routa.channelsnamespace. Connect and manage channels in the dashboard and pass the channel ID tosend(). If you use the Partner API, you list and delete disabled channels withpartner.channels.