NightmailDocs
Docs

Create a receivable address

post/v1/inbound/addresses

Admin only. Mail arrives once the domain is verified and its receiving MX record is active. Hosted, an address on one of your own domains (or a subdomain of one), verified or still being verified, where nothing receives yet turns receiving on at its host, as addReceivingHost does, and the answer’s receiving names the MX record to publish, the host’s status and whether the domain is verified yet; a host whose mail another provider receives today is refused with RECEIVING_HOST_IN_USE and the call that moves it. A refused request creates nothing, and receiving stays as it was. Permanent addresses claim earlier unrouted mail (kept 30 days) for their address or rules; temporary addresses start empty. Expiry stops new delivery and sending without deleting history.

Needs Inboxes: write on the whole workspace. A person needs to be an owner or admin.

Example

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

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

const result = await createInboundAddress({
  client,
  body: {
    "address": "example",
    "aliases": [],
    "rules": [],
    "metadata": {},
    "requireDmarc": false
  },
  throwOnError: true,
});

console.log(result.data);
curl --request POST \
  --url 'https://nightmail.dev/v1/inbound/addresses' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "address": "example",
  "aliases": [],
  "rules": [],
  "metadata": {},
  "requireDmarc": false
}'

Request body

CreateInboundAddress
keystring or null

Stable key you choose (lowercase letters, digits, hyphens). Config files refer to inbox:<key>, webhook:<key> and forward:<name>.

addressrequiredstring
displayNamestring or null
publicAddressstring

Permanent addresses only: immutable default From with the same local part on a strict ancestor domain verified for sending with DKIM in the receiving region. Does not change routing or MX.

ttlSecondsinteger

Lease duration in seconds, 60–2592000 (30 days). Omit for a permanent address. Temporary addresses accept plus-tags, not aliases, wildcard rules or historical backfill. Expiry is fixed at creation.

aliasesstring[]
rulesstring[]

Wildcard address patterns, e.g. support+*@acme.com or *@help.acme.com.

metadataobject
sendLimitsobject

Override the loop guards. Defaults: perRecipientPerHour 20, perThreadPer10Minutes 10. 0 blocks sending. There is no hourly or daily cap per address.

sendLimits.perHourinteger

Deprecated and not enforced: any whole number from 0 is accepted. 0 turns sending off; any other number has no effect.

sendLimits.perDayinteger

Deprecated and not enforced: any whole number from 0 is accepted. 0 turns sending off; any other number has no effect.

sendLimits.perRecipientPerHourinteger
sendLimits.perThreadPer10Minutesinteger
requireDmarcboolean

Hold received mail without a DMARC pass for its From domain: it is stored with the unverified label and does not emit message.received.

flowobject

Where the new address’s mail goes, saved with the address in one transaction and one routing version: deliver creates the route for its own address, split adds a two-way rule on it (setInboundAddressFlow changes both later). If any part is refused, nothing is created. Needs what changing routes and rules needs.

flow.endpointsobject[]

New endpoints this change uses, made with it: a refusal or failure makes none of them.

flow.forwardobject

A new forward, made after the address: its recipient is asked by the new address. deliver and split may name it at once (forward:<name>; <name> in split params): mail received from the moment they allow it is forwarded, never mail received before. The answer’s forward says whether they were emailed.

flow.deliverstring or string or string[] or null

Where 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.

flow.splitobject

Adds a two-way rule on the new address. Its params may name the new address as inbox:<key>.

Responses

201Success
CreatedInboundAddress
idrequiredstring
keyrequiredstring or null

Stable key you choose (lowercase letters, digits, hyphens). Config files refer to inbox:<key>, webhook:<key> and forward:<name>.

addressrequiredstring
displayNamerequiredstring or null
domainrequiredstring
aliasesrequiredstring[]
rulesrequiredstring[]
publicAddressrequiredstring or null

Send-only address used as the default From. Null to send from the receiving address.

metadatarequiredobject
originrequiredstring
createdAtrequiredstring
updatedAtrequiredstring
expiresAtrequiredstring or null

UTC lease expiry, or null for a permanent address. After expiry, new delivery and sending stop. History stays readable and the address remains reserved until an admin deletes it.

statsrequiredobject
stats.threadsrequiredinteger
stats.unreadThreadsrequiredinteger
stats.lastMessageAtrequiredstring or null
sendLimitsrequiredobject

Loop guards against runaway agents and reply loops: messages to one recipient per hour, and in one conversation per 10 minutes. The workspace’s sending limits apply on top; there is no hourly or daily cap per address.

sendLimits.perHourrequiredinteger

Deprecated and not enforced: an address has no hourly send cap. The value last set (100 if never set); 0 means sending is off.

sendLimits.perDayrequiredinteger

Deprecated and not enforced: an address has no daily send cap. The value last set (1000 if never set); 0 means sending is off.

sendLimits.perRecipientPerHourrequiredinteger
sendLimits.perThreadPer10Minutesrequiredinteger
requireDmarcrequiredboolean

When true, received mail without a DMARC pass for its From domain is stored with the unverified label and does not emit message.received.

kindrequiredstring

inbox: an agent inbox; manage it with /v1/inboxes.

receivingobject

Present while the host doesn’t route mail here yet: hosted, an address on one of your own domains, verified or still being verified, turns receiving on at its host if it was off.

receiving.domainIdrequiredstring

The domain the address is on (receiving hosts: /v1/inbound/domains/{id}/hosts).

receiving.hostrequiredstring

Where the address receives.

receiving.turnedOnrequiredboolean

Whether creating the address turned receiving on at this host (it didn’t receive mail before).

receiving.statusrequiredstring

The host’s receiving status now: waiting_for_mx until its MX record is live (poll getInboundDomain or listReceivingHosts).

receiving.verifiedrequiredboolean

Whether the domain is verified. Until it is (its DNS records: getDomain), mail waits even with the MX record live.

receiving.dnsrequiredobject[]

The MX record to publish at the host, if it isn’t already: mail arrives once it is.

forwardobject

The forward flow.forward made, as getEndpoint returns it.

forward.idrequiredstring

Endpoint ID: mwh_… for a webhook, con_… for Slack, Discord or a forward. Routes list webhooks and forwards by ID.

forward.namerequiredstring

Endpoint name, unique in the workspace across every type. Rules call endpoints.<name>(…).

forward.typerequiredstring
forward.statusrequiredstring

ready: 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.callrequiredstring

How a rule calls it.

forward.targetrequiredstring

Where it delivers. Slack, Discord and webhook URLs are write-only; only the last four characters are shown.

forward.policyrequiredobject
forward.expiresAtrequiredstring or null

When a pending forward confirmation link expires.

forward.requestFromrequiredstring or null

A forward: the address that emailed its recipient to confirm. null when none was asked (preverified) and for other types.

forward.nextSteprequiredstring

What to do next, for people and agents.

forward.createdAtrequiredstring
forward.confirmationrequiredstring

emailed: its recipient was asked to confirm (requestFrom names who asked); skipped: preverified, ready at once.

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.