# Receive emails with Webhook Push

Every MailSlurp inbox can be connected to a webhook. Webhooks are rules that forward emails to an HTTP endpoint that is publicly accessible on your server or system. MailSlurp will post a JSON payload that contains the emailId and inboxId to your system every time an email is received. You can then fetch the full email, forward, parse the contents, stream attachments and more!

# Creating a webhook

First create an inbox. Then you can create a webhook online in the webapp or using the API or SDKs. You must define a URL for the webhook that can be called by MailSlurp servers using HTTP POST method.

# The payload


Your url will be sent a JSON payload via HTTP POST each time an email is received for the inbox that the webhook was created for. Use the inboxId and emailId in the request body to lookup the email and process it how you wish.

Each time an email is received a JSON payload will be sent to your URL via HTTP POST. Here is a sample of what that looks like:

  "inboxId": "...",
  "emailId": "...",
  "createdAt": "...",
  "name": "myWebhook"

The exact JSON-Schema of the webhook notification payload is defined below:

  "type": "object",
  "id": "urn:jsonschema:com:mailslurp:lib:models:WebhookNotificationObject",
  "properties": {
    "inboxId": {
      "type": "string",
      "required": true,
      "format": "uuid"
    "createdAt": {
      "type": "string",
      "required": true,
      "format": "date-time"
    "emailId": {
      "type": "string",
      "required": true,
      "format": "uuid"
    "name": {
      "type": "string"

# Express example

Let's see how a webhook fits together with an example Javascript server using Express.

Note: you can use any framework or language you like with webhooks.

const express = require("express");
const app = express.createServer();
 * define your endpoint
 * here your webhook url should include the full protocol and domain.
 * i.e.: https://myserver.com/my-webhook-endpoint
app.post("/my-webhook-endpoint", function (request, response) {
  // access the data on request body
  // return a 2xx status code so MailSlurp knows you received it