Read or wait for the rules version
/v1/rules/versionRead 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 nullThe version you have. The call waits until the version differs from it.
endpointsquery · stringThe endpoints marker from the last response: also wait for an endpoint to be created, changed or deleted.
waitquery · integer or nullSeconds to wait for a change (0–25). Ignored without after or endpoints.
Responses
200Success
RuleVersionversionrequiredintegerThe routing version. Routes and rules share it, and it is the If-Match for saving either.
endpointsrequiredstringMarks the latest endpoint change seen. Pass it back as endpoints to wait for the next one.
changedrequiredbooleanversion or endpoints moved past what you passed as after and endpoints.
actorrequiredobject or nullWho made the change returned: the save behind version, or else the latest endpoint change. Null when nothing changed.
actor.typerequiredstringmember is a person in the dashboard, api_key an API key, mcp an MCP client (or a temporary token it made).
actor.namerequiredstring or nullThe 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.selfrequiredbooleanThe 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.
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.