NightmailDocs
Docs

Get public stats

get/v1/public/stats

Public, unauthenticated sending figures for the installation. A minute job computes them from stored mail; this route only reads the result, so a request never scans mail. Aggregates over whole UTC hours, rounded, and only once at least 10 workspaces have sent (available); a hosted installation counts only mail sent through its shared pool. No workspace, address or per-workspace figure is returned. Responses are cached for up to 60 seconds. 503 until the figures are first computed.

Needs no credential.

Example

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

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

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

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

Responses

200Success
PublicStats
generatedAtrequiredstring

The end of the last whole UTC hour the figures cover. They change at most once an hour; responses are cached for up to 60 seconds.

availablerequiredboolean

False until at least 10 workspaces have sent mail in the last 30 days. Every figure is then null and regions is empty, so the figures never describe a single customer.

acceptedLast30Daysrequiredinteger or null

Emails Amazon SES accepted in the last 30 whole days of hours, rounded to two significant figures (to the nearest 10 below 100). Simulated, suppressed and rejected mail is excluded. Email history is kept for 30 days, so there is no all-time total.

acceptedLastHourrequiredinteger or null

Emails Amazon SES accepted in the last whole UTC hour, rounded the same way. The last entry of acceptedHourly.

acceptedHourlyrequiredinteger or null[]

Accepted emails per whole UTC hour over the last 24 hours, oldest first, rounded. Null for an hour in which fewer than 3 workspaces sent.

deliveryRaterequirednumber or null

delivered ÷ (delivered + bounced) for emails created in the last 30 days, each email counted once, to three decimals. Null without outcomes.

medianSendLatencyMsrequiredinteger or null

Median time from API acceptance to Amazon SES acceptance for the most recent 5,000 direct, unscheduled sends in the last 24 whole hours, to the nearest 10 ms. Null without samples from at least 3 workspaces.

regionsrequiredstring[]

AWS regions that accepted mail in the last 30 days. Hosted installations list only their shared sending regions.

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.