Skip to content
Svanja

Docs API reference

Rules

Read rules, save drafts, test them, and turn them on, pause, run or archive them.

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.

Operations

An operation is one thing you can do, like reading a task or starting one. Its effect says what it changes. Some operations that act outside Svanja or change access wait for a person's approval; the approval flow is on the API overview.

rule.enable Changes access or automation

Enable a Rule.

POST /rules/{id}/actions

rule.read Reads only

Read Rules.

GET /rules GET /rules/{id}

rule.reassign_executor Changes access or automation

Reassign a Rule executor.

POST /rules/{id}/actions

rule.replay Acts outside Svanja

Replay a Rule run.

POST /rules/{id}/actions

rule.save_draft Changes data in Svanja

Save a Rule draft.

POST /rules PATCH /rules/{id}

rule.test Reads only

Test a Rule.

POST /rules/{id}/tests

Endpoints

Paths start at https://app.svanja.com/api/v1. Every endpoint needs an API key unless it says otherwise. A required Idempotency-Key header is listed with the parameters.

GET /rules List Rules

Status codes: 200, 401, 403, 429

POST /rules Create a Rule draft

Status codes: 201, 401, 403, 422, 429

GET /rules/{id} Read a Rule
Parameter In Type Required Notes
id path string yes

Status codes: 200, 401, 403, 404, 429

PATCH /rules/{id} Update a Rule draft
Parameter In Type Required Notes
id path string yes

Status codes: 202, 401, 403, 404, 422, 429

POST /rules/{id}/actions Run a Rule lifecycle action
Parameter In Type Required Notes
id path string yes

Status codes: 202, 401, 403, 404, 422, 429

POST /rules/{id}/tests Test a Rule
Parameter In Type Required Notes
id path string yes

Status codes: 202, 401, 403, 404, 422, 429

This page as plain Markdown, for AI tools: rules.md

Try Svanja with your own mailbox

Sign up now, and you get an email when your account is ready.