Start a conversation
/v1/inbound/threadsStart a conversation from an inbound address.
Needs Send email for the address or inbox.
Example
import { createClient } from '@nightmail/sdk/client';
import { createInboundThread } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await createInboundThread({
client,
body: {
"attachments": [],
"replyTo": [],
"headers": [],
"addressId": "address_123",
"to": [
"recipient@example.com"
],
"cc": [],
"bcc": [],
"subject": "Hello from Nightmail"
},
throwOnError: true,
});
console.log(result.data);curl --request POST \
--url 'https://nightmail.dev/v1/inbound/threads' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"attachments": [],
"replyTo": [],
"headers": [],
"addressId": "address_123",
"to": [
"recipient@example.com"
],
"cc": [],
"bcc": [],
"subject": "Hello from Nightmail"
}'Parameters
Idempotency-Keyheader · stringOptional. 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
CreateInboundThreadfromstringDefaults 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.
textstringhtmlstringattachmentsobject 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[].namerequiredstringheaders[].valuerequiredstringautoSubmittedstringAdds an RFC 3834 Auto-Submitted header so other automated systems do not reply to this message.
addressIdrequiredstringOpaque inbound address ID (mbx_…).
torequiredstring[]ccstring[]bccstring[]subjectrequiredstringResponses
202Queued, not yet delivered.
InboundMessagesimulatedbooleanidrequiredstringthreadIdrequiredstringaddressIdsrequiredstring[]directionrequiredstringstatusrequiredstringfromrequiredobjectfrom.namerequiredstring or nullfrom.addressrequiredstringtorequiredobject[]Addresses in the To header (at most 20 on conversation pages, up to 100 on getInboundMessage).
to[].namerequiredstring or nullto[].addressrequiredstringtoCountrequiredintegerTotal 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 nullcc[].addressrequiredstringccCountrequiredintegerTotal 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 nullreplyTo[].addressrequiredstringreplyToCountrequiredintegerTotal addresses in the Reply-To header (may exceed replyTo.length when shortened).
subjectrequiredstringsnippetrequiredstringtextrequiredstringreplyTextrequiredstringreceivedAtrequiredstringbodyTruncatedrequiredbooleanattachmentCountrequiredintegerreadrequiredbooleanerrorCoderequiredstring or nullsuppressionReasonstring or nullReason 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 nullmessageIdrequiredstring or nullRFC Message-ID, not the Nightmail message ID (id).
inReplyTorequiredstring or nullreferencesrequiredstring[]Message-IDs in the References header (at most 20 on conversation pages, up to 100 on getInboundMessage).
referencesCountrequiredintegerTotal 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.
ApiErrorerrorrequiredobjecterror.coderequiredstringerror.messagerequiredstringerror.requestIdrequiredstringerror.fieldstringerror.retryablerequiredbooleanerror.resetAtstringNext 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.requiredobjectOn a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.