A rule runs automatically when a matching email arrives or at a scheduled time. You can view them in Rules. These endpoints let you draft and test rules from code, or pause all of them at once. To read rules, your key needs the Rules area, which is included in Full access and Read-only. To make changes, it needs Full access or Rules set to Read and write. Turning a rule on always requires a person’s approval in the app, and whether a key can change a rule also depends on the person it belongs to. For more on how rules work, see Rules.
Use GET /rules and GET /rules/{id} to read rules. POST /rules creates a draft, and PATCH /rules/{id} updates it. Drafts never run.
POST /rules/{id}/tests tests a rule and saves the result without running any of its actions. By default, it checks recent events and builds previews for up to 10 matches, which uses a few credits. To test a scheduled rule as if it were due right now, send {"mode":"schedule_now"}.
POST /rules/{id}/actions handles lifecycle actions: enable, pause, resume, run_now, replay, stop_with_tasks, archive, and restore. The first time you call enable, the API returns authorization_required along with an approval_url, and the rule stays unchanged. Once a person approves it, send the same action again with authorization_request_id. Replaying a run follows the same approval flow. For general API details, see The REST API, or use svanja rule to manage rules from a terminal.