# 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) · [Auth reference](/docs/tags/auth.md)

## Get current identity

`GET /v1/me`



Operation ID: `getCurrentIdentity`

Permission: Needs any API key, person or agent token of the workspace.



### TypeScript SDK

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

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

const result = await getCurrentIdentity({
  client,
  throwOnError: true,
});

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

### cURL

```sh
curl --request GET \
  --url 'https://nightmail.dev/v1/me' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY"
```

### 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 |  |
| `workspaceId` | string | yes |  |
| `role` | string or null | yes |  |
| `multiTenant` | boolean | yes |  |
| `simulated` | boolean | yes |  |
| `email` | string or null | yes |  |
| `name` | string or null | yes |  |
| `permissions` | string[] | yes |  |
| `domains` | string[] | yes |  |
| `origin` | string | yes |  |
| `host` | string | yes |  |
| `mcpScopes` | string[] | yes | The OAuth scopes this installation's MCP server asks for, for read, send and manage (nightmail:read …, or bane:read … until the account service supports nightmail:*). |
| `connection` | object or null | yes | The current workspace's hosted sending connection; null when self-hosted. |
| `connection.kind` | string | yes |  |
| `connection.region` | string | yes |  |
| `connection.state` | string | yes | awaiting_role: waiting for the BYO stack. provisioning: verifying regional resources and importing verified domains. ready: sending allowed once the tenant is ready. failed: the last setup attempt failed; verify again. |
| `connection.tenant` | string | yes | Hosted only: the SES tenant that isolates this workspace. Sends are rejected with TENANT_NOT_READY until it is ready. BYO connections are always ready. |
| `connection.sendingPause` | object or null | yes | Hosted reputation hold: sending and dispatch are paused until operator review. Receiving is unaffected. |
| `connection.sendingLimit` | object or null | no | Hosted only: the daily limit (set by the sender score) that POST /v1/emails/send enforces with 429 SEND_LIMIT_REACHED. |
| `connection.standing` | object or null | no | Hosted only: the enforcement step summary. GET /v1/sender-score has the reasons, the limit math and what an owner can release. |
| `connection.domains` | object | no | Domains of its own the workspace claimed and how many can send. The built-in domain is not one of them. |
| `connection.sent` | boolean | no | Whether this workspace has any sent email in its log (test sends included; the log keeps 30 days). |
| `connection.received` | boolean | no | Whether this workspace has received any email (kept as long as its received mail is). |
| `connection.builtinDomain` | object or null | no | Hosted only: the subdomain of the installation's own domain this workspace sends and receives on before it verifies a domain of its own (sendEmail from any address at it), with who it sends to and its recipient caps. Absent when the installation has none; null until this workspace has one. |
| `connection.attention` | string | no | A connected AWS account's most pressing health finding, for a banner; absent when nothing needs attention. |
| `hostedSetup` | string or null | no | A hosted dashboard session in a workspace made seconds ago whose Hosted mail (its connection and built-in domain) is still being written: starting. Read /v1/me again shortly; null otherwise. |
| `focus` | array or null | no | A hosted dashboard session: what this workspace is here for, the first leading (focus in getWorkspaceSettings, which changes it). Null until chosen or for other credentials; empty when skipped. |
| `workspaces` | array or null | yes | A hosted dashboard session's workspaces and roles (select one with X-Nightmail-Workspace); null for keys, MCP, agent tokens and self-hosted. |
| `operator` | string or null | no | Nightmail staff only: the platform operator role of this dashboard session (it opens /operator). Null for everyone else, and for a session that didn't sign in with Google. |
| `staffSignIn` | boolean | no | Nightmail staff only: true when this person holds an operator role but this session didn't sign in with Google, which staff tools need. False otherwise. |
| `uiNotes` | boolean | no | Nightmail staff only: this session may use staff UI notes. False for everyone else. |
| `canCreateWorkspace` | boolean | no | Dashboard sessions: whether createWorkspace lets this session create another workspace. Hosted, only staff can for now; everyone else has one workspace and gets 403 WORKSPACE_LIMIT. False for keys, MCP and agent tokens. |
| `analytics` | boolean | no | Whether this installation records how its dashboard is used (DASHBOARD_ANALYTICS). The dashboard sends nothing when false. |
| `byo` | boolean | no | Hosted dashboard sessions: an operator lets this workspace connect its own AWS account (POST /v1/connection with kind byo). False otherwise, and the dashboard offers Hosted mail only. |
| `presence` | boolean | no | Whether this installation shows who else has a campaign open in the dashboard (campaign rooms run on the Cloudflare deployment). False on the Node server. |
| `billing` | object or null | no | Hosted dashboard sessions: whether the workspace is free, whether an empty balance has paused sending or held received mail, and auto-recharge, so the dashboard can show it on its first frame. Null otherwise; GET /v1/billing has the detail. |
| `billing.enforcement` | string | yes |  |
| `billing.free` | boolean | yes | Anomaly made this workspace free: never charged or paused for the balance. |
| `billing.sending` | string | yes |  |
| `billing.receiving` | string | yes |  |
| `billing.autoRecharge` | string | yes |  |
| `newsletters` | array or null | yes | The workspace’s oldest four newsletters (listNewsletters has them all), so a sidebar can name them on its first frame; a fourth means there are more. Null for a credential that cannot read lists (one without read, or limited to sender domains or addresses). |
| `mailServers` | object or null | no | The hosts mail apps connect to: IMAP on 993 (TLS) or 143 (STARTTLS), SMTP on 465 (TLS) or 587 (STARTTLS). An app password signs in to both; a send-only API key signs in to SMTP as apikey. Null when this installation has no IMAP/SMTP gateway. |
| `mailServers.imap` | string | yes |  |
| `mailServers.smtp` | string | yes |  |

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