---
title: "Create rule"
method: POST
path: "/api/v1/projects/{projectId}/rules"
tags: ["Rules"]
---

# Create rule

`POST /api/v1/projects/{projectId}/rules`

## Request

- Base URL: `http://localhost:8080`
- URL: `http://localhost:8080/api/v1/projects/{projectId}/rules`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Creates a new event processing rule with conditions and actions

## Path parameters

- `projectId` string, uuid, required

## Request body

- RuleRequest
  - `name` string, required
  - `description` string
  - `enabled` boolean
  - `priority` integer
  - `eventTypePattern` string
  - `conditions` union
    - Group
      - `type` string, required
      - `op` 'AND' | 'OR' | 'NOT'
      - `children` union[]
        - union
          - Group (recursive)
          - Predicate
            - `type` string, required
            - `field` string
            - `operator` 'EQ' | 'NEQ' | 'CONTAINS' | 'NOT_CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'IN' | 'NOT_IN' | 'REGEX' | 'GT' | 'GTE' | 'LT' | 'LTE' | 'BETWEEN' | 'EXISTS' | 'NOT_EXISTS' | 'IS_NULL' | 'NOT_NULL'
            - `value` unknown
            - `valueType` 'STRING' | 'NUMBER' | 'BOOLEAN' | 'ARRAY_STRING' | 'ARRAY_NUMBER' | 'DATE_TIME'
            - `caseInsensitive` boolean
    - Predicate
      - `type` string, required
      - `field` string
      - `operator` 'EQ' | 'NEQ' | 'CONTAINS' | 'NOT_CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'IN' | 'NOT_IN' | 'REGEX' | 'GT' | 'GTE' | 'LT' | 'LTE' | 'BETWEEN' | 'EXISTS' | 'NOT_EXISTS' | 'IS_NULL' | 'NOT_NULL'
      - `value` unknown
      - `valueType` 'STRING' | 'NUMBER' | 'BOOLEAN' | 'ARRAY_STRING' | 'ARRAY_NUMBER' | 'DATE_TIME'
      - `caseInsensitive` boolean
  - `actions` RuleActionRequest[]
    - `type` 'ROUTE' | 'TRANSFORM' | 'DROP' | 'TAG', required
    - `endpointId` string, uuid
    - `transformationId` string, uuid
    - `config` unknown
    - `sortOrder` integer

## Response `201`

Rule created

---

[API](https://skmtc.dev/railhook/apis/railhook-api.md) · [All operations](https://skmtc.dev/railhook/apis/railhook-api/llms.txt) · [OpenAPI document](https://skmtc.dev/railhook/apis/railhook-api/revisions/4e2c76dfc33d?raw)
