NightmailDocs
Docs

Reply in a visible conversation

post/v1/inbound/threads/{threadId}/reply

Replies to the newest visible message in either direction, breaking time ties by descending message ID. addressId restricts the target and sending address; provide it when the target is linked to more than one visible address. Set replyToMessageId to select an older visible message in this thread. For reviewed replies, pin both IDs and expectedRecipients. A recipient mismatch or a pending outbound parent without a provider Message-ID returns 409.

Needs Send email for the address or inbox.

Example

import { createClient } from '@nightmail/sdk/client';
import { replyToInboundThread } from '@nightmail/sdk';

const client = createClient({
  baseUrl: 'https://nightmail.dev',
  auth: scheme => scheme.scheme === 'bearer'
    ? process.env.NIGHTMAIL_API_KEY
    : undefined,
});

const result = await replyToInboundThread({
  client,
  path: {
    "threadId": "thread_123"
  },
  body: {
    "attachments": [],
    "replyTo": [],
    "headers": [],
    "replyAll": false,
    "bcc": [],
    "quote": false,
    "allowAutomated": false
  },
  throwOnError: true,
});

console.log(result.data);
curl --request POST \
  --url 'https://nightmail.dev/v1/inbound/threads/thread_123/reply' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "attachments": [],
  "replyTo": [],
  "headers": [],
  "replyAll": false,
  "bcc": [],
  "quote": false,
  "allowAutomated": false
}'

Parameters

threadIdrequiredpath · string
Idempotency-Keyheader · string

Optional. Makes retries safe. Repeating a request with the same key and the same body returns the original result without performing the write again. While the first request with a key is still running, a duplicate returns 409 IDEMPOTENCY_IN_PROGRESS with Retry-After: retry with the same key, never a new one. Reusing a key with a different body returns 409 IDEMPOTENCY_CONFLICT. Keys are scoped to the API key and request path. A send's key is kept at least 30 days from the request, as long as the log of the emails it queued; then it is deleted, and the same key is a new request that sends again. A scheduled send's key is kept at least 60 days, after which a repeat is refused because its time has passed. Without a key, every request is processed, so a retried send can deliver twice.

Request body

ReplyToInboundThread
fromstring

Defaults to the public address if configured, otherwise the primary receiving address. Address keys may use only addresses owned by this mailbox. Administrators may use any address on a domain registered in Nightmail for the receiving region; replies still return to whatever address the recipient answers.

textstring
htmlstring
attachmentsobject or object[]

Up to 100 files, 25 MiB combined. Any type Amazon SES delivers (executables and scripts are refused).

replyTostring[]
headersobject[]

Extra MIME headers, 8 KB total. The 15-header limit includes generated headers (two for marketing and any mailbox threading headers). Any name is allowed except headers Nightmail controls: From, Sender, Reply-To, Return-Path, To, Cc, Bcc, Subject, Date, Message-ID, MIME-Version, Content-*, DKIM-*, ARC-*, Authentication-Results, Received*, Resent-*, X-SES-*, List-Unsubscribe*, Auto-Submitted, and reply, receipt, trace and transport headers (Mail-Reply-To, Mail-Followup-To, Followup-To, Disposition-Notification-*, Return-Receipt-To, Errors-To, Bounces-To, Delivered-To, X-Original-To, DomainKey-*, Feedback-ID, TLS-Required, BIMI-*, Autocrypt*, OpenPGP). In-Reply-To and References must be <id@domain> Message-IDs and thread the message in the recipient's mail client.

headers[].namerequiredstring
headers[].valuerequiredstring
autoSubmittedstring

Adds an RFC 3834 Auto-Submitted header so other automated systems do not reply to this message.

addressIdstring

Opaque inbound address ID (mbx_…).

replyToMessageIdstring

Nightmail message ID (msg_…) of a visible message in this thread.

expectedRecipientsobject

Check the final To, Cc and Bcc against these reviewed address sets; never overrides recipients. A mismatch returns 409 INBOUND_RECIPIENTS_CHANGED.

expectedRecipients.torequiredstring[]
expectedRecipients.ccrequiredstring[]
expectedRecipients.bccrequiredstring[]
replyAllboolean

Also copy everyone else on the original message.

tostring[]

Override the computed recipients.

ccstring[]
bccstring[]
subjectstring

Defaults to "Re: <original subject>".

quoteboolean

Append the original message as quoted text.

allowAutomatedboolean

Reply even when the original is automated or the recipient is a no-reply address.

Responses

202Queued, not yet delivered.
InboundMessage
simulatedboolean
idrequiredstring
threadIdrequiredstring
addressIdsrequiredstring[]
directionrequiredstring
statusrequiredstring
fromrequiredobject
from.namerequiredstring or null
from.addressrequiredstring
torequiredobject[]

Addresses in the To header (at most 20 on conversation pages, up to 100 on getInboundMessage).

to[].namerequiredstring or null
to[].addressrequiredstring
toCountrequiredinteger

Total addresses in the To header (may exceed to.length when shortened).

ccrequiredobject[]

Addresses in the Cc header (at most 20 on conversation pages, up to 100 on getInboundMessage).

cc[].namerequiredstring or null
cc[].addressrequiredstring
ccCountrequiredinteger

Total addresses in the Cc header (may exceed cc.length when shortened).

replyTorequiredobject[]

Addresses in the Reply-To header (at most 20 on conversation pages, up to 100 on getInboundMessage).

replyTo[].namerequiredstring or null
replyTo[].addressrequiredstring
replyToCountrequiredinteger

Total addresses in the Reply-To header (may exceed replyTo.length when shortened).

subjectrequiredstring
snippetrequiredstring
textrequiredstring
replyTextrequiredstring
receivedAtrequiredstring
bodyTruncatedrequiredboolean
attachmentCountrequiredinteger
readrequiredboolean
errorCoderequiredstring or null
suppressionReasonstring or null

Reason recorded when this send was suppressed. For a multi-recipient send blocked locally, this is the first blocked recipient in To, Cc, Bcc order.

emailIdrequiredstring or null
messageIdrequiredstring or null

RFC Message-ID, not the Nightmail message ID (id).

inReplyTorequiredstring or null
referencesrequiredstring[]

Message-IDs in the References header (at most 20 on conversation pages, up to 100 on getInboundMessage).

referencesCountrequiredinteger

Total Message-IDs in the References header (may exceed references.length when shortened).

400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiError
errorrequiredobject
error.coderequiredstring
error.messagerequiredstring
error.requestIdrequiredstring
error.fieldstring
error.retryablerequiredboolean
error.resetAtstring

Next capacity change for a Hosted rolling send limit.

error.detailsobject[]

Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch).

error.requiredobject

On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.