Wait for emails to arrive using REST API

How MailSlurp waitFor methods work to hold a connection until matching emails arrive. Email matching guide for REST API.

  • Table of contents

MailSlurp has many functions for receiving emails. One popular method is the WaitForController wait methods.

Wait For methods let you wait for an email to arrive to an inbox during tests or code. This way you can perform actions and wait for the expected email to arrive. The API will hold the connection open so with WaitFor you don't need to repeat long-poll the API to check your emails.

See the API documentation for more information.


MailSlurps WaitForController endpoints can be used to wait for an email (or a number of emails) to arrive in an inbox. Here is an example using the Javascript client.

const inbox = await mailslurp.createInbox();
await mailslurp.sendEmail(inbox.id, {
  to: [inbox.emailAddress],
  subject: 'test',

// wait for first email
const latestEmail = await mailslurp.waitForLatestEmail(inbox.id, timeoutMs);