Wait for new emails

Hi, is there a way for the API to wait for new emails for a specified period? Let´s say, I want to retrieve emails recieved from a specified date-time. I am expecting the email to be sent within 20 seconds. My initial approach would be to check for inbox count before sending the email and periodically check every 5 seconds, if there is an increment. Is there some better method?

Hi Messages have received property so you can filter ones that are older than some specified time.
That’s what I use to get latest message using ts:
public static async getLatestMessage(emailAddress: string, timespanInSeconds: number = 60, retryInterval: number = 5000): Promise {

const maxRetries = Math.ceil(timespanInSeconds / (retryInterval / 1000));

for (let i = 0; i < maxRetries; i++) {
  const messages = await this.getMessages(emailAddress);
  const message = messages[0];
  const received = new Date(message.received);
  const isWithinTimeSpan = this.isMessageReceivedWithinTimeSpan(received, timespanInSeconds);

  if (isWithinTimeSpan) {
    return message;

  await this.delay(retryInterval);

throw new Error(`Email:${emailAddress}. No message received within the last ${timespanInSeconds} seconds.`);


Hi Martin,

Polling the number of messages in an inbox is a common approach, and many of our customers use it effectively. However, I have some concerns about your time period of 20 seconds. While email delivery is generally fast, 20 seconds is quite short to expect consistent delivery due to potential throttling on the sending side.

Here are a few recommendations:

  1. Custom Domain Setup:
  • Ensure you are signed up for a paid plan and using a zero-setup custom domain.
  • A custom subdomain can be set up in seconds and is included in all of our paid plans.
  • Using a custom domain signals our system that the emails are for a paying customer, allowing for much higher throttling limits.
  1. Polling Alternatives:
  • Web Sockets:
    • Consider using a web socket.
    • This opens a persistent connection to our servers, and any received messages are immediately forwarded over the web socket.
  • Web Hooks:
    • Alternatively, use a web hook.
    • This method requires a server to receive the web hooks but ensures immediate notification of new messages.