---
title: "Create or update rule"
method: POST
path: "/kody-rules/create-or-update"
tags: ["Kody Rules"]
---

# Create or update rule

`POST /kody-rules/create-or-update`

Create a new rule or update an existing one.

## Request body

- CreateKodyRuleDto
  - `severity` 'low' | 'medium' | 'high' | 'critical', required
  - `origin` 'user' | 'library' | 'generated', required
  - `status` 'active' | 'rejected' | 'pending' | 'deleted'
  - `referenceProcessingStatus` 'pending' | 'processing' | 'completed' | 'failed'

## Response `201`

- KodyRuleResponseDto
  - `statusCode` number, required
  - `type` string, required
  - `data` KodyRuleDto, required
    - `uuid` string, uuid, required
    - `title` string, required
    - `rule` string, required
    - `path` object, nullable, required
    - `sourcePath` object, nullable, required
    - `sourceAnchor` object, nullable, required
    - `severity` string, required
    - `status` string, required
    - `repositoryId` object, nullable, required
    - `directoryId` object, nullable, required
    - `examples` KodyRulesExampleDto[], nullable, required
      - `snippet` string, required
      - `isCorrect` boolean, required
    - `origin` string, required
    - `scope` string, required
    - `inheritance` KodyRuleInheritanceDto, required
      - `inheritable` boolean, required
      - `exclude` string[], required
      - `include` string[], required
    - `createdAt` string, required
    - `updatedAt` string, required
    - `referenceProcessingStatus` object
    - `externalReferences` KodyRuleExternalReferenceDto[], required
      - `filePath` string, required
      - `description` string, nullable, required
      - `repositoryName` string, nullable, required
    - `syncErrors` KodyRuleSyncErrorDto[], required
      - `type` string, required
      - `message` string, nullable, required
      - `details` object, required — Provider-specific error details.

## Other responses

- `400` — Validation error
- `401` — Not authenticated
- `403` — Insufficient permissions
- `500` — Unexpected error

---

[API](https://skmtc.net/kodustech/apis/kodus-api.md) · [All operations](https://skmtc.net/kodustech/apis/kodus-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kodustech/kodus-api/versions/e2282ac5fb3a/schema)
