Send SMS from Express with the SendiMessage API
Express covers both directions of a SendiMessage integration in a dozen lines with the official npm SDK: one route your systems call to send, and one route that receives delivery and reply webhooks.
The SDK ships verifyWebhookSignature, so the webhook route can check the timestamped SendiMessage-Signature header against the raw body before trusting any event.
What this integration enables
Architecture
- Your application eventAn order ships, a booking nears, a ticket updates
- Express server codeBuilds the request with credentials from the environment
- SendiMessage APIPOST /send-message returns the queued message
- Managed messaging lineSMS, or iMessage on supported lines and destinations
- Webhook eventsDelivery status and incoming replies post back to your endpoint
Example request
// npm install sendimessageimport express from "express";import SendImessage, { verifyWebhookSignature } from "sendimessage";const app = express();const client = new SendImessage({apiKey: process.env.SENDIMESSAGE_KEY,apiSecret: process.env.SENDIMESSAGE_SECRET,});// Outbound: your systems call this to send.app.post("/notify", express.json(), async (req, res) => {try {const msg = await client.sendMessage({ number: req.body.to, content: req.body.content });res.json({ handle: msg.message_handle, status: msg.status }); // "QUEUED"} catch (err) {res.status(502).json({ error: String(err) });}});// Inbound: SendiMessage posts delivery + reply events here.// Raw body required — re-serialized JSON differs byte-for-byte.app.post("/webhooks/sendimessage", express.raw({ type: "application/json" }), (req, res) => {const ok = verifyWebhookSignature({secret: process.env.WEBHOOK_SECRET,rawBody: req.body,signatureHeader: req.get("SendiMessage-Signature") ?? "", // "t=...,v1=..."});if (!ok) return res.sendStatus(401);const event = JSON.parse(req.body); // event.type: "outbound" | "receive" | line eventsres.sendStatus(200);});app.listen(3000);
Delivery events and incoming replies
Point a Express route at your webhook URL to receive delivery status and incoming replies. Verify the signature header before processing.
// "outbound" event → your express endpoint// Verify the SendiMessage-Signature header (t={timestamp},v1=HMAC-SHA256 of// "{timestamp}.{raw body}", keyed with your webhook secret), then use// GET /v2/messages/{message_handle} for authoritative state and match it to// your contact_id in express.
Limitations and honest notes
- iMessage delivery is available on supported messaging lines and destinations. Recipients without iMessage receive SMS when fallback is configured — never assume universal iMessage availability.
- Messages are accepted asynchronously — the API returns status QUEUED and final status arrives via webhook or the message endpoints.
- Official SDKs are published for JavaScript/TypeScript (npm: sendimessage), Python (PyPI: sendimessage), PHP (Composer: sendimessage/sdk), and Go (github.com/sendimessage/sendimessage-go). Every SDK is dependency-free and covers the full public API surface.
Security considerations
- Keep the API key pair in server configuration or environment variables, never in the repository.
- Verify webhook signatures before trusting delivery or reply events.
Frequently asked questions
Is there an official Express package for SendiMessage?
Can Express receive message replies?
Related integrations
Ready to connect Express?
Request a messaging line and a SendiMessage integration specialist will review your Express workflow and guide the setup.