K8 HQ

Rules — K8 HQ Content API

Rules operations for K8 HQ Content API. Requests, permissions and responses.

Version 1OpenAPI description (JSON)

Browse operation groups

Before making requests, read the authentication and request requirements.

Automate what happens to mail: create, test and manage rules, and start from templates.

Base URL

Base URLFor
https://api.k8hq.com/v1API tokens and the K8 HQ web app

Endpoints

Rules

List rule actions

GET/rule-actions

The actions your templates may use, with their fields, the permission each needs in a rule's ceiling and any daily cap. K8 HQ's own built-in actions (such as reading DMARC reports) appear only inside its starter templates, which you can install.

For API tokens with rules:read and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Response body (JSON)

FieldTypeDescription
actions requiredRuleActionType[]

Responses

StatusBodyMeaning
200JSONThe actions.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

List starter templates

GET/rule-templates

K8 HQ's own templates (reading DMARC reports, alerting on DMARC failures, moving spam to Spam). Install one with POST /rules: its template and a value for each parameter.

For API tokens with rules:read and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Response body (JSON)

FieldTypeDescription
templates requiredobject[]

Responses

StatusBodyMeaning
200JSONThe starters.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

List rules

GET/rules

The organization's rules, oldest first. Owners and admins see every rule; others see the rules acting on a container they can use.

For API tokens with rules:read and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Response body (JSON)

FieldTypeDescription
rules requiredRule[]

Responses

StatusBodyMeaning
200JSONThe rules.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Create a rule

POST/rules

Installs a template with parameter values. The rule gets its own agent and a frozen ceiling: exactly its actions, on the inboxes you may use now (your grant and your token's containers). It acts on events after it's created. Creating a rule requires permission to edit every inbox it acts on. Members can't create rules for an inbox where an owner or admin turned rules by members off (403). A rule that sends mail (reply) needs a person who used their passkey in the last 5 minutes (401 step_up_required); tokens can't create one. Rules belong to the organization. K8 HQ can pause a rule when its sponsor loses permission to edit an inbox it acts on. Needs a passkey confirmation of exactly this change (x-k8hq-confirm: rule.sending, design note 0013): send x-k8hq-confirm with it.

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
activeFromstringWhen the rule starts acting (RFC 3339 with an offset, e.g. 2026-10-19T09:00:00-07:00); empty for now. On a change, leave it out to keep it, or send "" to clear it.
activeUntilstringWhen the rule stops acting (RFC 3339), after activeFrom; empty for no end. Outside the window the rule stays as it is and lets events pass. On a change, leave it out to keep it, or send "" to clear it.
aiClassifyDailyCapintegerClassifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit.
aiClassifyPreviewbooleanTests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage.
aiSendingOptInbooleanAn owner requests bound passkey confirmation to let this AI rule send replies. With status active and no edits, one confirmation of the current version saves the agreement and resumes the paused rule together. False clears that agreement.
cursorstringTests only: a previous test's nextCursor, to test the rest of the window.
dailyCapintegerThe rule's safety breaker: past this many actions in a UTC day it pauses itself and its notice inbox (else its watched inbox) is told. Default 10,000; up to 10,000,000; -1 for no limit (nothing is counted: for rules meant to run at any volume). A test suggests one from real volume (suggestedCap).
limitintegerTests only: matches to list (all are counted; default 100).
paramsobjectA value for every template parameter.
sincestringTests only: start of the window (default 7 days ago).
statusactive | pausedChanges only.
templateTemplate
untilstringTests only: end of the window (default now).
{"params":{"watch":"ibx_01M4M2Y0M4T5157C6VTMHGSEMY"},"template":{"actions":[{"kind":"move","label":"archive"},{"add":["seen"],"kind":"flag"}],"filter":"message.from.exists(a, a.endsWith(\"@news.example.com\"))","name":"File newsletters","parameters":[{"kind":"inbox","name":"watch"}],"templateVersion":1,"triggers":[{"type":"message.received"}]}}

Response body (JSON)

FieldTypeDescription
agentId requiredstringThe agent it acts as (agt_…): the actor of every event it causes.
ceiling requiredstringThe agent's frozen permissions, as Cedar policies.
containers requiredstring[]The containers its ceiling covers.
createdAt requiredstringIt acts on events after this, never on history.
creator requiredstringThe member who created it (mem_…).
dailyCap requiredintegerActions a day before the rule pauses itself; -1: no limit.
id requiredstringrul_…
params requiredobject
status requiredactive | paused
summary requiredstringWhat it does, in plain words.
template requiredTemplate
updatedAt requiredstring
version requiredinteger
activeFromstringWhen the rule starts acting (UTC), if set.
activeUntilstringWhen the rule stops acting (UTC), if set.
aiClassifyDailyCapinteger
aiSendingOptInobject | null
createdAttributionAttribution
phaseactive | paused | scheduled | endedHow the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed).
updatedAttributionAttribution

