Skip to main content

Webhooks

Draft

Structural skeleton — content authored separately.

Webhooks push realtime events — inbound SMS, delivery receipts and device status — to an HTTPS endpoint you control. Every delivery is signed and retried.

Example

import express from 'express';
import { Msgly } from '@msgly/sdk';

const app = express();
const msgly = new Msgly({ apiKey: process.env.MSGLY_API_KEY });

app.post('/webhooks/msgly', express.raw({ type: '*/*' }), (req, res) => {
const event = msgly.webhooks.verify(
req.body,
req.header('X-Msgly-Signature'),
process.env.MSGLY_WEBHOOK_SECRET,
);

if (event.type === 'message.received') {
console.log('Inbound SMS from', event.data.from, ':', event.data.text);
}

res.sendStatus(200);
});

app.listen(3000);

How it works