Getting started
Quickstart
Send and receive your first iMessage with the mdnt SDK in under three minutes.
1. Install the SDK
The SDK ships dual ESM and CJS, with full TypeScript types.
bash
pnpm add mdnt2. Get a token
Provision an API token in your dashboard. Tokens scope to a customer; treat them like a database password.
.env
bash
MDNT_TOKEN=mdnt_live_3f4b...3. Send a message
messages.send resolves once the Mac bridge has confirmed dispatch (typically ~200ms). Delivery state is reported asynchronously through your webhook.
send.ts
ts
import Mdnt from 'mdnt';
const client = new Mdnt({ token: process.env.MDNT_TOKEN });
const message = await client.messages.send({
from: 'agent@example.com',
to: '+15551234567',
text: 'Hello from your agent',
});
console.log(message.id, message.status);
// → '019dce...' 'sent'4. Receive replies
Register a webhook URL. mdnt will POST a typed event payload signed with HMAC-SHA256. The SDK provides a parser that verifies the signature in one line.
webhook.ts
ts
import Mdnt from 'mdnt';
const client = new Mdnt({ token: process.env.MDNT_TOKEN });
export async function POST(req: Request) {
const event = client.webhooks.parse(
await req.text(),
Object.fromEntries(req.headers),
);
if (event.type === 'message.received') {
console.log(event.data.from, event.data.text);
}
return new Response('ok');
}Next: read the Messages API reference or the inbound guide.