---
title: "Update custom rule"
method: POST
path: "/api/v2/rules/update"
tags: ["Rules"]
---

# Update custom rule

`POST /api/v2/rules/update`

## Request

- Base URL: `https://zeropath.com`
- URL: `https://zeropath.com/api/v2/rules/update`
- Auth: API key in header `X-ZeroPath-API-Token-Id` and API key in header `X-ZeroPath-API-Token-Secret`

Update an existing natural language security rule. Only `ruleId` is required — all other fields are optional and only provided fields are changed. Pass `allRepositories: true` to make the rule apply to all repos, or `repositoryIds` to scope it to specific repos. Omit both to leave scope unchanged.

## Request body

- UpdateRuleInput
  - `organizationId` string
  - `ruleId` string, required
  - `name` string
  - `rule` string: Natural language description of the security rule
  - `globPattern` string: Glob pattern for files this rule applies to
  - `sourceTypes` string[]
  - `repositoryIds` string[]: Scope the rule to specific repositories. Cannot be combined with allRepositories.
  - `allRepositories` true: Set to true to make the rule apply to all repositories in the organization. Cannot be combined with repositoryIds.
  - `scope` 'allRepositories' | 'repositories' | 'tags': Optional explicit scope. Use tags with tagIds to switch the rule to tag-only scope.
  - `tagIds` string[]: Tag IDs to associate with this rule

## Response `200`

Rule updated successfully

- Rule
  - `id` string, required
  - `name` string, required
  - `rule` string, required: Natural language description of the security rule
  - `globPattern` string, required
  - `sourceTypes` string[], required
  - `source` 'USER' | 'SECURITY_COMPASS'
  - `repositoryIds` string[], required
  - `scope` 'allRepositories' | 'repositories' | 'tags', required
  - `tags` RuleTag[], required
    - `id` string, required
    - `name` string, required
  - `createdAt` string, date-time, required
  - `updatedAt` string, date-time, required

## Other responses

- `400`: Error Response
- `401`: Error Response
- `404`: Error Response

---

[API](https://skmtc.dev/zeropath/apis/zeropath-api.md) - [All operations](https://skmtc.dev/zeropath/apis/zeropath-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zeropath/apis/zeropath-api/revisions/126e9c80ba0d?raw)