Responses

StatusBodyMeaning
201RuleCreated.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonSign in required (unauthenticated), or confirm this change with your passkey (confirmation_required, or step_up_required with action until confirmations are enforced): the answer carries the action to confirm.
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonNot allowed (forbidden); or the confirmation isn't this session's (confirmation_invalid), or an API token or assistant asked (needs_person).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe confirmation is for a different change, or what it changes is different now (confirmation_mismatch), was already used (confirmation_used) or timed out (confirmation_expired).
422application/problem+jsonThe template or parameters aren't valid (rejected): the detail says what.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Test a rule against history

POST/rules/test

Replays the organization's events in a window (default the last 7 days) through the rule's triggers, inboxes and filter, and lists what it would have done with each match. Nothing is changed. What arrived is as received and labels and flags are as they were after each event; actions that read content are listed, not run; events it would emit aren't passed to other rules. Each event evaluated is metered (rules.evaluations).

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Request body (JSON)

FieldTypeDescription
activeFromstringWhen the rule starts acting (RFC 3339 with an offset, e.g. 2026-10-19T09:00:00-07:00); empty for now. On a change, leave it out to keep it, or send "" to clear it.
activeUntilstringWhen the rule stops acting (RFC 3339), after activeFrom; empty for no end. Outside the window the rule stays as it is and lets events pass. On a change, leave it out to keep it, or send "" to clear it.
aiClassifyDailyCapintegerClassifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit.
aiClassifyPreviewbooleanTests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage.
aiSendingOptInbooleanAn owner requests bound passkey confirmation to let this AI rule send replies. With status active and no edits, one confirmation of the current version saves the agreement and resumes the paused rule together. False clears that agreement.
cursorstringTests only: a previous test's nextCursor, to test the rest of the window.
dailyCapintegerThe rule's safety breaker: past this many actions in a UTC day it pauses itself and its notice inbox (else its watched inbox) is told. Default 10,000; up to 10,000,000; -1 for no limit (nothing is counted: for rules meant to run at any volume). A test suggests one from real volume (suggestedCap).
limitintegerTests only: matches to list (all are counted; default 100).
paramsobjectA value for every template parameter.
sincestringTests only: start of the window (default 7 days ago).
statusactive | pausedChanges only.
templateTemplate
untilstringTests only: end of the window (default now).

Response body (JSON)

FieldTypeDescription
capped requiredintegerActions the rule's daily limit would have refused (it would have paused itself).
evaluated requiredintegerEvents the rule selected and its filter checked (metered as rules.evaluations).
failed requiredobjectEvents a live run would have recorded as rule.action.failed, by reason (denied, filter_error, invalid, depth).
matched requiredinteger
matches requiredobject[]
notes requiredstring[]What a test can't show.
perDay requiredobjectMatches per UTC day.
scanned requiredintegerEvents read (up to 2000 per call; metered as events.read).
suggestedCap requiredintegerA daily limit with room above the peak day: three times its actions, at least 100.
unknown requiredintegerSelected events whose message is gone.
window requiredobject
aiClassifyobject
horizonstringThe organization's earliest event a test can see.
nextCursorstringMore of the window to test: pass it as cursor.
peakDaystring

