Rules — K8 HQ Content API
Rules operations for K8 HQ Content API. Requests, permissions and responses.
Version 1OpenAPI description (JSON)
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 URL | For |
https://api.k8hq.com/v1 | API 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
| Name | Type | Description |
org (query) | string | The 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)
| Field | Type | Description |
actions required | RuleActionType[] | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The actions. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
org (query) | string | The 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)
| Field | Type | Description |
templates required | object[] | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The starters. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
org (query) | string | The 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)
| Field | Type | Description |
rules required | Rule[] | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The rules. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
org (query) | string | The 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) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
activeFrom | string | When 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. |
activeUntil | string | When 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. |
aiClassifyDailyCap | integer | Classifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit. |
aiClassifyPreview | boolean | Tests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage. |
aiSendingOptIn | boolean | An 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. |
cursor | string | Tests only: a previous test's nextCursor, to test the rest of the window. |
dailyCap | integer | The 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). |
limit | integer | Tests only: matches to list (all are counted; default 100). |
params | object | A value for every template parameter. |
since | string | Tests only: start of the window (default 7 days ago). |
status | active | paused | Changes only. |
template | Template | |
until | string | Tests 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)
| Field | Type | Description |
agentId required | string | The agent it acts as (agt_…): the actor of every event it causes. |
ceiling required | string | The agent's frozen permissions, as Cedar policies. |
containers required | string[] | The containers its ceiling covers. |
createdAt required | string | It acts on events after this, never on history. |
creator required | string | The member who created it (mem_…). |
dailyCap required | integer | Actions a day before the rule pauses itself; -1: no limit. |
id required | string | rul_… |
params required | object | |
status required | active | paused | |
summary required | string | What it does, in plain words. |
template required | Template | |
updatedAt required | string | |
version required | integer | |
activeFrom | string | When the rule starts acting (UTC), if set. |
activeUntil | string | When the rule stops acting (UTC), if set. |
aiClassifyDailyCap | integer | |
aiSendingOptIn | object | null | |
createdAttribution | Attribution | |
phase | active | paused | scheduled | ended | How the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed). |
updatedAttribution | Attribution | |
Responses
| Status | Body | Meaning |
| 201 | Rule | Created. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | Sign 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. |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | Not allowed (forbidden); or the confirmation isn't this session's (confirmation_invalid), or an API token or assistant asked (needs_person). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The 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). |
| 422 | application/problem+json | The template or parameters aren't valid (rejected): the detail says what. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
org (query) | string | The 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)
| Field | Type | Description |
activeFrom | string | When 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. |
activeUntil | string | When 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. |
aiClassifyDailyCap | integer | Classifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit. |
aiClassifyPreview | boolean | Tests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage. |
aiSendingOptIn | boolean | An 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. |
cursor | string | Tests only: a previous test's nextCursor, to test the rest of the window. |
dailyCap | integer | The 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). |
limit | integer | Tests only: matches to list (all are counted; default 100). |
params | object | A value for every template parameter. |
since | string | Tests only: start of the window (default 7 days ago). |
status | active | paused | Changes only. |
template | Template | |
until | string | Tests only: end of the window (default now). |
Response body (JSON)
| Field | Type | Description |
capped required | integer | Actions the rule's daily limit would have refused (it would have paused itself). |
evaluated required | integer | Events the rule selected and its filter checked (metered as rules.evaluations). |
failed required | object | Events a live run would have recorded as rule.action.failed, by reason (denied, filter_error, invalid, depth). |
matched required | integer | |
matches required | object[] | |
notes required | string[] | What a test can't show. |
perDay required | object | Matches per UTC day. |
scanned required | integer | Events read (up to 2000 per call; metered as events.read). |
suggestedCap required | integer | A daily limit with room above the peak day: three times its actions, at least 100. |
unknown required | integer | Selected events whose message is gone. |
window required | object | |
aiClassify | object | |
horizon | string | The organization's earliest event a test can see. |
nextCursor | string | More of the window to test: pass it as cursor. |
peakDay | string | |
Responses
| Status | Body | Meaning |
| 200 | RuleTest | The test. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 422 | application/problem+json | The template or parameters aren't valid (rejected). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
org (query) | string | The 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)
| Field | Type | Description |
activeFrom | string | When 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. |
activeUntil | string | When 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. |
aiClassifyDailyCap | integer | Classifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit. |
aiClassifyPreview | boolean | Tests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage. |
aiSendingOptIn | boolean | An 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. |
cursor | string | Tests only: a previous test's nextCursor, to test the rest of the window. |
dailyCap | integer | The 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). |
limit | integer | Tests only: matches to list (all are counted; default 100). |
params | object | A value for every template parameter. |
since | string | Tests only: start of the window (default 7 days ago). |
status | active | paused | Changes only. |
template | Template | |
until | string | Tests 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)
| Field | Type | Description |
containers required | string[] | |
summary required | string | |
valid required | true | |
activeFrom | string | The rule's active window as it would be saved (UTC), if set. |
activeUntil | string | The rule's active window as it would be saved (UTC), if set. |
ruleSummary | string | The summary without the rule's name or active window, for showing the name separately and the window in the person's own time. |
Responses
| Status | Body | Meaning |
| 200 | JSON | Valid. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 422 | application/problem+json | Not valid (rejected): the detail says what. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Get a rule
GET/rules/{rule}
For API tokens with rules:read and the web app.
Parameters
| Name | Type | Description |
rule (path) required | string | Rule ID (rul_…). |
org (query) | string | The 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)
| Field | Type | Description |
agentId required | string | The agent it acts as (agt_…): the actor of every event it causes. |
ceiling required | string | The agent's frozen permissions, as Cedar policies. |
containers required | string[] | The containers its ceiling covers. |
createdAt required | string | It acts on events after this, never on history. |
creator required | string | The member who created it (mem_…). |
dailyCap required | integer | Actions a day before the rule pauses itself; -1: no limit. |
id required | string | rul_… |
params required | object | |
status required | active | paused | |
summary required | string | What it does, in plain words. |
template required | Template | |
updatedAt required | string | |
version required | integer | |
activeFrom | string | When the rule starts acting (UTC), if set. |
activeUntil | string | When the rule stops acting (UTC), if set. |
aiClassifyDailyCap | integer | |
aiSendingOptIn | object | null | |
createdAttribution | Attribution | |
phase | active | paused | scheduled | ended | How the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed). |
updatedAttribution | Attribution | |
Responses
| Status | Body | Meaning |
| 200 | Rule | The rule. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
rule (path) required | string | Rule ID (rul_…). |
org (query) | string | The 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) | string | The ETag of the version you read. |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
activeFrom | string | When 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. |
activeUntil | string | When 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. |
aiClassifyDailyCap | integer | Classifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit. |
aiClassifyPreview | boolean | Tests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage. |
aiSendingOptIn | boolean | An 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. |
cursor | string | Tests only: a previous test's nextCursor, to test the rest of the window. |
dailyCap | integer | The 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). |
limit | integer | Tests only: matches to list (all are counted; default 100). |
params | object | A value for every template parameter. |
since | string | Tests only: start of the window (default 7 days ago). |
status | active | paused | Changes only. |
template | Template | |
until | string | Tests only: end of the window (default now). |
{"status":"paused"}
Response body (JSON)
| Field | Type | Description |
agentId required | string | The agent it acts as (agt_…): the actor of every event it causes. |
ceiling required | string | The agent's frozen permissions, as Cedar policies. |
containers required | string[] | The containers its ceiling covers. |
createdAt required | string | It acts on events after this, never on history. |
creator required | string | The member who created it (mem_…). |
dailyCap required | integer | Actions a day before the rule pauses itself; -1: no limit. |
id required | string | rul_… |
params required | object | |
status required | active | paused | |
summary required | string | What it does, in plain words. |
template required | Template | |
updatedAt required | string | |
version required | integer | |
activeFrom | string | When the rule starts acting (UTC), if set. |
activeUntil | string | When the rule stops acting (UTC), if set. |
aiClassifyDailyCap | integer | |
aiSendingOptIn | object | null | |
createdAttribution | Attribution | |
phase | active | paused | scheduled | ended | How the rule stands now: active, paused, scheduled (its window hasn't started) or ended (its window has passed). |
updatedAttribution | Attribution | |
Responses
| Status | Body | Meaning |
| 200 | Rule | The rule after the change. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | Sign 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. |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | Not allowed (forbidden); or the confirmation isn't this session's (confirmation_invalid), or an API token or assistant asked (needs_person). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The 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). |
| 412 | application/problem+json | If-Match named an older version (version_mismatch). |
| 422 | application/problem+json | Not valid (rejected). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
rule (path) required | string | Rule ID (rul_…). |
org (query) | string | The 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) | string | The ETag of the version you read. |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Responses
| Status | Body | Meaning |
| 204 | | Deleted. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | A request with this Idempotency-Key is still running (in_progress). |
| 412 | application/problem+json | If-Match named an older version (version_mismatch). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
rule (path) required | string | Rule ID (rul_…). |
org (query) | string | The 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)
| Field | Type | Description |
actions required | RuleAction[] | |
name required | string | |
templateVersion required | 1 | |
triggers required | object[] | |
conditions | AIClassifyCondition[] | |
description | string | |
filter | string | A 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. |
parameters | object[] | |
Responses
| Status | Body | Meaning |
| 200 | Template | The template. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
rule (path) required | string | Rule ID (rul_…). |
org (query) | string | The 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)
| Field | Type | Description |
activeFrom | string | When 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. |
activeUntil | string | When 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. |
aiClassifyDailyCap | integer | Classifications per UTC day. Zero uses 200 on create or keeps the saved limit on edit. |
aiClassifyPreview | boolean | Tests only. A person explicitly asks for an AI label distribution. Uses AI and counts toward K8 usage. |
aiSendingOptIn | boolean | An 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. |
cursor | string | Tests only: a previous test's nextCursor, to test the rest of the window. |
dailyCap | integer | The 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). |
limit | integer | Tests only: matches to list (all are counted; default 100). |
params | object | A value for every template parameter. |
since | string | Tests only: start of the window (default 7 days ago). |
status | active | paused | Changes only. |
template | Template | |
until | string | Tests only: end of the window (default now). |
Response body (JSON)
| Field | Type | Description |
capped required | integer | Actions the rule's daily limit would have refused (it would have paused itself). |
evaluated required | integer | Events the rule selected and its filter checked (metered as rules.evaluations). |
failed required | object | Events a live run would have recorded as rule.action.failed, by reason (denied, filter_error, invalid, depth). |
matched required | integer | |
matches required | object[] | |
notes required | string[] | What a test can't show. |
perDay required | object | Matches per UTC day. |
scanned required | integer | Events read (up to 2000 per call; metered as events.read). |
suggestedCap required | integer | A daily limit with room above the peak day: three times its actions, at least 100. |
unknown required | integer | Selected events whose message is gone. |
window required | object | |
aiClassify | object | |
horizon | string | The organization's earliest event a test can see. |
nextCursor | string | More of the window to test: pass it as cursor. |
peakDay | string | |
Responses
| Status | Body | Meaning |
| 200 | RuleTest | The test. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 422 | application/problem+json | The template or parameters aren't valid (rejected). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |