NightmailDocs
Docs

Read or wait for the rules version

get/v1/rules/version

Read the rules and routes version, or wait for it to change. Without after, returns the current version at once. With after (and endpoints, to include endpoint changes), waits up to wait seconds for a rule, route or endpoint save and returns as soon as one commits, with who saved it. The dashboard keeps one of these open while you edit rules so an agent’s saves appear live. Each waited 2.5 seconds counts as one request against the credential’s per-minute budget.

Needs Receiving rules: read on the whole workspace. A person needs to be an owner or admin.

Example

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

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

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

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

Parameters

afterquery · integer or null

The version you have. The call waits until the version differs from it.

endpointsquery · string

The endpoints marker from the last response: also wait for an endpoint to be created, changed or deleted.

waitquery · integer or null

Seconds to wait for a change (0–25). Ignored without after or endpoints.

Responses

200Success
RuleVersion
versionrequiredinteger

The routing version. Routes and rules share it, and it is the If-Match for saving either.

endpointsrequiredstring

Marks the latest endpoint change seen. Pass it back as endpoints to wait for the next one.

changedrequiredboolean

version or endpoints moved past what you passed as after and endpoints.

actorrequiredobject or null

Who made the change returned: the save behind version, or else the latest endpoint change. Null when nothing changed.

actor.typerequiredstring

member is a person in the dashboard, api_key an API key, mcp an MCP client (or a temporary token it made).

actor.namerequiredstring or null

The member’s name, the API key’s name or the MCP client and its profile label; null when it is gone. Never an email address.

actor.selfrequiredboolean

The credential making this request made the change (another tab, say).

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.