Skip to main content
Inbound emails contain the HTML and Plain Text body of the email, as well as the headers.
Webhooks do not include the actual HTML or Plain Text body of the email. You must call the received emails API to retrieve them. This design choice supports large payloads in serverless environments that have limited request body sizes.
After receiving the webhook event, call the Receiving API. Here’s an example in a Next.js application:
app/api/events/route.ts
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

export const POST = async (request: NextRequest) => {
  const event = await request.json();

  if (event.type === 'email.received') {
    const { data: email } = await resend
      .emails
      .receiving
      .get(event.data.email_id);

    console.log(email.html);
    console.log(email.text);
    console.log(email.headers);

    return NextResponse.json(email);
  }

  return NextResponse.json({});
};