> ## Documentation Index
> Fetch the complete documentation index at: https://docs.causeloop.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Alert Rule

> Create a new alert rule.

Validates:
- name: non-empty
- type: "threshold" (default, legacy) | "crest" (V2 Wave 5C)
- type=threshold: scope non-empty string, threshold.probability 0.0-1.0,
  threshold.window_days >= 1
- type=crest: scope {pattern_ids|all}, condition {p_horizon_days,
  threshold, consecutive_runs}
- channels: subset of valid channel values



## OpenAPI

````yaml /openapi.json post /v1/alert-rules
openapi: 3.1.0
info:
  description: Causeloop Platform Backend
  title: Causeloop API
  version: 1.0.0
servers: []
security: []
paths:
  /v1/alert-rules:
    post:
      tags:
        - alert-rules
      summary: Create Alert Rule
      description: |-
        Create a new alert rule.

        Validates:
        - name: non-empty
        - type: "threshold" (default, legacy) | "crest" (V2 Wave 5C)
        - type=threshold: scope non-empty string, threshold.probability 0.0-1.0,
          threshold.window_days >= 1
        - type=crest: scope {pattern_ids|all}, condition {p_horizon_days,
          threshold, consecutive_runs}
        - channels: subset of valid channel values
      operationId: create_alert_rule_v1_alert_rules_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlertRuleCreate'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                additionalProperties: true
                title: Response Create Alert Rule V1 Alert Rules Post
                type: object
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    AlertRuleCreate:
      properties:
        channels:
          default: []
          items:
            type: string
          title: Channels
          type: array
        condition:
          anyOf:
            - $ref: '#/components/schemas/CrestCondition'
            - type: 'null'
        enabled:
          default: true
          title: Enabled
          type: boolean
        name:
          title: Name
          type: string
        scope:
          title: Scope
        snoozed_until:
          anyOf:
            - type: string
            - type: 'null'
          title: Snoozed Until
        threshold:
          anyOf:
            - $ref: '#/components/schemas/AlertThreshold'
            - type: 'null'
        type:
          default: threshold
          title: Type
          type: string
      required:
        - name
        - scope
      title: AlertRuleCreate
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    CrestCondition:
      properties:
        consecutive_runs:
          default: 1
          minimum: 1
          title: Consecutive Runs
          type: integer
        p_horizon_days:
          minimum: 1
          title: P Horizon Days
          type: integer
        threshold:
          maximum: 1
          minimum: 0
          title: Threshold
          type: number
      required:
        - p_horizon_days
        - threshold
      title: CrestCondition
      type: object
    AlertThreshold:
      properties:
        probability:
          maximum: 1
          minimum: 0
          title: Probability
          type: number
        window_days:
          title: Window Days
          type: integer
      required:
        - probability
        - window_days
      title: AlertThreshold
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http

````