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

# Create custom rule

`POST /api/v2/rules/create`

## Request

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

Create a new natural language security rule that will be applied during scans

## Request body

- CreateRuleInput
  - `organizationId` string
  - `name` string, required: Name for the custom rule
  - `rule` string, required: Natural language description of the security rule
  - `globPattern` string: Glob pattern for files this rule applies to
  - `sourceTypes` string[]: Source types this rule applies to
  - `repositoryIds` string[]: Specific repository IDs to apply this rule to (if not specified, applies to all)

## Response `200`

Rule created successfully

- Rule
  - `id` string, required
  - `name` string, required
  - `rule` string, required: Natural language description of the security rule
  - `globPattern` string, required
  - `sourceTypes` string[], required
  - `repositoryIds` string[], required
  - `createdAt` string, date-time, required
  - `updatedAt` string, date-time, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized

---

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