---
title: "Evaluate a candidate context against the saved rules (or one unsaved rule) without writing"
method: POST
path: "/api/hook-rules/dry-run"
tags: ["HookRules"]
---

# Evaluate a candidate context against the saved rules (or one unsaved rule) without writing

`POST /api/hook-rules/dry-run`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/hook-rules/dry-run`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

## Request body

- object
  - `op` 'create' | 'update'
  - `workspace` string
  - `context` object, required
    - `type` string, required
    - `name` string
    - `description` string
    - `content` string
    - `tags` string[]
    - `properties` object
    - `metadata` object
  - `rule` HookRuleInput
    - `name` string, required
    - `enabled` boolean
    - `priority` integer
    - `match` HookRuleMatch
      - `ops` string[]: Absent means [create, update]. delete, review and retrieve.before are opt-in and cannot share a rule with create or update.
      - `types` string[]
      - `workspaces` string[]
      - `tagsAny` string[]
      - `tagsAll` string[]
      - `text` HookRulePattern
        - `source` string, required: Linear-time subset: literals, ., [classes], \d \w \s, * + ? {m,n} (n <= 100), | and (groups). No anchors, backreferences or lookaround.
        - `caseInsensitive` boolean
    - `actions` HookRuleAction[], required
      - `type` 'addTags' | 'setProperties' | 'patch' | 'redact' | 'quarantine' | 'deny' | 'narrow', required

## Response `200`

The patched candidate and the verdict. Nothing is written and no counters move.

- object
  - `candidate` object
  - `changed` string[]
  - `quarantine` HookRuleVerdict, nullable
    - `ruleId` integer
    - `ruleName` string
    - `reason` string
  - `deny` HookRuleVerdict, nullable
    - `ruleId` integer
    - `ruleName` string
    - `reason` string
  - `matchedRules` object[]
    - `id` integer
    - `name` string

## Other responses

- `400`: Request body/query failed Zod validation.
- `401`: Missing or invalid credentials.
- `403`: Admin or owner role (or an API key with admin scope) required.

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
