---
title: "Create custom validation rule"
method: POST
path: "/api/v1/rules/create"
tags: ["Open API", "Rules"]
---

# Create custom validation rule

`POST /api/v1/rules/create`

## Request

- Base URL: `https://developer.claimmind.life` (the document declares no server; this is the origin it was published from)
- URL: `https://developer.claimmind.life/api/v1/rules/create`
- Auth: none declared. Required headers: `X-API-Key`

Create new tenant-specific validation rules for claim processing.

    **Use Case:** Define custom business rules for your hospital's claim validation requirements.

    **Authentication:** API Key (X-API-Key header)
    **Required Scope:** `rules:write`

    **Request Structure:**
    List of rule objects to create.

    **Rule Components:**
    - requirement: What the rule checks (description)
    - applicability: Logic defining when rule applies
      - age_min/age_max: Patient age range
      - sex: allowed gender (M/F/any)
      - care_type: List of care types (e.g. ["Rawat Inap"])
    - severity: ERROR | WARNING | INFO
      - ERROR: Blocks claim submission
      - WARNING: Shows warning but allows submission
      - INFO: Informational message only
    - category: Rule category (e.g., "Administratif")

    **Example Request:**
    ```json
    {
        "rules": [
            {
                "requirement": "Patient age must be between 0 and 150 years",
                "applicability": {
                    "age_min": 0,
                    "age_max": 150,
                    "sex": "any",
                    "care_type": ["Rawat Inap", "Rawat Jalan"]
                },
                "severity": "ERROR",
                "category": "Administratif"
            }
        ]
    }
    ```

    **Example Response:**
    ```json
    {
        "created_rules": [
            {
                "rule_id": "rule-uuid-123",
                "requirement": "Patient age must be between 0 and 150 years",
                "status": "ACTIVE"
            }
        ]
    }
    ```

    **Common Errors:**
    - 400: Invalid condition syntax
    - 403: Insufficient permissions
    - 500: Validator Service error

## Headers

- `X-API-Key` string, required

## Request body

- CreateRuleRequest: Request schema for creating rules.
  - `rules` CreateRuleItem[], required
    - `requirement` string, required
    - `applicability` Applicability, required: Rule applicability criteria.
      - `icd10_any` string[], nullable
      - `icd9_any` string[], nullable
      - `age_min` integer, nullable
      - `age_max` integer, nullable
      - `sex` 'M' | 'F' | 'any': Sex enum.
      - `care_type` CareType[], nullable
    - `severity` 'error' | 'warning' | 'info' | 'any' | 'EPISODIC', required: Rule severity enum.
    - `category` 'Kriteria Diagnosis' | 'Tatalaksana' | 'Monitoring' | 'Indikasi Rawat Inap' | 'Kriteria Pulang' | 'Administratif' | 'Farmakologi' | 'Others', required: Rule category enum.
    - `documents_to_validate` string[], nullable

## Response `200`

Rule created successfully

- unknown

## Other responses

- `400`: Invalid rule configuration
- `403`: Insufficient permissions
- `422`: Validation Error

---

[API](https://skmtc.dev/claimmind/apis/claimmind-open-api-service.md) - [All operations](https://skmtc.dev/claimmind/apis/claimmind-open-api-service/llms.txt) - [OpenAPI document](https://skmtc.dev/claimmind/apis/claimmind-open-api-service/revisions/ee8bfbeadb8a?raw)
