NightmailDocs
Docs

Get metrics

get/v1/metrics

Operational created-cohort metrics, not invoicing or provider reputation. Dashboard sessions may receive a cached result until the workspace creates an email or records an email event (quantized to 10-second buckets during high-volume sending), or for up to 60 seconds, and compute at most 30 such Overview reads a minute: past that they get their last result (cache header stale) or 429 DASHBOARD_RATE_LIMITED. API keys, MCP and agent tokens always get fresh results. Selects emails created in [from,to), scoped by email region and stream. to defaults to now and from to 24 hours (granularity=10m) or 30 days before to; from equal to to is an empty window. Outcomes use current email state and all recorded events, including events after to; this is not a historical state snapshot. Each outcome counts distinct emails, so replays do not inflate counts and outcomes may overlap. Accepted (bucket sent) means evidence of provider acceptance, not merely queued/created. Daily UTC creation buckets contain count=created emails. Granularity defaults to day; granularity=hour returns hourly UTC creation buckets and granularity=10m returns 10-minute UTC creation buckets (within the last 6 days) with canonical ISO dates, while preserving daily buckets and totals. Absent buckets mean zero created emails and zero outcomes; no moving averages are applied. Engagement is observed, not verified human activity. Each statement stops after 5 seconds: a request that needs longer is refused with 422 READ_TOO_LARGE. Narrow the dates or filters.

Needs Sent mail: read on the whole workspace.

Example

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

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

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

console.log(result.data);
curl --request GET \
  --url 'https://nightmail.dev/v1/metrics' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY"

Parameters

regionquery · string
fromquery · string
toquery · string
streamquery · string
granularityquery · string
includequery · string

Comma-separated extras computed in the same statement: previous (totals for the window of equal length ending at from) and streams (totals per stream for the window, ignoring the stream filter).

Responses

200Success
Metrics
basisrequiredstring
fromrequiredstring
torequiredstring
regionrequiredstring or null
streamrequiredstring or null
totalsrequiredobject
totals.emailsrequirednumber
totals.acceptedrequirednumber
totals.deliveredrequirednumber
totals.bouncedrequirednumber
totals.complainedrequirednumber
totals.openedrequirednumber
totals.clickedrequirednumber
totals.failedrequirednumber
totals.deliveryDelayedrequirednumber
totals.simulatedrequirednumber
dailyrequiredobject[]
daily[].daterequiredstring
daily[].countrequirednumber
daily[].sentrequirednumber
daily[].deliveredrequirednumber
daily[].bouncedrequirednumber
daily[].complainedrequirednumber
hourlyobject[]
hourly[].daterequiredstring
hourly[].countrequirednumber
hourly[].sentrequirednumber
hourly[].deliveredrequirednumber
hourly[].bouncedrequirednumber
hourly[].complainedrequirednumber
tenMinuteobject[]
tenMinute[].daterequiredstring
tenMinute[].countrequirednumber
tenMinute[].sentrequirednumber
tenMinute[].deliveredrequirednumber
tenMinute[].bouncedrequirednumber
tenMinute[].complainedrequirednumber
previousobject

Present with include=previous.

previous.fromrequiredstring
previous.torequiredstring
previous.totalsrequiredobject
streamsobject

Present with include=streams.

streams.transactionalrequiredobject
streams.marketingrequiredobject
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.