Responses

StatusBodyMeaning
200RuleTestThe test.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
422application/problem+jsonThe template or parameters aren't valid (rejected).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Check a rule

POST/rules/validate

Checks a template and parameter values as creating it would, without saving, and describes it in plain words.

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Request body (JSON)

FieldTypeDescription
activeFromstringWhen the rule starts acting (RFC 3339 with an offset, e.g. 2026-10-19T09:00:00-07:00); empty for now. On a change, leave it out to keep it, or send "" to clear it.
activeUntilstringWhen the rule stops acting (RFC 3339), after activeFrom; empty for no end. Outside the window the rule stays as it is and lets events pass. On a change, leave it out to keep it, or send "" to clear it.
aiClassifyDailyCapintegerClassifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit.
aiClassifyPreviewbooleanTests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage.
aiSendingOptInbooleanAn owner requests bound passkey confirmation to let this AI rule send replies. With status active and no edits, one confirmation of the current version saves the agreement and resumes the paused rule together. False clears that agreement.
cursorstringTests only: a previous test's nextCursor, to test the rest of the window.
dailyCapintegerThe rule's safety breaker: past this many actions in a UTC day it pauses itself and its notice inbox (else its watched inbox) is told. Default 10,000; up to 10,000,000; -1 for no limit (nothing is counted: for rules meant to run at any volume). A test suggests one from real volume (suggestedCap).
limitintegerTests only: matches to list (all are counted; default 100).
paramsobjectA value for every template parameter.
sincestringTests only: start of the window (default 7 days ago).
statusactive | pausedChanges only.
templateTemplate
untilstringTests only: end of the window (default now).
{"params":{"watch":"ibx_01M4M2Y0M4T5157C6VTMHGSEMY"},"template":{"actions":[{"kind":"move","label":"archive"},{"add":["seen"],"kind":"flag"}],"filter":"message.from.exists(a, a.endsWith(\"@news.example.com\"))","name":"File newsletters","parameters":[{"kind":"inbox","name":"watch"}],"templateVersion":1,"triggers":[{"type":"message.received"}]}}

Response body (JSON)

FieldTypeDescription
containers requiredstring[]
summary requiredstring
valid requiredtrue
activeFromstringThe rule's active window as it would be saved (UTC), if set.
activeUntilstringThe rule's active window as it would be saved (UTC), if set.
ruleSummarystringThe summary without the rule's name or active window, for showing the name separately and the window in the person's own time.

Responses

StatusBodyMeaning
200JSONValid.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
422application/problem+jsonNot valid (rejected): the detail says what.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Get a rule

GET/rules/{rule}

For API tokens with rules:read and the web app.

Parameters

NameTypeDescription
rule (path) requiredstringRule ID (rul_…).
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Response body (JSON)

FieldTypeDescription
agentId requiredstringThe agent it acts as (agt_…): the actor of every event it causes.
ceiling requiredstringThe agent's frozen permissions, as Cedar policies.
containers requiredstring[]The containers its ceiling covers.
createdAt requiredstringIt acts on events after this, never on history.
creator requiredstringThe member who created it (mem_…).
dailyCap requiredintegerActions a day before the rule pauses itself; -1: no limit.
id requiredstringrul_…
params requiredobject
status requiredactive | paused
summary requiredstringWhat it does, in plain words.
template requiredTemplate
updatedAt requiredstring
version requiredinteger
activeFromstringWhen the rule starts acting (UTC), if set.
activeUntilstringWhen the rule stops acting (UTC), if set.
aiClassifyDailyCapinteger
aiSendingOptInobject | null
createdAttributionAttribution
phaseactive | paused | scheduled | endedHow the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed).
updatedAttributionAttribution

Responses

