MAILGENT
SDK / API ReferenceMessages

Reply to Email

POST /v0/messages/:messageId/reply

Scope: mail:send

Reply to an existing email. The reply is automatically threaded.

Request

import { Mailgent } from "@mailgent/sdk";

const mailgent = new Mailgent({ apiKey: process.env.MAILGENT_API_KEY! });
const reply = await mailgent.mail.reply("<msg-id@gmail.com>", {
  text: "Thanks for your question! Here's the answer...",
});
import os
from mailgent import Mailgent

mailgent = Mailgent(api_key=os.environ["MAILGENT_API_KEY"])
reply = mailgent.mail.reply(
    "<msg-id@gmail.com>",
    text="Thanks for your question! Here's the answer...",
)
mailgent mail reply '<msg-id@gmail.com>' \
  --text "Thanks for your question! Here's the answer..."

Pass --html for an HTML body. Quote the messageId — it contains <>@.

mail.reply(message_id, text=..., html?)

Available through @mailgent/mcp — see MCP setup.

curl -X POST https://api.mailgent.dev/v0/messages/%3Cmsg-id%40gmail.com%3E/reply \
  -H "Authorization: Bearer loid-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"text":"Thanks! Here is the info you requested."}'

Body

{
  "text": "Thanks for your question! Here's the answer...",
  "html": "<p>Optional HTML reply</p>"
}
FieldTypeRequiredDescription
textstringYesPlain text reply
htmlstringNoHTML reply
attachmentsAttachment[]NoSee Attachments

Response — 201 Created

{
  "messageId": "<new-uuid@mailgent.dev>",
  "threadId": "thd_f8e2a1c4d7b90e3f",
  "inboxId": "agent-x8k2m@mailgent.dev",
  "from": ["agent-x8k2m@mailgent.dev"],
  "to": ["sender@example.com"],
  "cc": [],
  "subject": "Re: Question about pricing",
  "text": "Thanks for your question! Here's the answer...",
  "extractedText": "Thanks for your question! Here's the answer...",
  "labels": ["sent"],
  "createdAt": "2026-03-28T14:30:00.000Z"
}

Errors

StatusCodeDescription
404not_foundOriginal message not found
429quota_exceededDaily send limit reached (50/day)

Threading

  • Subject prefixed with Re: automatically
  • In-Reply-To header set to the original messageId
  • References header includes full chain
  • Same threadId as the original

On this page