Set where an address’s mail goes
/v1/inbound/addresses/{addressId}/flowChange where one address’s mail goes, in one version. Changes the route for the address’s own address and its two-way rule together: one transaction and one routing version, so all of it is saved or none of it. Omitted fields stay as they are, a field equal to what is saved writes nothing, and when nothing changes the version stays. deliver replaces only the route’s destinations (a paused route stays paused). Send the version from getInboundOverview or getRouting as If-Match; a stale one is refused with 409 and nothing changes.
Needs Receiving rules: write on the whole workspace. A person needs to be an owner or admin. Not a temporary agent token.
Example
import { createClient } from '@nightmail/sdk/client';
import { setInboundAddressFlow } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await setInboundAddressFlow({
client,
path: {
"addressId": "address_123"
},
body: {},
throwOnError: true,
});
console.log(result.data);curl --request PATCH \
--url 'https://nightmail.dev/v1/inbound/addresses/address_123/flow' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
--header 'Content-Type: application/json' \
--data '{}'Parameters
addressIdrequiredpath · stringOpaque inbound address ID (mbx_…).
if-matchheader · stringApply only if routes and rules are still at this version, from getInboundOverview, GET /v1/routing or a previous ETag.
Request body
SetInboundAddressFlowendpointsobject[]New endpoints this change uses, made with it: a refusal or failure makes none of them.
endpoints[].typerequiredstringendpoints[].namerequiredstringEndpoint name, unique in the workspace across every type.
endpoints[].urlrequiredstringAs createEndpoint takes it: a Slack or Discord webhook URL, or a public HTTPS URL for a webhook (its signing secret is not returned here).
forwardobjectA new forward: its recipient is asked by this address when it can send the request (else as createEndpoint picks one). deliver and split may name it at once: mail received from the moment they allow it is forwarded, never mail received before. The answer’s forward says whether they were emailed.
forward.namerequiredstringEndpoint name, unique in the workspace across every type.
forward.addressrequiredstringRecipient. They confirm with an emailed link, sent from the new address when it can send it (else as createEndpoint picks one), unless preverify applies.
forward.preverifyboolean or stringAs createEndpoint takes it: auto skips the confirmation only for an address on a domain this workspace has verified.
deliverstring or string or string[] or nullWhere the address's mail goes: the destinations of the route for its own address, as createRoute takes them (inbox, webhook and forward IDs or keys, [] to keep it without an inbox, or 'drop'). Creates the route when there is none; null deletes it.
rulestringThe key of the two-way rule (split or split-by-meaning) on this address that split changes.
splitobject or nullWith rule: rewrites that rule. A rule other addresses also run is left as it is for them, and this address gets its own copy under a new key. Without rule: adds a new two-way rule on this address. null, with rule: takes the rule off this address, and deletes it once no address runs it.
split.reciperequiredstringsplit, or split-by-meaning to let the AI decide.
split.paramsobjectThe fields createRuleFromRecipe takes for this recipe: split { test, value, then, otherwise }, split-by-meaning { meaning, then, otherwise }.
Responses
200Success
InboundAddressFlowversionrequiredintegerThe routing and rules version after the change, also the ETag; unchanged when nothing changed.
forwardobjectThe forward flow.forward made, as getEndpoint returns it.
forward.idrequiredstringEndpoint ID: mwh_… for a webhook, con_… for Slack, Discord or a forward. Routes list webhooks and forwards by ID.
forward.namerequiredstringEndpoint name, unique in the workspace across every type. Rules call endpoints.<name>(…).
forward.typerequiredstringforward.statusrequiredstringready: callable. pending: a forward waiting for its recipient to confirm. expired: the confirmation link lapsed. declined: the recipient declined or stopped forwards. paused: deliveries are held.
forward.callrequiredstringHow a rule calls it.
forward.targetrequiredstringWhere it delivers. Slack, Discord and webhook URLs are write-only; only the last four characters are shown.
forward.policyrequiredobjectforward.expiresAtrequiredstring or nullWhen a pending forward confirmation link expires.
forward.requestFromrequiredstring or nullA forward: the address that emailed its recipient to confirm. null when none was asked (preverified) and for other types.
forward.nextSteprequiredstringWhat to do next, for people and agents.
forward.createdAtrequiredstringforward.confirmationrequiredstringemailed: its recipient was asked to confirm (requestFrom names who asked); skipped: preverified, ready at once.
routerequiredobject or nullThe route for the address's own address, as getRoute returns it; null when there is none.
route.keyrequiredstring or nullStable key you choose (lowercase letters, digits, hyphens). Config files refer to inbox:<key>, webhook:<key> and forward:<name>.
route.matchrequiredstringRecipient, case-insensitive: an address (support@acme.com), a local-part pattern (reply+*@acme.com, *-invoices@acme.com) or a catch-all (*@acme.com, or @acme.com). The most specific route wins: exact address, then the pattern with the most literal characters, then the plus-address base, then the catch-all, then the domain default.
route.torequiredstring or string or string[]Inbox, webhook and forward IDs, [] to keep, or 'drop'.
route.subaddressesrequiredbooleanroute.enabledrequiredbooleanroute.noterequiredstringroute.idrequiredstringroute.createdAtrequiredstringrulerequiredstring or nullThe two-way rule this change left on the address: the rule it named, its own copy when the rule was shared, or the new rule. null when it was taken off, or no rule was named or added.
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.