StatusBodyMeaning
200RuleThe rule.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Change a rule

PATCH/rules/{rule}

Replaces its template and/or parameter values (the ceiling is frozen again within your current access) and/or pauses or resumes it. You need permission to edit the inboxes it acts on. Someone with permission to manage all rules for the organization can pause a rule anywhere. With If-Match, only that version is changed. Needs a passkey confirmation of exactly this change (x-k8hq-confirm: rule.sending, design note 0013): send x-k8hq-confirm with it.

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
rule (path) requiredstringRule ID (rul_…).
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.
If-Match (header)stringThe ETag of the version you read.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
activeFromstringWhen the rule starts acting (RFC 3339 with an offset, e.g. 2026-10-19T09:00:00-07:00); empty for now. On a change, leave it out to keep it, or send "" to clear it.
activeUntilstringWhen the rule stops acting (RFC 3339), after activeFrom; empty for no end. Outside the window the rule stays as it is and lets events pass. On a change, leave it out to keep it, or send "" to clear it.
aiClassifyDailyCapintegerClassifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit.
aiClassifyPreviewbooleanTests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage.
aiSendingOptInbooleanAn owner requests bound passkey confirmation to let this AI rule send replies. With status active and no edits, one confirmation of the current version saves the agreement and resumes the paused rule together. False clears that agreement.
cursorstringTests only: a previous test's nextCursor, to test the rest of the window.
dailyCapintegerThe rule's safety breaker: past this many actions in a UTC day it pauses itself and its notice inbox (else its watched inbox) is told. Default 10,000; up to 10,000,000; -1 for no limit (nothing is counted: for rules meant to run at any volume). A test suggests one from real volume (suggestedCap).
limitintegerTests only: matches to list (all are counted; default 100).
paramsobjectA value for every template parameter.
sincestringTests only: start of the window (default 7 days ago).
statusactive | pausedChanges only.
templateTemplate
untilstringTests only: end of the window (default now).
{"status":"paused"}

Response body (JSON)

FieldTypeDescription
agentId requiredstringThe agent it acts as (agt_…): the actor of every event it causes.
ceiling requiredstringThe agent's frozen permissions, as Cedar policies.
containers requiredstring[]The containers its ceiling covers.
createdAt requiredstringIt acts on events after this, never on history.
creator requiredstringThe member who created it (mem_…).
dailyCap requiredintegerActions a day before the rule pauses itself; -1: no limit.
id requiredstringrul_…
params requiredobject
status requiredactive | paused
summary requiredstringWhat it does, in plain words.
template requiredTemplate
updatedAt requiredstring
version requiredinteger
activeFromstringWhen the rule starts acting (UTC), if set.
activeUntilstringWhen the rule stops acting (UTC), if set.
aiClassifyDailyCapinteger
aiSendingOptInobject | null
createdAttributionAttribution
phaseactive | paused | scheduled | endedHow the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed).
updatedAttributionAttribution

Responses

StatusBodyMeaning
200RuleThe rule after the change.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonSign in required (unauthenticated), or confirm this change with your passkey (confirmation_required, or step_up_required with action until confirmations are enforced): the answer carries the action to confirm.
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonNot allowed (forbidden); or the confirmation isn't this session's (confirmation_invalid), or an API token or assistant asked (needs_person).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe confirmation is for a different change, or what it changes is different now (confirmation_mismatch), was already used (confirmation_used) or timed out (confirmation_expired).
412application/problem+jsonIf-Match named an older version (version_mismatch).
422application/problem+jsonNot valid (rejected).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Delete a rule

DELETE/rules/{rule}

Its agent can no longer act. You need permission to edit the inboxes it acts on, or permission to manage all rules for the organization.

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
rule (path) requiredstringRule ID (rul_…).
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.
If-Match (header)stringThe ETag of the version you read.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Responses

StatusBodyMeaning
204Deleted.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonA request with this Idempotency-Key is still running (in_progress).
412application/problem+jsonIf-Match named an older version (version_mismatch).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Export a rule's template

