# Nightmail API

Send, receive and reply to email on your own domains. 202 means queued, not delivered.

- [Interactive documentation](/docs)
- [OpenAPI 3.1 JSON](/openapi.json)
- [Agent index](/llms.txt)
- TypeScript package: `@nightmail/sdk`

[API index](/docs.md) · [Inbound addresses reference](/docs/tags/inbound-addresses.md)

## Update inbound address

`PATCH /v1/inbound/addresses/{addressId}`

Admin only. Only supplied fields change. The address, public sender and expiry are immutable.

Operation ID: `updateInboundAddress`

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `addressId` | path | string | yes | Opaque inbound address ID (mbx_…). |

### Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string or null | no | Stable key you choose (lowercase letters, digits, hyphens). Config files refer to inbox:<key>, webhook:<key> and forward:<name>. |
| `displayName` | string or null | no |  |
| `aliases` | string[] | no |  |
| `rules` | string[] | no |  |
| `metadata` | object | no |  |
| `sendLimits` | object | no | Override the loop guards. Defaults: perRecipientPerHour 20, perThreadPer10Minutes 10. 0 blocks sending. There is no hourly or daily cap per address. |
| `sendLimits.perHour` | integer | no | Deprecated and not enforced: any whole number from 0 is accepted. 0 turns sending off; any other number has no effect. |
| `sendLimits.perDay` | integer | no | Deprecated and not enforced: any whole number from 0 is accepted. 0 turns sending off; any other number has no effect. |
| `sendLimits.perRecipientPerHour` | integer | no |  |
| `sendLimits.perThreadPer10Minutes` | integer | no |  |
| `requireDmarc` | boolean | no |  |

### TypeScript SDK

```ts
import { createClient } from '@nightmail/sdk/client';
import { updateInboundAddress } from '@nightmail/sdk';

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

const result = await updateInboundAddress({
  client,
  path: {
    "addressId": "address_123"
  },
  body: {},
  throwOnError: true,
});

console.log(result.data);
```

### cURL

```sh
curl --request PATCH \
  --url 'https://nightmail.dev/v1/inbound/addresses/address_123' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{}'
```

### Responses

| Status | Description | Schema |
| --- | --- | --- |
| `200` | Success | object |
| `400`, `401`, `403`, `404`, `409`, `413`, `422`, `429`, `500`, `503` | Request failed; use error.code and requestId to diagnose. | object |

#### 200: Success

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `key` | string or null | yes | Stable key you choose (lowercase letters, digits, hyphens). Config files refer to inbox:<key>, webhook:<key> and forward:<name>. |
| `address` | string | yes |  |
| `displayName` | string or null | yes |  |
| `domain` | string | yes |  |
| `aliases` | string[] | yes |  |
| `rules` | string[] | yes |  |
| `publicAddress` | string or null | yes | Send-only address used as the default From. Null to send from the receiving address. |
| `metadata` | object | yes |  |
| `origin` | string | yes |  |
| `createdAt` | string | yes |  |
| `updatedAt` | string | yes |  |
| `expiresAt` | string or null | yes | 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. |
| `stats` | object | yes |  |
| `stats.threads` | integer | yes |  |
| `stats.unreadThreads` | integer | yes |  |
| `stats.lastMessageAt` | string or null | yes |  |
| `sendLimits` | object | yes | 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.perHour` | integer | yes | 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.perDay` | integer | yes | 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.perRecipientPerHour` | integer | yes |  |
| `sendLimits.perThreadPer10Minutes` | integer | yes |  |
| `requireDmarc` | boolean | yes | When true, received mail without a DMARC pass for its From domain is stored with the unverified label and does not emit message.received. |
| `kind` | string | yes | inbox: an agent inbox; manage it with /v1/inboxes. |

#### 400, 401, 403, 404, 409, 413, 422, 429, 500, 503: Request failed; use error.code and requestId to diagnose.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |
| `error.code` | string | yes |  |
| `error.message` | string | yes |  |
| `error.requestId` | string | yes |  |
| `error.field` | string | no |  |
| `error.retryable` | boolean | yes |  |
| `error.resetAt` | string | no | Next capacity change for a Hosted rolling send limit. |
| `error.details` | object[] | no | 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.required` | object | no | On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same. |
