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

# Send, reply, and forward

> Send new emails, reply to messages, reply all, and forward messages from your inboxes.

You can send messages, reply to conversations, and forward emails from your inboxes through the API. All sent messages are tracked within threads alongside received messages, giving you a complete view of each conversation.

<Note>
  Your domain must have sending capability enabled to send messages from inboxes. See [add a sending domain](/docs/guides/sending-domains) to configure your domain.
</Note>

## Send a new message

Send a new email from an inbox. This creates a new thread for the conversation.

```typescript theme={null}
import { Nuntly } from '@nuntly/sdk';

const nuntly = new Nuntly({
  apiKey: process.env.NUNTLY_API_KEY,
});

const result = await nuntly.inboxes.send('ibx_01kabn43yqyxn2bx4ve84mczd3', {
  to: [{ address: 'recipient@example.com', name: 'Jane Doe' }],
  subject: 'Welcome to our platform',
  html: '<p>Thanks for signing up. Let us know if you have any questions.</p>',
  text: 'Thanks for signing up. Let us know if you have any questions.',
});

console.log('Message ID:', result.data.id);
console.log('Thread ID:', result.data.threadId);
console.log('Email Message-ID:', result.data.messageId);
```

### Send request fields

| Field     | Required | Description                                  |
| --------- | -------- | -------------------------------------------- |
| `to`      | Yes      | Array of recipient addresses (at least one). |
| `cc`      | No       | Array of CC addresses.                       |
| `bcc`     | No       | Array of BCC addresses.                      |
| `subject` | Yes      | The message subject line.                    |
| `html`    | No       | The HTML body.                               |
| `text`    | No       | The plain text body.                         |

Each address is an object with `address` (required) and `name` (optional) fields.

## Reply to a message

Reply to a received message. The reply is added to the same thread and automatically sets the `In-Reply-To` header to link the conversation.

```typescript theme={null}
const reply = await nuntly.messages.reply('imsg_01kabn43yqyxn2bx4ve84mczd3', {
  html: '<p>Thank you for reaching out. We will look into this right away.</p>',
  text: 'Thank you for reaching out. We will look into this right away.',
});

console.log('Reply ID:', reply.data.id);
console.log('Thread ID:', reply.data.threadId);
```

### Reply request fields

| Field      | Required | Description                                                    |
| ---------- | -------- | -------------------------------------------------------------- |
| `html`     | No       | The HTML body of the reply.                                    |
| `text`     | No       | The plain text body of the reply.                              |
| `replyAll` | No       | Set to `true` to reply to all recipients. Defaults to `false`. |

## Reply all

When you set `replyAll` to `true`, the reply is sent to the original sender and all recipients from the original message. Your own inbox address is automatically excluded from the recipient list.

```typescript theme={null}
const replyAll = await nuntly.messages.reply('imsg_01kabn43yqyxn2bx4ve84mczd3', {
  html: '<p>Sharing this update with everyone on the thread.</p>',
  text: 'Sharing this update with everyone on the thread.',
  replyAll: true,
});
```

## Forward a message

Forward an existing message to new recipients. This creates a new thread for the forwarded conversation.

```typescript theme={null}
const forward = await nuntly.messages.forward('imsg_01kabn43yqyxn2bx4ve84mczd3', {
  to: [{ address: 'colleague@example.com', name: 'John' }],
  text: 'Please take a look at this message from the customer.',
});

console.log('Forwarded message ID:', forward.data.id);
console.log('New thread ID:', forward.data.threadId);
```

### Forward request fields

| Field  | Required | Description                                              |
| ------ | -------- | -------------------------------------------------------- |
| `to`   | Yes      | Array of recipient addresses (at least one).             |
| `text` | No       | An optional comment to prepend to the forwarded message. |

## Response fields

All send, reply, and forward operations return the same response structure:

| Field       | Description                     |
| ----------- | ------------------------------- |
| `id`        | The ID of the new message.      |
| `threadId`  | The ID of the thread.           |
| `messageId` | The RFC 5322 Message-ID header. |

## Next steps

<CardGroup cols={2}>
  <Card title="Threads" icon="messages" href="/docs/guides/receiving-threads">
    View the full conversation history in threads
  </Card>

  <Card title="Receiving events" icon="webhook" href="/docs/guides/receiving-webhooks">
    Get notified when messages are sent from your inboxes
  </Card>
</CardGroup>
