SDKs
Official SDKs for integrating MyMX webhooks into your application. SDKs handle signature verification, type definitions, and provide helper utilities.
Available Now
The official Node.js SDK is ready for production use.
Installation
$
npm install mymxExample
import { handleWebhook, MyMXWebhookError, MYMX_CONFIRMED_HEADER } from 'mymx';export async function POST(req: Request) {const body = await req.text();try {const event = handleWebhook({body,headers: Object.fromEntries(req.headers),secret: process.env.WEBHOOK_SECRET!,});// Access email dataconsole.log('From:', event.email.headers.from);console.log('Subject:', event.email.headers.subject);console.log('Body:', event.email.parsed.body_text);// Confirm processing (enables content discard if configured)return new Response(null, {status: 200,headers: { [MYMX_CONFIRMED_HEADER]: 'true' },});} catch (err) {if (err instanceof MyMXWebhookError) {return new Response(null, { status: 400 });}throw err;}}
Features
- One-line webhook handling with
handleWebhook() - Signature verification with timing-safe comparison and replay protection
- Full TypeScript types for
EmailReceivedEvent - Structured error codes via
MyMXWebhookError - Helper functions for raw email decoding