---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/api-reference/receive-emails/send-trust/reply

Receive Emails: Send & trust

# Reply

Reply inside the same conversation. The reply is saved in Sent and INBOX, and the subject becomes Re: original.

POST `https://g.sendcorex.com/v1` command: reply

The recipient is the `reply_to` (or `from`) of the original message. If the `id` is a message you sent, the reply goes to the last client who wrote in the conversation, not to yourself. The labels of the original are kept.

Recipients who refused tracking on the preferences page are never tracked, even with `true`.

Emails sent from the mailbox carry no List-Unsubscribe header or unsubscribe link unless you send `unsubscribe: true`, because they are personal emails.

Everyone who receives an email from the mailbox becomes a contact in the account’s “Webmail” list and is trusted in this mailbox: their replies go to the Inbox and the address shows up in autocomplete. Senders the mailbox blocked stay blocked.

With `unsubscribe: true`, recipients who already unsubscribed from this mailbox are refused with `RECIPIENT_UNSUBSCRIBED`, and `recipients` lists them. Replies are never blocked.

## Arguments

- `id` string required
The `message_uid` of the message you are replying to.
- `html` string optional
HTML body. Send `html` or `text`.
- `text` string optional
Plain text body.
- `reply_all` boolean optional
Everyone in the To and Cc of the original goes in Cc, except you and the person you reply to.
- `cc` string[] optional
Extra recipients in copy.
- `bcc` string[] optional
Extra recipients in blind copy.
- `template_id` string optional
Fill the body from a template.
- `attachments` object[] optional
Files in base64, same format as Send Email.
- `compose_uid` string optional
Attachments uploaded before with `upload_attachment`.
- `followup_at` string optional
Remind you if nobody replies by this date. Without it, a reminder already set on the conversation is removed (you just replied).
- `track_opens` boolean optional
Track when each recipient opens the email (invisible pixel). Default `true`.
- `track_clicks` boolean optional
Track clicks on the links (each link goes through a redirect). Default `true`.
- `unsubscribe` boolean optional
Add an unsubscribe link. Put `[unsubscribe]` in the body (as a link `href` or as plain text) where the link should go; without it, a default line is added at the end. Default `false`.
- `idempotency_key` string optional
Your own key for this email (1–255 characters: letters, numbers, `_ - : .`), valid for 24 hours. A retry with the same key and the same args returns the first result with `idempotent_replayed: true`, and nothing is sent again.
- `recipient` string optional
Only on emails this mailbox sent: who gets the follow-up, in the same conversation with “Re:”. The person must have received that email (otherwise `INVALID_RECIPIENT`). Without it, a reply to a sent email goes to its recipient, never back to the mailbox.

Retrying? Use an idempotency key so the email is never sent twice. [Idempotency →](https://docs.sendcorex.com/idempotency)

## Quick start

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "reply",
        args: {
          id: "Vj0xQUJDMTIz",
          text: "Received, thank you!",
          reply_all: true
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);

const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);
```

## Response

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "reply",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "message_uid": "Vj0xQUJDMTIz",
        "thread_id": "thr_9a1c4e72",
        "message_id": "<5e0b9c1a-3d7f-4a21-9a6e-2f1c8d4b7e90>",
        "queued": true
      }
    }
  ]
}
```

### Response fields

- `message_uid`
The id of the reply.
- `thread_id`
The same conversation as the original message.
- `message_id`
A provisional Message-ID, replaced by the real SMTP one shortly after.
- `queued`
`true` = saved and queued, not delivered.
- `idempotent_replayed`
Only on a retry: `true` when this is the stored result of an earlier call with the same `idempotency_key`. Nothing was sent again.

## Reply to the last email of a sender

Search by sender, then reply to the newest result. Search returns the newest message first.

Node.js

```
const [s] = await call({
  command: 'search',
  args: { query: 'ana@client.com', field: 'from', limit: 5 },
});

const last = s.data.messages[0]; // newest first
if (last) {
  const [r] = await call({
    command: 'reply',
    args: { id: last.message_uid, html: '<p>Hi Ana, received!</p>' },
  });
  console.log(r.data); // { message_uid, thread_id, message_id, queued: true }
}
```

## Reply to every unread conversation

Reply and mark the conversation as read in the same request, so the next poll does not answer it again.

Node.js

```
const [l] = await call({ command: 'list_threads', args: { is_read: false, limit: 20 } });

for (const t of l.data.threads) {
  await call([
    { command: 'reply', args: { id: t.last_message_uid, text: 'We got your message and will get back to you.' } },
    { command: 'set_flags', args: { id: t.last_message_uid, is_read: true, scope: 'thread' } },
  ]);
}
```

You can also chain `list_threads` and `reply` in one request with `$ref`, using the `last_message_uid` of each thread.

## Safe retries

Always send an `idempotency_key` (for example a UUID per email). If a call times out, retry with the same key: the email is never sent twice. Only a successful send is stored, so if the send failed, a retry with the same key runs again. Keys are per mailbox: the same key in another mailbox or in `POST /v3.0/send` does not conflict.

Request body

```
{
  "commands": [
    {
      "command": "reply",
      "args": {
        "idempotency_key": "ticket-552-reply-1",
        "id": "Vj0xQUJDMTIz",
        "html": "<p>Thanks, we are on it.</p>"
      }
    }
  ]
}
```

## Errors

HTTP-level errors return `type`, `code` and `message`. Errors marked CMD come back inside the command result, with HTTP 200.

- 401`TOKEN_EXPIRED`
The access token has expired. Call Refresh Token and repeat the request.
- 401`INVALID_TOKEN`
The token is malformed, unknown or revoked.
- 429`RATE_LIMITED`
More than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD`INVALID_IDEMPOTENCY_KEY`
`idempotency_key` must have 1–255 characters: letters, numbers, `_ - : .`.
- CMD`IDEMPOTENCY_KEY_REUSED`
This `idempotency_key` was already used with different args. Use a new key for every new email.
- CMD`IDEMPOTENCY_IN_PROGRESS`
A call with the same `idempotency_key` is still running. Try again in 1 second with the same key.
- CMD`INVALID_RECIPIENT`
The recipient is missing or not a valid email.
- CMD`RECIPIENT_UNSUBSCRIBED`
One or more recipients unsubscribed from this mailbox. `recipients` lists them: remove them or send again with `unsubscribe: false`.
- CMD`INVALID_ARGS`
A required argument is missing or invalid.
- CMD`NOT_FOUND`
The message, thread or folder does not exist for this token.
- CMD`NO_RECIPIENT`
The conversation has no recipient to reply to.
- CMD`RECIPIENT_LIMIT_EXCEEDED`
to, cc and bcc together have more than 50 addresses.
- CMD`FILE_BLOCKED`
A file was blocked by the security scan.
- CMD`ATTACHMENTS_TOO_LARGE`
The attachments of the email add up to more than 25 MB, or the mailbox already has 500 MB of uploads waiting to be sent.
- CMD`NO_CREDITS`
The account has fewer email credits than recipients (1 credit per copy).
- CMD`SENDER_NOT_FOUND`
The sender behind the token is not registered.
- CMD`SENDER_NO_DOMAIN`
The sender behind the token has no domain.
- CMD`INTERNAL`
Server error. The detail is only written to the server log.
