Skip to main content
Email clients thread emails by using the message_id metadata. If you want to reply to an email, you should add the In-Reply-To header set to the message_id of the received email. We also recommend setting the subject to start with Re: so that email clients can group the replies together.

Get the message ID

The message_id is included in the webhook event payload when an email is received:
{
  "type": "email.received",
  "data": {
    "email_id": "56761188-7520-42d8-8898-ff6fc54ce618",
    "message_id": "<example+123>",
    "subject": "Sending this example",
    "from": "Acme <onboarding@resend.dev>",
    "to": ["delivered@resend.dev"]
  }
}
Use the message_id value from event.data.message_id as the In-Reply-To header when sending your reply.

Send a reply in thread

Here’s how you can reply in thread using each SDK:
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const messageId = event.data.message_id;

const { data, error } = await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: `Re: ${event.data.subject}`,
  html: '<p>Thanks for your email!</p>',
  headers: {
    'In-Reply-To': messageId,
  },
});

Replying multiple times in a thread

If you’re replying multiple times within the same thread, make sure to also append the previous message_ids to the References header, separated by spaces. This helps email clients maintain the correct threading structure.
const previousReferences = ['<msg_id1@domain.com>', '<msg_id2@domain.com>'];

const { data, error } = await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: `Re: ${event.data.subject}`,
  html: '<p>Thanks for your email!</p>',
  headers: {
    'In-Reply-To': event.data.message_id,
    'References': [...previousReferences, event.data.message_id].join(' '),
  },
});