const MailSlurp = require('mailslurp-client').default;
const mailslurp = new MailSlurp({
apiKey: process.env.API_KEY ?? 'your-api-key',
});
// create an inbox with options using the inbox controller
const inbox = await mailslurp.inboxController.createInbox({
// name is used a contact name when sending
name: 'John Doe',
// use the expanded domain pool so randomly assigned email address is more varied
useDomainPool: true,
// permanent by default or supply an expires at time
expiresAt: undefined,
});
Turn incoming email and SMS into action.
Receive messages and attachments, trigger webhooks and put the content to work in your application. Route email, send automatic replies and extract the fields your workflow needs.

Trusted by top companies worldwide
Follow the message through to your endpoint.
A customer sends an email or SMS. MailSlurp receives it and notifies your webhook; your application fetches the message and attachments, updates its records and responds. Inspect webhook events and HTTP responses in the dashboard when a handoff needs attention.
Create inboxes, then attach the routing rules
Create real inboxes on demand or connect Gmail, Outlook, and custom domains. Then configure forwarding, replies, rulesets, webhooks, and extraction so each message reaches the right destination.
async function handleNewAttachmentPayload(payload: WebhookNewAttachmentPayload) {
type PackageStatus = {
packageId: string;
delivered: boolean;
}
const { result } = await aiController.generateStructuredContentFromAttachment({
generateStructuredContentAttachmentOptions: {
attachmentId: payload.attachmentId,
instructions: 'Parse attachment and extract package status',
outputSchema: {
type: StructuredOutputSchemaTypeEnum.object,
properties: {
packageId: {
type: StructuredOutputSchemaTypeEnum.string,
description: 'The ID of the package'
},
delivered: {
type: StructuredOutputSchemaTypeEnum.boolean,
description: 'Has the package been delivered?'
}
}
}
}
});
await persistStructuredData(result as PackageStatus);
}
Turn received messages into structured actions
Match inbound email, route attachments, trigger webhooks, and convert message content into JSON using schemas, AI prompts, labels, and OCR.
Integrate MailSlurp Seamlessly
Integrate with any framework
Official plugins and SDKs for all major programming languages, frameworks, and test platforms. All functionality available via API or dashboard.

CI/CD Native
MailSlurp fits right into your existing development, testing, and CI/CD workflows. Deploy and iterate with confidence and actionable feedback.


