Get current identity
/v1/meNeeds any API key, person or agent token of the workspace.
Example
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 --request GET \
--url 'https://nightmail.dev/v1/me' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY"Responses
200Success
idrequiredstringworkspaceIdrequiredstringrolerequiredstring or nullmultiTenantrequiredbooleansimulatedrequiredbooleanemailrequiredstring or nullnamerequiredstring or nullpermissionsrequiredstring[]domainsrequiredstring[]originrequiredstringhostrequiredstringmcpScopesrequiredstring[]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:*).
connectionrequiredobject or nullThe current workspace's hosted sending connection; null when self-hosted.
connection.kindrequiredstringconnection.regionrequiredstringconnection.staterequiredstringawaiting_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.tenantrequiredstringHosted 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.sendingPauserequiredobject or nullHosted reputation hold: sending and dispatch are paused until operator review. Receiving is unaffected.
connection.sendingLimitobject or nullHosted only: the daily limit (set by the sender score) that POST /v1/emails/send enforces with 429 SEND_LIMIT_REACHED.
connection.standingobject or nullHosted only: the enforcement step summary. GET /v1/sender-score has the reasons, the limit math and what an owner can release.
connection.domainsobjectDomains of its own the workspace claimed and how many can send. The built-in domain is not one of them.
connection.sentbooleanWhether this workspace has any sent email in its log (test sends included; the log keeps 30 days).
connection.receivedbooleanWhether this workspace has received any email (kept as long as its received mail is).
connection.builtinDomainobject or nullHosted 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.attentionstringA connected AWS account's most pressing health finding, for a banner; absent when nothing needs attention.
hostedSetupstring or nullA 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.
focusarray or nullA 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.
workspacesrequiredarray or nullA hosted dashboard session's workspaces and roles (select one with X-Nightmail-Workspace); null for keys, MCP, agent tokens and self-hosted.
operatorstring or nullNightmail 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.
staffSignInbooleanNightmail 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.
uiNotesbooleanNightmail staff only: this session may use staff UI notes. False for everyone else.
canCreateWorkspacebooleanDashboard 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.
analyticsbooleanWhether this installation records how its dashboard is used (DASHBOARD_ANALYTICS). The dashboard sends nothing when false.
byobooleanHosted 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.
presencebooleanWhether this installation shows who else has a campaign open in the dashboard (campaign rooms run on the Cloudflare deployment). False on the Node server.
billingobject or nullHosted 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.enforcementrequiredstringbilling.freerequiredbooleanAnomaly made this workspace free: never charged or paused for the balance.
billing.sendingrequiredstringbilling.receivingrequiredstringbilling.autoRechargerequiredstringnewslettersrequiredarray or nullThe 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).
mailServersobject or nullThe 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.imaprequiredstringmailServers.smtprequiredstring400, 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.