Rules
The Rules routes of Amiril's HTTP API that an OAuth access token can call, with their parameters, request bodies and responses.
Newest first, archived rules only with archived=include, each with its mode in the session's environment and in every live environment, with the bundle installations in the session's environment sync now.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
archived?"include""include"The workspace's rules
application/json- response
rules*array<>bundle*|The bundle installations in the session's environment sync now; null when nothing was ever published there
curl -X GET 'https://api.amiril.ai/api/rules'{ "rules": [ { "id": "string", "name": "string", "description": "string", "mode": "off", "modes": [ { "environment": "string", "mode": "off" } ], "failMode": "open", "appliesTo": { "agents": [ "string" ], "tools": [ "string" ] }, "latestVersion": 0, "publishedVersion": 0, "publishedAt": "string", "createdBy": "string", "createdAt": "string", "updatedAt": "string", "archivedAt": "string", "warnings": [ { "code": "agent_unresolved", "agent": "string", "message": "string" } ], "liveSince": { "bundleVersion": "string", "at": "string" }, "shown": { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string" } } ], "bundle": { "version": "string", "etag": "string" }}Stores the rule as version 1, a draft: installations do not see it until it is published. text spells the whole rule; rule carries what the text does not spell. Its id is the one given, else the text's @id, else a slug of its name made unique in the workspace. A mode given applies in the session's environment; every other environment starts in shadow. Saved fromDraft, the draft is linked to the rule, which answers the suggestion it made, and the first version's change note says where it came from.
Needs a full access token. A read-only token is refused.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
application/json- body
id?stringThe text's @id when omitted, else derived from the name
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64name*string1 <= length <= 200description?|nullrule?Defaults to {} when text is given; one of rule and text is required
text?stringThe whole rule in the rule language (grammar in GET /api/schema): its id, the agents and tools its head names, when it is checked, its action, scope, sentences and condition. Replaces every key of rule the text spells; rule then carries only what the text does not spell: description, if_missing, on_error
length <= 8000mode?stringThe mode in the session's environment; defaults to shadow, which every other environment starts in
"off""shadow""enforce"failMode?stringDefaults to open
"open""closed"changeNote?|nullfromDraft?stringThe rule draft it was saved from, so the draft's issue shows the rule once it is published
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidThe new rule
application/json- response
rule*versions*array<>Newest first
document*The latest version as the bundle would carry it with the current settings, agents as the names they send
agents*Since when the rule has had the agents it has now. Counts and backtests from before sinceVersion were for other agents
curl -X POST 'https://api.amiril.ai/api/rules' \ -H 'Content-Type: application/json' \ -d '{ "name": "string"}'{ "rule": { "id": "string", "name": "string", "description": "string", "mode": "off", "modes": [ { "environment": "string", "mode": "off" } ], "failMode": "open", "appliesTo": { "agents": [ "string" ], "tools": [ "string" ] }, "latestVersion": 0, "publishedVersion": 0, "publishedAt": "string", "createdBy": "string", "createdAt": "string", "updatedAt": "string", "archivedAt": "string", "warnings": [ { "code": "agent_unresolved", "agent": "string", "message": "string" } ], "liveSince": { "bundleVersion": "string", "at": "string" }, "shown": { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string" } }, "versions": [ { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string", "author": "string", "changeNote": "string", "createdAt": "string", "publishedAt": "string" } ], "document": { "property1": null, "property2": null }, "agents": { "sinceVersion": 0, "gained": { "names": [ "string" ], "everyOther": true } }}Loads the rule with the given settings through the SDK's own engine and returns every problem it reports, with the rule as the bundle would carry it.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
application/json- body
rule*One rule of an amiril.rules/1 document, head (target, agents) included. An id names the rule and is not stored; version, mode and fail_mode come from the rule's settings and are removed if present
text?stringThe whole rule in the rule language (grammar in GET /api/schema): its id, the agents and tools its head names, when it is checked, its action, scope, sentences and condition. Replaces every key of rule the text spells; rule then carries only what the text does not spell: description, if_missing, on_error
length <= 8000mode?stringoff: not evaluated. shadow: evaluated and recorded, never acts. enforce: its decision takes effect
"off""shadow""enforce"failMode?stringWhat happens to a call the rule targets when the SDK faults before deciding: closed stops it. Applies only while the rule enforces
"open""closed"Problems, empty when the rule loads
application/json- response
problems*array<>Empty when the SDK loads the rule
warnings*array<>What loads but may not do what was meant; never stops a save
document*The rule as the bundle would carry it
curl -X POST 'https://api.amiril.ai/api/rules/validate' \ -H 'Content-Type: application/json' \ -d '{ "rule": { "property1": null, "property2": null }}'{ "problems": [ { "path": "string", "code": "string", "message": "string" } ], "warnings": [ { "path": "string", "code": "matches_partial_anchor", "message": "string" } ], "document": { "property1": null, "property2": null }}The sentences the SDK's engine renders for the rule: the decision sentence, the text the model is handed when the call is stopped, and what a reviewer reads. With a sample call, the decision the rule takes on it.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
application/json- body
rule*One rule of an amiril.rules/1 document, head (target, agents) included. An id names the rule and is not stored; version, mode and fail_mode come from the rule's settings and are removed if present
text?stringThe whole rule in the rule language (grammar in GET /api/schema): its id, the agents and tools its head names, when it is checked, its action, scope, sentences and condition. Replaces every key of rule the text spells; rule then carries only what the text does not spell: description, if_missing, on_error
length <= 8000mode?stringoff: not evaluated. shadow: evaluated and recorded, never acts. enforce: its decision takes effect
"off""shadow""enforce"failMode?stringWhat happens to a call the rule targets when the SDK faults before deciding: closed stops it. Applies only while the rule enforces
"open""closed"ruleId?stringThe rule being edited, so the model's text names it as installations will
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64call?|A sample call to decide; without one the sentences show ? for every value the rule reads
The rendered sentences
application/json- response
template*decision*|The decision on the sample call; null without one, when the rule does not target it, or when unsupported is not empty
unsupported*array<string>Capabilities the rule needs that Amiril's own evaluator lacks, so the sample call was not decided; empty when it was
curl -X POST 'https://api.amiril.ai/api/rules/preview' \ -H 'Content-Type: application/json' \ -d '{ "rule": { "property1": null, "property2": null }}'{ "template": { "fail": "string", "pass": "string", "model": [ { "when": "blocked", "text": "string" } ], "reviewer": { "action": "string", "outcome": "string", "body": "string", "details": [ "string" ] } }, "decision": { "action": "string", "outcome": "string", "sentence": "string", "model": [ { "when": "blocked", "text": "string" } ], "reviewer": { "action": "string", "outcome": "string", "body": "string", "details": [ "string" ] } }, "unsupported": [ "string" ]}Makes each rule's latest version the one installations run in every environment (every rule with a draft, or the ones named), after the SDK's engine loads each, and writes each environment's new bundle version. Returns the session's environment's bundle. Recorded in the workspace activity log.
Needs a full access token. A read-only token is refused.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
application/json- body
ruleIds?array<>Publish only these rules; every rule with a draft when omitted
1 <= items <= 500What was published and the bundle now served
application/json- response
published*array<>bundle*|nullcurl -X POST 'https://api.amiril.ai/api/rules/publish' \ -H 'Content-Type: application/json' \ -d '{}'{ "published": [ { "ruleId": "string", "version": 0 } ], "bundle": { "version": "string", "etag": "string" }}The rule with every version, newest first, and its mode in the session's environment and in every live environment.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*stringThe rule's id: a slug, which the model reads when the rule stops a call
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64The rule
application/json- response
rule*versions*array<>Newest first
document*The latest version as the bundle would carry it with the current settings, agents as the names they send
agents*Since when the rule has had the agents it has now. Counts and backtests from before sinceVersion were for other agents
curl -X GET 'https://api.amiril.ai/api/rules/string'{ "rule": { "id": "string", "name": "string", "description": "string", "mode": "off", "modes": [ { "environment": "string", "mode": "off" } ], "failMode": "open", "appliesTo": { "agents": [ "string" ], "tools": [ "string" ] }, "latestVersion": 0, "publishedVersion": 0, "publishedAt": "string", "createdBy": "string", "createdAt": "string", "updatedAt": "string", "archivedAt": "string", "warnings": [ { "code": "agent_unresolved", "agent": "string", "message": "string" } ], "liveSince": { "bundleVersion": "string", "at": "string" }, "shown": { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string" } }, "versions": [ { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string", "author": "string", "changeNote": "string", "createdAt": "string", "publishedAt": "string" } ], "document": { "property1": null, "property2": null }, "agents": { "sinceVersion": 0, "gained": { "names": [ "string" ], "everyOther": true } }}A new rule or text is stored as the next draft version. Mode and fail mode take effect at once on a published rule, and each change is recorded in the workspace activity log. The mode changes in the session's environment only, moving its bundle version; the other settings move every environment's. A new id is accepted only before the rule is first published. A new version that changes the agents in the head is refused with 409, whose body says what changes: new_version (at least one agent stays) or replace (no agent stays). Sending agentChange with that kind confirms it; on replace the returned rule is a new one, with a new id, and this one is archived with its history. Either way a backtest of the saved version starts. Unknown fields are refused.
Needs a full access token. A read-only token is refused.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*stringThe rule's id: a slug, which the model reads when the rule stops a call
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64application/json- body
id?stringA new id; only before the rule is first published
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64name?string1 <= length <= 200description?|nullrule?A new draft version; installations keep the published one until the next publish
text?stringThe whole rule as rule text: a new draft version over rule, or over the latest version when rule is omitted
length <= 8000changeNote?|nullmode?stringThe mode in the session's environment
"off""shadow""enforce"failMode?stringWhat happens to a call the rule targets when the SDK faults before deciding: closed stops it. Applies only while the rule enforces
"open""closed"agentChange?stringConfirms a new version that changes the agents in the head: the kind the 409 refusal of the same save named. Without it, or with another kind, the save is refused with 409
"new_version""replace"The rule
application/json- response
rule*versions*array<>Newest first
document*The latest version as the bundle would carry it with the current settings, agents as the names they send
agents*Since when the rule has had the agents it has now. Counts and backtests from before sinceVersion were for other agents
curl -X PATCH 'https://api.amiril.ai/api/rules/string' \ -H 'Content-Type: application/json' \ -d '{}'{ "rule": { "id": "string", "name": "string", "description": "string", "mode": "off", "modes": [ { "environment": "string", "mode": "off" } ], "failMode": "open", "appliesTo": { "agents": [ "string" ], "tools": [ "string" ] }, "latestVersion": 0, "publishedVersion": 0, "publishedAt": "string", "createdBy": "string", "createdAt": "string", "updatedAt": "string", "archivedAt": "string", "warnings": [ { "code": "agent_unresolved", "agent": "string", "message": "string" } ], "liveSince": { "bundleVersion": "string", "at": "string" }, "shown": { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string" } }, "versions": [ { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string", "author": "string", "changeNote": "string", "createdAt": "string", "publishedAt": "string" } ], "document": { "property1": null, "property2": null }, "agents": { "sinceVersion": 0, "gained": { "names": [ "string" ], "everyOther": true } }}The issues in the session's environment the rule was drafted for, each with its runs since the rule began enforcing there (null while it does not enforce). Empty for a rule nobody drafted from an issue.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*stringThe rule's id: a slug, which the model reads when the rule stops a call
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64The issues
application/json- response
issues*array<>curl -X GET 'https://api.amiril.ai/api/rules/string/issues'{ "issues": [ { "id": "string", "label": "string", "title": "string", "detector": "grounding", "subject": "string", "state": "open", "severity": "critical", "newRuns": 0 } ]}Changes the mode in the session's environment only. Takes effect at once on a published rule, moving that environment's bundle version. Recorded in the workspace activity log with the environment.
Needs a full access token. A read-only token is refused.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*stringThe rule's id: a slug, which the model reads when the rule stops a call
^[a-z0-9]+(-[a-z0-9]+)*$length <= 64application/json- body
mode*stringoff: not evaluated. shadow: evaluated and recorded, never acts. enforce: its decision takes effect
"off""shadow""enforce"The rule
application/json- response
rule*versions*array<>Newest first
document*The latest version as the bundle would carry it with the current settings, agents as the names they send
agents*Since when the rule has had the agents it has now. Counts and backtests from before sinceVersion were for other agents
curl -X POST 'https://api.amiril.ai/api/rules/string/mode' \ -H 'Content-Type: application/json' \ -d '{ "mode": "off"}'{ "rule": { "id": "string", "name": "string", "description": "string", "mode": "off", "modes": [ { "environment": "string", "mode": "off" } ], "failMode": "open", "appliesTo": { "agents": [ "string" ], "tools": [ "string" ] }, "latestVersion": 0, "publishedVersion": 0, "publishedAt": "string", "createdBy": "string", "createdAt": "string", "updatedAt": "string", "archivedAt": "string", "warnings": [ { "code": "agent_unresolved", "agent": "string", "message": "string" } ], "liveSince": { "bundleVersion": "string", "at": "string" }, "shown": { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string" } }, "versions": [ { "version": 0, "rule": { "property1": null, "property2": null }, "text": "string", "author": "string", "changeNote": "string", "createdAt": "string", "publishedAt": "string" } ], "document": { "property1": null, "property2": null }, "agents": { "sinceVersion": 0, "gained": { "names": [ "string" ], "everyOther": true } }}The stored backtest of the rule version over the window (24h, 7d or 30d; default 7d): how many past calls it would have fired on, the newest matched calls with links to their runs and the decision sentence for each, the counts per agent, and whether the result still matches the rule's current settings. Status none when never requested. A publish recomputes the default window for the versions it carries.
Any access token can call this, read-only or full.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*string1 <= length <= 256version*integer1 <= value <= 9007199254740991window?string"24h""7d""30d"The result, or status none
application/json- response
ruleId*stringruleVersion*numberwindow*string"24h""7d""30d"status*stringnone: never requested
"none""queued""running""done""failed"current*|Whether the stored result was computed from the rule as it stands now (its settings, and the names its agents are seen under); null with no result
requestedAt*string|nullstartedAt*string|nullfinishedAt*string|nullwindowFrom*string|nullwindowTo*string|nullrunsScanned*number|nullcallsScanned*number|nullfired*|Past calls the rule would have fired on (any action but allow)
errors*|Past calls on which its evaluation errored
notEvaluable*|Past calls whose arguments arrived truncated, which a rule reading arguments cannot be evaluated on: neither fired nor passed
truncated*booleanThe cost ceiling stopped the scan at coveredTo
coveredTo*string|nullhistory*|nullmatched*array<>The newest matched calls, capped; fired is the count
byAgent*array<>The counts per agent, by the name its calls carried: every agent with a replayed call, sorted by name
error*string|nullcaveats*array<>What a replay of stored spans cannot reproduce, to state beside the numbers
curl -X GET 'https://api.amiril.ai/api/backtests/string/1'{ "ruleId": "string", "ruleVersion": 0, "window": "24h", "status": "none", "current": true, "requestedAt": "string", "startedAt": "string", "finishedAt": "string", "windowFrom": "string", "windowTo": "string", "runsScanned": 0, "callsScanned": 0, "fired": 0, "errors": 0, "notEvaluable": 0, "truncated": true, "coveredTo": "string", "history": { "records": 0, "runs_open": 0, "sessions": 0, "evicted_runs": 0, "evicted_sessions": 0, "evicted_records_by_age": 0, "evicted_records_by_size": 0, "over_limit_events": 0 }, "matched": [ { "runId": "string", "spanId": "string", "link": "string", "tool": "string", "agent": "string", "sessionId": "string", "at": "string", "phase": "pre", "action": "allow", "outcome": "string", "sentence": "string" } ], "byAgent": [ { "agent": "string", "callsScanned": 0, "fired": 0, "errors": 0, "notEvaluable": 0 } ], "error": "string", "caveats": [ { "code": "string", "text": "string" } ]}Queues the backtest of the rule version over the window (default 7d), replacing the stored result when it finishes. Any version can be backtested, drafts included. Poll the read for the result.
Needs a full access token. A read-only token is refused.
accessTokenAuthorizationBearer <JWT>An OAuth access token from Amiril's authorization server, the kind an MCP client gets when it connects.
ruleId*string1 <= length <= 256version*integer1 <= value <= 9007199254740991application/json- body
window?string"24h""7d""30d"Queued
application/json- response
ruleId*stringruleVersion*numberwindow*string"24h""7d""30d"status*stringnone: never requested
"none""queued""running""done""failed"current*|Whether the stored result was computed from the rule as it stands now (its settings, and the names its agents are seen under); null with no result
requestedAt*string|nullstartedAt*string|nullfinishedAt*string|nullwindowFrom*string|nullwindowTo*string|nullrunsScanned*number|nullcallsScanned*number|nullfired*|Past calls the rule would have fired on (any action but allow)
errors*|Past calls on which its evaluation errored
notEvaluable*|Past calls whose arguments arrived truncated, which a rule reading arguments cannot be evaluated on: neither fired nor passed
truncated*booleanThe cost ceiling stopped the scan at coveredTo
coveredTo*string|nullhistory*|nullmatched*array<>The newest matched calls, capped; fired is the count
byAgent*array<>The counts per agent, by the name its calls carried: every agent with a replayed call, sorted by name
error*string|nullcaveats*array<>What a replay of stored spans cannot reproduce, to state beside the numbers
curl -X POST 'https://api.amiril.ai/api/backtests/string/1' \ -H 'Content-Type: application/json' \ -d '{}'{ "ruleId": "string", "ruleVersion": 0, "window": "24h", "status": "none", "current": true, "requestedAt": "string", "startedAt": "string", "finishedAt": "string", "windowFrom": "string", "windowTo": "string", "runsScanned": 0, "callsScanned": 0, "fired": 0, "errors": 0, "notEvaluable": 0, "truncated": true, "coveredTo": "string", "history": { "records": 0, "runs_open": 0, "sessions": 0, "evicted_runs": 0, "evicted_sessions": 0, "evicted_records_by_age": 0, "evicted_records_by_size": 0, "over_limit_events": 0 }, "matched": [ { "runId": "string", "spanId": "string", "link": "string", "tool": "string", "agent": "string", "sessionId": "string", "at": "string", "phase": "pre", "action": "allow", "outcome": "string", "sentence": "string" } ], "byAgent": [ { "agent": "string", "callsScanned": 0, "fired": 0, "errors": 0, "notEvaluable": 0 } ], "error": "string", "caveats": [ { "code": "string", "text": "string" } ]}