---
title: "Run Rule Test"
method: POST
path: "/api/v1/custom-rules/test"
tags: ["custom-rules"]
---

# Run Rule Test

`POST /api/v1/custom-rules/test`

## Request

- Base URL: `https://app.kaminari.ad`
- URL: `https://app.kaminari.ad/api/v1/custom-rules/test`
- Auth: HTTP bearer

Test a rule against an existing scan (real execution via checkers).

## Request body

- RuleTestRequest: Request body for POST /custom-rules/test. ``context`` selects the prompt mode for LLM rules: * ``isolated`` (default) — the prompt carries only the draft rule; good for iterating on criteria wording. * ``production`` — the prompt carries the org's full active rule set with the draft substituted for its saved version (``rule_id``), exactly like a real scan; the reply is filtered to the draft's tags. Only valid for ``rule_type="llm"``.
  - `scan_id` string, uuid, required
  - `rule_type` string, required
  - `config` object, required
  - `target` string
  - `name` string
  - `context` 'isolated' | 'production'
  - `rule_id` string, uuid, nullable

## Response `200`

Successful Response

- RuleTestResponse: Response from POST /custom-rules/test. ``llm_failed`` is True when the LLM provider could not complete the evaluation (API error, invalid response). The UI surfaces this as a warning instead of showing a misleading "No match". ``llm_call_id`` / ``llm_prompt_url`` / ``llm_response_url`` are populated only when an LLM-based rule actually ran and the worker persisted the call's telemetry. The UI renders collapsible prompt and response sections from the two same-origin URLs (served by ``/api/internal/llm/calls/{id}/...``); non-LLM rule types and runs where telemetry didn't land leave them empty/None so the sections stay hidden.
  - `matched` boolean, required
  - `tags` RuleTestTagResult[], required
    - `tag_slug` string, required
    - `detail` string
  - `elapsed_ms` integer, required
  - `llm_failed` boolean
  - `llm_call_id` string, uuid, nullable
  - `llm_prompt_url` string
  - `llm_response_url` string

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kaminari/apis/kaminari-ad-api.md) · [All operations](https://skmtc.dev/kaminari/apis/kaminari-ad-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kaminari/apis/kaminari-ad-api/revisions/013f86e2fd32?raw)
