---
title: "Update a hook rule"
method: PATCH
path: "/api/hook-rules/{id}"
tags: ["HookRules"]
---

# Update a hook rule

`PATCH /api/hook-rules/{id}`

## Request

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

## Request body

- HookRulePatch
  - `name` string
  - `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[]
    - `type` 'addTags' | 'setProperties' | 'patch' | 'redact' | 'quarantine' | 'deny' | 'narrow', required

## Response `200`

Updated rule.

- HookRule
  - `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
  - `id` integer
  - `createdAt` string, date-time
  - `updatedAt` string, date-time

## 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.
- `404`: Resource not found (or not visible to the caller).

---

[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)
