create_routing_rule
const url = 'https://example.com/api/v1/routing-rules';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"channel_ids":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"],"group_ids":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"],"hold":true,"join":"or","name":"example","severity":"example","tag_match":"any","tags":["example"],"when":{"days":[1],"end_minute":1,"mode":"always","start_minute":1},"when_closed":"next_rule"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/routing-rules \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "channel_ids": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "group_ids": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "hold": true, "join": "or", "name": "example", "severity": "example", "tag_match": "any", "tags": [ "example" ], "when": { "days": [ 1 ], "end_minute": 1, "mode": "always", "start_minute": 1 }, "when_closed": "next_rule" }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Create-rule body: a name, an optional severity filter (absent = any), the folders and tags a node must be inside or carry one of (ADR-259, ADR-262), and target channels. Editing a rule takes the same body (ADR-193).
object
Only alerts on a node inside one of these folders, at any depth, reach the rule’s channels
(ADR-262). Both this and tags empty = every node. Omitted on an edit, the rule keeps the
folders it has.
The rule sends nowhere: while it is the first open rule that matches an alert, the alert is
held until another rule decides (ADR-262). channel_ids is then not read. Omitted on a
create = false; omitted on an edit, the rule keeps its own.
The lowest severity the rule takes: unreachable, critical, warning or info; it takes
that one and every one above it (ADR-277). Absent or null = every alert. info also takes
every alert, so it is stored as null and read back as null.
Only alerts on a node carrying at least one of these (or every one, by tag_match) among
its effective labels (its own plus its folders’, minus the ones it refuses) reach the rule’s
channels. Empty = every node. Compared exactly, case included. Omitted on an edit, the rule keeps the tags it has —
a client that predates the field must not widen a rule by saving it.
When the rule is open (ADR-262): always, or during / outside a weekly window read in
the node’s own zone. A window needs at least one ISO weekday (1 = Monday .. 7 = Sunday);
minutes are after local midnight, below 1440. Omitted on an edit, the rule keeps its own.
object
Whether a routing rule is open always, only inside its window, or only outside it (ADR-262 decision 3).
What the rule does while its when hours are closed (ADR-266): next_rule passes the
alert on to the rules below and the catch-all, hold keeps it back until a rule that sends
opens. A rule that is always open never reads it. Omitted on a create = next_rule; omitted
on an edit, the rule keeps its own.
Responses
Section titled “Responses”Rule created
The id of a freshly created resource — the whole body of a 201.
Deliberately one shape for every creator. The json!({"id": …}) literal it replaces was written
out per handler, which is how {"id": …} and {"node_id": …} both ended up in this API for the
same idea; a client then needs to know which creator it called to read the id back.
object
Examplegenerated
{ "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}Empty name, a severity outside unreachable|critical|warning|info|null, a tag that is empty, too long or holds a control character, or a when window with no weekday in 1..7 or a minute outside 0..1439
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}No valid bearer token
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}Role lacks ManageSystem
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}This core has no write side (skeleton mode)
The ADR-019 envelope every failure renders as. pub(crate) and schema-bearing so the OpenAPI
document can name one error shape for every endpoint (ADR-035) instead of leaving 4xx/5xx bodies
undescribed — a client that has to guess the failure shape ends up parsing the success shape and
reading undefined.
object
object
Stable machine-readable code. Clients branch on this, never on the message.
Operator-facing sentence. Safe to display; never carries an internal error’s own text.
Examplegenerated
{ "error": { "code": "example", "message": "example" }}