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

# Update an alert rule



## OpenAPI

````yaml PATCH /v1/alert-rules/{rule_id}
openapi: 3.1.0
info:
  title: PolyAI Alerts API
  version: 1.0.0
  description: >-
    Create alert rules, inspect active alerts, register webhook endpoints, and
    receive signed webhook notifications when alert thresholds are breached.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.uk.poly.ai
    description: UK region
  - url: https://api.eu.poly.ai
    description: EU region
security:
  - ApiKeyAuth: []
paths:
  /v1/alert-rules/{rule_id}:
    patch:
      summary: Update an alert rule
      operationId: updateAlertRule
      parameters:
        - $ref: '#/components/parameters/RuleId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAlertRuleRequest'
      responses:
        '200':
          description: Alert rule updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlertRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '502':
          $ref: '#/components/responses/BadGateway'
components:
  parameters:
    RuleId:
      name: rule_id
      in: path
      required: true
      description: The rule_id must be a prefixed ID (e.g. ar_0Kx4mNpQ8rWvYb2dFgHjLs).
      schema:
        type: string
        pattern: ^ar_[A-Za-z0-9]+$
        example: ar_0Kx4mNpQ8rWvYb2dFgHjLs
  schemas:
    UpdateAlertRuleRequest:
      $ref: '#/components/schemas/UpdateAlertRuleAttributes'
      example:
        threshold_value: 2000
        enabled: false
    AlertRule:
      type: object
      required:
        - id
        - name
        - metric
        - operator
        - threshold_value
        - window_duration
        - enabled
        - current_state
        - created_at
        - updated_at
      properties:
        id:
          type: string
          pattern: ^ar_[A-Za-z0-9]+$
          example: ar_0Kx4mNpQ8rWvYb2dFgHjLs
        name:
          type: string
        project_id:
          type:
            - string
            - 'null'
        metric:
          $ref: '#/components/schemas/Metric'
        operator:
          $ref: '#/components/schemas/ComparisonOperator'
        threshold_value:
          type: integer
          minimum: 0
        window_duration:
          $ref: '#/components/schemas/WindowDuration'
        enabled:
          type: boolean
          default: true
        current_state:
          $ref: '#/components/schemas/AlertState'
        since:
          type:
            - string
            - 'null'
          format: date-time
        last_evaluated_at:
          type:
            - string
            - 'null'
          format: date-time
        current_value:
          type:
            - integer
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    UpdateAlertRuleAttributes:
      type: object
      properties:
        name:
          type: string
        project_id:
          type:
            - string
            - 'null'
        metric:
          $ref: '#/components/schemas/Metric'
        operator:
          $ref: '#/components/schemas/ComparisonOperator'
        threshold_value:
          type: integer
          minimum: 0
        window_duration:
          $ref: '#/components/schemas/WindowDuration'
        enabled:
          type: boolean
      additionalProperties: false
    Metric:
      type: string
      enum:
        - turn_latency_p50
        - turn_latency_p95
        - api_errors
        - function_errors
        - call_crashes
        - call_volume
    ComparisonOperator:
      type: string
      enum:
        - '>'
        - <
        - '>='
        - <=
    WindowDuration:
      type: string
      description: Evaluation window duration
      enum:
        - 5m
        - 10m
        - 60m
    AlertState:
      type: string
      enum:
        - ok
        - alert
        - no_data
        - unknown
    Error:
      type: object
      properties:
        message:
          type: string
  responses:
    BadRequest:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnprocessableEntity:
      description: Validation error or malformed resource ID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadGateway:
      description: Monitoring backend sync failure.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````