Reply to an inbound email
Answer a received email in the same thread with POST /v3/inbound/messages/{id}/reply: wemail sets the recipient, Re: subject and threading headers.
Sends a reply to a message you received, as a normal outbound email in the same conversation. You only write the body: wemail addresses the reply to the original sender, builds the Re: subject and sets the In-Reply-To and References headers so Gmail, Outlook and every other mail client shows it in the thread. It is the building block for support desks, AI agents and any workflow that answers inbound mail — with loop protection built in, so your automation never ends up arguing with an out-of-office reply.
POST /v3/inbound/messages/{id}/reply
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | uuid | Required | The inbound message to answer (from the poll API, a forward payload or the inbound log). It must still be stored — kept messages live 30 days, forward-only ones 72 hours. |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Optional | Plain-text body of the reply. text and/or html is required. |
html | string | Optional | HTML body of the reply. text and/or html is required. |
from | string | Optional | Sender — email@domain or Display Name <email@domain> on a domain verified for sending (at most 400 characters). Omitted = the address the original was sent to, when its domain is verified for sending on your workspace; otherwise 400 from_required (see "Choosing the sender" below). |
reply_all | boolean | Optional | Also reply to the original To and Cc recipients — your own receiving addresses are left out. Default false: only the sender (its Reply-To, else From). |
cc | string[] | Optional | Extra Cc recipients, at most 50. |
attachments | object[] | Optional | Files as base64 — the same shape and limits as `POST /v3/messages`: { filename, content, content_type?, content_id?, disposition? }. |
headers | object | Optional | Custom X-* headers, with the same rule as POST /v3/messages: only X-* names are kept (at most 32, 1 024 bytes per value; X-Wemail-* is reserved), anything else is dropped. In-Reply-To, References and Auto-Submitted are always set by wemail. |
automated | boolean | Optional | Default true: the reply carries Auto-Submitted: auto-replied (RFC 3834), so auto-responders on the other side stay quiet. Set false when a person wrote the reply. |
force | boolean | Optional | Reply even though the original looks automated (auto-reply, mailing list, no-reply sender, suspected loop). A bounce is never answered, even with force; the per-recipient reply limit always applies. Default false. |
What wemail builds for you
- To — the original
Reply-To, else itsFrom. Withreply_all: truethe original To and Cc recipients are added as Cc, minus every address on your own inbound domains and minus the sender of the reply. - Subject —
Re:+ the original subject. A subject that already starts withRe:,AW:orΑΠ:(any case) is kept as it is, so threads never growRe: Re: Re:. - Threading headers —
In-Reply-To: <original Message-ID>andReferences: <the original References> <original Message-ID>, explained below. - Auto-Submitted —
auto-repliedunless you sendautomated: false. - Everything else is a normal send — sender verification, suppressions, your plan quota and content checks apply exactly as for
POST /v3/messages. The reply counts as one sent email per recipient, shows in your sent messages and Activity, and fires the usual webhooks.
Threading
References is the original message’s References header (or, when it has none, its single In-Reply-To id) followed by the original Message-ID, duplicates removed. A long thread is capped at 20 ids: the first (root) id and the most recent ones are kept, which is what mail clients use to group the conversation. Ids that are not valid <id> tokens are dropped rather than copied, and a message without a usable Message-ID is answered without threading headers rather than with a malformed one. Because the headers are built from the stored original, a reply cannot be used to inject headers of your choosing.
Choosing the sender
Without from, the reply is sent from the address the original was sent to (the to field of the inbound message) — but only when that domain is also verified for sending on your workspace. If you receive on a dedicated subdomain such as in.example.com that is not a sending domain, pass from with an address on a domain you do send from (for example support@example.com); there is no silent fallback to another domain, the call answers 400 from_required instead. An explicit from must be on a verified sending domain, like any send.
Loop protection
Every reply passes three guards, in this order. How messages are classified and how to filter them is explained in Automated mail & loop protection.
- Automated originals are refused. When the original’s
automated.kindisauto_reply,list,no_reply,loop_suspectedorbounce, the call answers409 reply_blocked_automatedwithdetails.kind,details.signalsanddetails.forceable.force: truereplies anyway — except to a bounce, which is never answered. - At most 5 replies per hour and 20 per day go to one recipient address from your workspace. Above that the call answers
429 reply_loop_guard(details.window=hourorday,details.limit) and the conversation is markedloop_suspectedfor an hour.forcedoes not lift this limit. - Fail closed. If loop protection is briefly unavailable, automatic replies answer
503 reply_guard_unavailable— try again in a minute. A reply sent withautomated: false(written by a person) is not held back.
Response
202 Accepted with { message_id, to, subject }: message_id is the id of the outbound reply — follow it with `GET /v3/messages/{id}` and your delivery webhooks like any other email; to lists the addresses the reply went to and subject the subject wemail built. Requires a `full_access` key (a send_only or read_only key gets 403 insufficient_scope) and a plan that includes inbound e-mail. Limit: 60 calls per minute per key.
{
"error": {
"code": "reply_blocked_automated",
"message": "The original message looks automated (auto_reply) — replying could start a mail loop. Send with force: true to reply anyway.",
"details": { "kind": "auto_reply", "signals": ["auto_submitted:auto-replied", "subject:out_of_office"], "forceable": true }
},
"request_id": "req_01HC2M8Q4V"
}Responses
| Status | Description |
|---|---|
202 | Accepted. { message_id, to, subject, thread_id } — the reply is queued for delivery and joins the conversation thread_id. |
400 | validation_error — invalid body (text or html is required); from_required — the receiving domain is not verified for sending, pass from; or a sender-domain error of the normal send path (for example an unverified from domain). |
401 | Missing or invalid API key. |
403 | insufficient_scope — only a full_access key may reply; plan_not_allowed — your plan does not include inbound e-mail. |
404 | No such inbound message on your workspace (expired or deleted messages included). |
409 | reply_blocked_automated — the original looks automated (details.kind, details.signals). force: true replies anyway unless it is a bounce (details.forceable: false). |
422 | no_reply_address — the original has no usable From or Reply-To address; all_recipients_suppressed — every recipient is on your suppression list. |
429 | reply_loop_guard — 5 replies in the hour or 20 in the day already went to this recipient (details.window, details.limit); or rate_limited — more than 60 calls in a minute on this key. |
503 | reply_guard_unavailable — loop protection is briefly unavailable, automatic replies are held back. Retry in a minute; a reply with automated: false still goes. |
Code examples
curl -X POST https://api.wemail.io/v3/inbound/messages/6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55/reply \
-H "Authorization: Bearer afn_live_…" \
-H "Content-Type: application/json" \
-d '{
"from": "Support <support@example.com>",
"text": "Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me."
}'
# 202 {"message_id":"msg_01HC2M9T7XKQ4R8B2N","to":["maria@efood.gr"],"subject":"Re: Quick question about your ESP"}
# 409 reply_blocked_automated → the original is an auto-reply, bounce, list or no-reply mail: do not answer it
# 429 reply_loop_guard → 5 replies/hour or 20/day already went to this recipientimport { WemailClient, ResponseError } from "@wemailio/sdk";
const wemail = new WemailClient(process.env.WEMAIL_API_KEY);
try {
const reply = await wemail.inbound.replyInboundMessage({
id: "6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55",
replyInboundMessageRequest: {
from: "Support <support@example.com>",
text: "Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me.",
},
});
console.log(reply.messageId, reply.to, reply.subject);
} catch (err) {
// 409 reply_blocked_automated / 429 reply_loop_guard: do not retry automatically
if (err instanceof ResponseError) console.error(err.response.status, (await err.response.json()).error);
else throw err;
}import os
from wemail import WemailClient, ReplyInboundMessageRequest
wemail = WemailClient(api_key=os.environ["WEMAIL_API_KEY"])
reply = wemail.inbound.reply_inbound_message(
"6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55",
ReplyInboundMessageRequest(
var_from="Support <support@example.com>", # "from" is a Python keyword
text="Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me.",
),
)
print(reply.message_id, reply.to, reply.subject)<?php
$wemail = new \Wemail\WemailClient(getenv('WEMAIL_API_KEY'));
$reply = $wemail->inbound()->replyInboundMessage(
'6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55',
new \Wemail\Sdk\Model\ReplyInboundMessageRequest([
'from' => 'Support <support@example.com>',
'text' => 'Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me.',
])
);
echo $reply->getMessageId(), ' ', $reply->getSubject();wemail = Wemail::Client.new(api_key: ENV["WEMAIL_API_KEY"])
reply = wemail.inbound.reply_inbound_message(
"6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55",
Wemail::ReplyInboundMessageRequest.new(
from: "Support <support@example.com>",
text: "Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me."
)
)
puts reply.message_id, reply.subjectclient, _ := wemail.NewClient(os.Getenv("WEMAIL_API_KEY"))
// Generated layer (client.API.*): pass the key in the context.
ctx := context.WithValue(context.Background(), wemail.ContextAccessToken, os.Getenv("WEMAIL_API_KEY"))
reply, _, err := client.API.InboundAPI.
ReplyInboundMessage(ctx, "6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55").
ReplyInboundMessageRequest(wemail.ReplyInboundMessageRequest{
From: wemail.PtrString("Support <support@example.com>"),
Text: wemail.PtrString("Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me."),
}).
Execute()
if err != nil {
log.Fatal(err) // 409 reply_blocked_automated / 429 reply_loop_guard: do not retry automatically
}
fmt.Println(reply.MessageId, reply.Subject)WemailClient wemail = new WemailClient(System.getenv("WEMAIL_API_KEY"));
InboundReplyResult reply = wemail.inbound().replyInboundMessage(
UUID.fromString("6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55"),
new ReplyInboundMessageRequest()
.from("Support <support@example.com>")
.text("Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me."));
System.out.println(reply.getMessageId() + " " + reply.getSubject());var wemail = new WemailClient(Environment.GetEnvironmentVariable("WEMAIL_API_KEY"));
var reply = await wemail.Inbound.ReplyInboundMessageAsync(
Guid.Parse("6f1c2a1e-7d3b-4b7e-9f0e-2a4c8d9b1e55"),
new ReplyInboundMessageRequest(
from: "Support <support@example.com>",
text: "Hi Maria, thanks for getting back to us. Next Tuesday at 11:00 works for me."));
Console.WriteLine(quot;{reply.MessageId} {reply.Subject}");{
"message_id": "msg_01HC2M9T7XKQ4R8B2N",
"to": ["maria@efood.gr"],
"subject": "Re: Quick question about your ESP",
"thread_id": "9b2f6a1c-3d4e-4f5a-8b6c-7d8e9f0a1b2c"
}