GET/rules/{rule}/template

The template the rule was installed from, without its parameter values: install it elsewhere with POST /rules.

For API tokens with rules:read and the web app.

Parameters

NameTypeDescription
rule (path) requiredstringRule ID (rul_…).
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Response body (JSON)

FieldTypeDescription
actions requiredRuleAction[]
name requiredstring
templateVersion required1
triggers requiredobject[]
conditionsAIClassifyCondition[]
descriptionstring
filterstringA CEL expression that must be true for the rule to act, over event (type, subject, container, time, actor, data), message for message.* triggers (channel, direction, subject, participants, from, labels, flags, size, endpoints, spam, spamScore) and params. Checked when saved: every field it names must exist. Empty matches every triggering event.
parametersobject[]

Responses

StatusBodyMeaning
200TemplateThe template.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Test a saved rule against history

POST/rules/{rule}/test

Replays the organization's events in a window (default the last 7 days) through the rule's triggers, inboxes and filter, and lists what it would have done with each match. Nothing is changed. What arrived is as received and labels and flags are as they were after each event; actions that read content are listed, not run; events it would emit aren't passed to other rules. Each event evaluated is metered (rules.evaluations). The body may be empty or give the window.

For API tokens with rules:write and the web app.

Parameters

NameTypeDescription
rule (path) requiredstringRule ID (rul_…).
org (query)stringThe organization (org_). Required for a person signed in to the web app (any organization they're a member of); a token always answers for its own organization.

Request body (JSON)

FieldTypeDescription
activeFromstringWhen the rule starts acting (RFC 3339 with an offset, e.g. 2026-10-19T09:00:00-07:00); empty for now. On a change, leave it out to keep it, or send "" to clear it.
activeUntilstringWhen the rule stops acting (RFC 3339), after activeFrom; empty for no end. Outside the window the rule stays as it is and lets events pass. On a change, leave it out to keep it, or send "" to clear it.
aiClassifyDailyCapintegerClassifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit.
aiClassifyPreviewbooleanTests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage.
aiSendingOptInbooleanAn owner requests bound passkey confirmation to let this AI rule send replies. With status active and no edits, one confirmation of the current version saves the agreement and resumes the paused rule together. False clears that agreement.
cursorstringTests only: a previous test's nextCursor, to test the rest of the window.
dailyCapintegerThe rule's safety breaker: past this many actions in a UTC day it pauses itself and its notice inbox (else its watched inbox) is told. Default 10,000; up to 10,000,000; -1 for no limit (nothing is counted: for rules meant to run at any volume). A test suggests one from real volume (suggestedCap).
limitintegerTests only: matches to list (all are counted; default 100).
paramsobjectA value for every template parameter.
sincestringTests only: start of the window (default 7 days ago).
statusactive | pausedChanges only.
templateTemplate
untilstringTests only: end of the window (default now).

Response body (JSON)

FieldTypeDescription
capped requiredintegerActions the rule's daily limit would have refused (it would have paused itself).
evaluated requiredintegerEvents the rule selected and its filter checked (metered as rules.evaluations).
failed requiredobjectEvents a live run would have recorded as rule.action.failed, by reason (denied, filter_error, invalid, depth).
matched requiredinteger
matches requiredobject[]
notes requiredstring[]What a test can't show.
perDay requiredobjectMatches per UTC day.
scanned requiredintegerEvents read (up to 2000 per call; metered as events.read).
suggestedCap requiredintegerA daily limit with room above the peak day: three times its actions, at least 100.
unknown requiredintegerSelected events whose message is gone.
window requiredobject
aiClassifyobject
horizonstringThe organization's earliest event a test can see.
nextCursorstringMore of the window to test: pass it as cursor.
peakDaystring

Responses

StatusBodyMeaning
200RuleTestThe test.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
422application/problem+jsonThe template or parameters aren't valid (rejected).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).