---
title: "Preview Rule"
method: POST
path: "/api/rules/preview"
tags: ["rules"]
---

# Preview Rule

`POST /api/rules/preview`

## Request

- Base URL: `https://demo.usesecuro.com` (the document declares no server; this is the origin it was published from)
- URL: `https://demo.usesecuro.com/api/rules/preview`
- Auth: OAuth 2
  - Password
  - Token URL: `/api/auth/login`
- TypeScript: <https://skmtc.dev/usesecuro/apis/securo/docs/api/rules/preview/post.ts> (a function with typed inputs; its response is checked against the schema)

Show which existing transactions a draft rule would match, and how it
would change them, without saving anything.

## Headers

- `X-Workspace-Id` string, nullable

## Request body

- RulePreviewRequest: A draft rule sent from the editor, before it is saved. Carries the same save-time flags as `RuleCreate` — the preview answers "what happens when I save this?", and saving an inactive rule, or one not being applied to existing transactions, changes nothing right now. Name and priority play no part: neither decides what a rule matches.
  - `conditions_op` string
  - `conditions` union[], required
    - union
      - RuleConditionGroup: A nested group of conditions joined by its own operator. Groups let a rule mix AND and OR — `type is debit AND (contains UBER OR contains 99POP)`. They hold leaf conditions only: `conditions` is typed as `list[RuleCondition]`, so a nested group fails validation and rule depth stays capped at two levels, which is what the engine and editor support.
        - `op` string
        - `conditions` RuleCondition[], required
          - `field` string, required
          - `op` string, required
          - `value` unknown, required
      - RuleCondition
        - `field` string, required
        - `op` string, required
        - `value` unknown, required
  - `actions` RuleAction[]
    - `op` string, required
    - `value` unknown, required
  - `is_active` boolean
  - `apply_to_existing` boolean
  - `overwrite_existing_categories` boolean
  - `limit` integer
  - `offset` integer

## Response `200`

Successful Response

- RulePreviewResponse
  - `matched` integer, required
  - `will_change` integer, required
  - `will_apply` boolean, required
  - `sample` RulePreviewItem[], required
    - `id` string, uuid, required
    - `date` string, date, required
    - `description` string, required
    - `amount` number, required
    - `currency` string, required
    - `type` string, required
    - `current_category_id` string, uuid, nullable
    - `current_category_name` string, nullable
    - `new_category_id` string, uuid, nullable
    - `new_category_name` string, nullable
    - `will_change` boolean, required
  - `offset` integer

## Other responses

- `422`: Validation Error

## Changes

- **2026-11-05** `416a7752fec4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/usesecuro/apis/securo/changes/api/rules/preview/post.md)

---

[API](https://skmtc.dev/usesecuro/apis/securo.md) - [All operations](https://skmtc.dev/usesecuro/apis/securo/llms.txt) - [OpenAPI document](https://skmtc.dev/usesecuro/apis/securo/revisions/416a7752fec4?raw)
