> ## Documentation Index
> Fetch the complete documentation index at: https://pigeonpost-developer.27communication.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Replies and threads

> Answer emails so they stay in the same conversation.

## Reply to an email

Pass the email you're answering as `reply_to_message_id`: its `Message-ID` (from its `headers`), or its `email_…` id.

```bash theme={null}
curl -X POST "$EE_URL/api/v1/acc_ba1fa6938d8548298e8ce62e4b4b4e99/emails/send" \
  -H "X-API-KEY: $EE_KEY" -H "Content-Type: application/json" \
  -d '{
    "reply_to_message_id": "<CAKs9P1x@mail.example.com>",
    "html": "<p>Thanks, looks good!</p>"
  }'
```

```json Response 201 theme={null}
{ "object": "EmailSent", "account_id": "acc_ba1fa6938d8548298e8ce62e4b4b4e99", "message_id": "84c3db9476d84b288bc6fa055a576764@mail-api.example.com", "provider_id": null, "tracking_id": null }
```

The engine fills in the rest:

| | Default |
| - | - |
| Recipients | The original's `Reply-To`, or its sender, when you give no `to`/`cc`/`bcc` |
| Subject | `Re: ` plus the original subject, when you give none |
| `In-Reply-To` | The original's `Message-ID` |
| `References` | The original's references plus its `Message-ID` |

So the reply shows in the same conversation in Gmail and other email clients, for the user and the recipients.

<Note>
  `reply_to_message_id` must name an email of the same account that the engine has synced. Emails that arrived before the account connected aren't synced (unless you used [initial sync](/accounts/initial-sync)), so they can't be answered this way. An unknown `reply_to_message_id` gets `400 errors/invalid_parameters`.
</Note>

Don't confuse it with `reply_to`: that field sets the `Reply-To` header of the email you send.

To reply to everyone, pass the recipients yourself, for example the original `from_attendee` plus its `to_attendees` and `cc_attendees`, minus the user's own address. Write them as `{ "email", "display_name" }` (an attendee's `identifier` is the `email`).

## Find the email a reply answers

Every email has its `headers`. The answered email's `Message-ID` is in `In-Reply-To`:

```json theme={null}
"headers": [
  { "name": "Message-ID", "value": "<11fb30c561954dd39462f523c0c0282d@mail.gmail.com>" },
  { "name": "In-Reply-To", "value": "<CAKs9P1x@mail.example.com>" },
  { "name": "References", "value": "<CAKs9P1x@mail.example.com>" }
]
```

To get the answered email itself, take its [thread](#threads) and find the email whose `Message-ID` header matches. An email that answers nothing has no `In-Reply-To` header.

## Forward

There's no forward call. Send a new email with the original's content and files: put its `body` in `html`, download the attachments with [the attachment endpoint](/emails/attachments) and attach them again. See [Forward attachments](/emails/attachments#5-forward-attachments).

## Threads

Every email has a `thread_id`:

| Provider | `thread_id` |
| - | - |
| IMAP (Gmail included) | The `Message-ID` of the conversation's first email, found through `References` and `In-Reply-To` |

Get the whole conversation of an email, **oldest first**:

```bash theme={null}
curl "$EE_URL/api/v1/acc_ba1fa6938d8548298e8ce62e4b4b4e99/emails/email_94a0d77db739407e932c3b97fef44aac/thread" -H "X-API-KEY: $EE_KEY"
```

Or by its `thread_id` (URL-encoded):

```bash theme={null}
curl "$EE_URL/api/v1/acc_ba1fa6938d8548298e8ce62e4b4b4e99/threads/CAKs9P1x%40mail.example.com" -H "X-API-KEY: $EE_KEY"
```

The response is a `Thread`, with Sent copies included and drafts left out:

```json theme={null}
{
  "object": "Thread",
  "id": "CAKs9P1x@mail.example.com",
  "data": [ { "object": "Email", "…": "…" } ],
  "has_more": false
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.