> For the complete documentation index, see [llms.txt](https://docs.mailtrap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailtrap.io/developers/inbound/messages/reply-to-a-message.md).

# Reply to a message

Send a reply to an inbound message. The reply is threaded to the original and its subject is prefixed with `Re:` (unless it already starts with one).

By default the reply is addressed to the original sender (its `Reply-To`, or `From` when absent). Pass `to` to override the recipients — an explicit empty array sends to `cc`/`bcc` only — or add `cc`/`bcc`.

The sender depends on the inbox type:

* **Mailtrap-hosted inbox** — always sends from the inbox's own generated address. Supplying `from` is rejected with `400`.
* **Custom-domain inbox** — you supply `from`, whose address must belong to the inbox's domain. The token needs admin access on that sending domain.

```json
{"openapi":"3.1.0","info":{"title":"Inbound","version":"2.0.0"},"tags":[{"name":"messages","description":"Inbound messages are the emails delivered to an inbox. Use these\nendpoints to page through recent messages, fetch the full body and\nattachments, reply to or forward a message, or delete one you no longer\nneed.\n"}],"servers":[{"description":"Mailtrap API","url":"https://mailtrap.io"}],"security":[{"HeaderAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"HeaderAuth":{"type":"apiKey","description":"API token in Api-Token header","in":"header","name":"Api-Token"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer token authentication"}},"parameters":{"inbox_id":{"name":"inbox_id","in":"path","required":true,"description":"Inbound inbox ID","schema":{"type":"integer"}},"message_id":{"name":"id","in":"path","required":true,"description":"Inbound message ID","schema":{"type":"string"}}},"schemas":{"SendMessageInput":{"type":"object","description":"Options for the sent message. All fields are optional. `reply` and\n`reply_all` must carry a body (`text` and/or `html`); `forward` may omit\nit, since the original message is quoted automatically. `forward` has\nno default recipient, so supply at least one in `to`, `cc`, or `bcc`.\nAddresses use the Email Sending API `{ email, name }` shape. Missing\nbodies or recipients are rejected by the Email API with `400`.\n","properties":{"from":{"allOf":[{"$ref":"#/components/schemas/Address"}],"description":"Sender address. Rejected for Mailtrap-hosted inboxes (they always\nsend from their own address); required for custom-domain inboxes,\nwhere the address must belong to the inbox's domain.\n"},"to":{"type":"array","maxItems":1000,"items":{"$ref":"#/components/schemas/Address"}},"cc":{"type":"array","maxItems":1000,"items":{"$ref":"#/components/schemas/Address"}},"bcc":{"type":"array","maxItems":1000,"items":{"$ref":"#/components/schemas/Address"}},"reply_to":{"$ref":"#/components/schemas/Address"},"text":{"type":"string","description":"Plain-text body."},"html":{"type":"string","description":"HTML body."},"category":{"type":"string","maxLength":255,"description":"Email API category for the sent message."},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/EmailAttachment"}},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Custom headers to add to the sent message. `In-Reply-To` and\n`References` are always set from the original message and cannot be\noverridden.\n"},"custom_variables":{"type":"object","additionalProperties":{"type":"string"},"description":"Email API custom variables for the sent message."}}},"Address":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"},"name":{"type":"string"}}},"EmailAttachment":{"type":"object","required":["content","filename"],"properties":{"content":{"type":"string","description":"Base64-encoded attachment content."},"filename":{"type":"string"},"type":{"type":"string","description":"MIME type of the attachment."},"disposition":{"type":"string","enum":["attachment","inline"],"default":"attachment"},"content_id":{"type":"string","description":"`Content-ID` used to reference an inline attachment from the HTML\nbody. Only relevant when `disposition` is `inline`.\n"}}},"SendMessageResult":{"type":"object","required":["message_ids"],"properties":{"message_ids":{"type":"array","description":"UUIDs assigned by the Email API to the sent message, one per\nrecipient. These are the sent message's UUIDs — not the inbound\nmessage ID acted on, nor an RFC `Message-ID` header value.\n","items":{"type":"string"}}}},"SendMessageError":{"type":"object","properties":{"errors":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}}}},"responses":{"SendMessageAccepted":{"description":"Message queued for delivery. Returns the UUID(s) the Email API\nassigned to the sent message, one per recipient.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResult"}}}},"SendMessageBadRequest":{"description":"The message could not be sent. Returned for an invalid sender (for\nexample a `from` on a Mailtrap-hosted inbox, or one outside the inbox's\ndomain) and for validation errors rejected by the Email API.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageError"}}}},"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"SendMessageForbidden":{"description":"The token lacks admin access (on the inbox for a Mailtrap-hosted inbox,\nor on the inbox's sending domain for a custom-domain inbox), the\nMailtrap-hosted sending limit has been reached, or the Email API\nrejected the message.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageError"}}}},"NotFound":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"PayloadTooLarge":{"description":"The message exceeds the maximum allowed size.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageError"}}}},"TooManyRequests":{"description":"Too many requests. Retry after a short delay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageError"}}}}}},"paths":{"/api/inbound/inboxes/{inbox_id}/messages/{id}/reply":{"post":{"operationId":"replyToInboundMessage","summary":"Reply to a message","description":"Send a reply to an inbound message. The reply is threaded to the\noriginal and its subject is prefixed with `Re:` (unless it already\nstarts with one).\n\nBy default the reply is addressed to the original sender (its\n`Reply-To`, or `From` when absent). Pass `to` to override the\nrecipients — an explicit empty array sends to `cc`/`bcc` only — or add\n`cc`/`bcc`.\n\nThe sender depends on the inbox type:\n\n- **Mailtrap-hosted inbox** — always sends from the inbox's own\n  generated address. Supplying `from` is rejected with `400`.\n- **Custom-domain inbox** — you supply `from`, whose address must\n  belong to the inbox's domain. The token needs admin access on that\n  sending domain.\n","tags":["messages"],"parameters":[{"$ref":"#/components/parameters/inbox_id"},{"$ref":"#/components/parameters/message_id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageInput"}}}},"responses":{"201":{"$ref":"#/components/responses/SendMessageAccepted"},"400":{"$ref":"#/components/responses/SendMessageBadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/SendMessageForbidden"},"404":{"$ref":"#/components/responses/NotFound"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"429":{"$ref":"#/components/responses/TooManyRequests"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mailtrap.io/developers/inbound/messages/reply-to-a-message.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
