> ## 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

> Update an alert rule. Only the fields included in the request body are changed.



## OpenAPI

````yaml PATCH /v1/alert-rules/{rule_id}
openapi: 3.1.0
info:
  title: PolyAI Alerts API
  version: 1.0.8
  description: Manage alert rules and query active alerts.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.eu.poly.ai
    description: EU region
  - url: https://api.uk.poly.ai
    description: UK region
  - url: https://api.studio.poly.ai
    description: Studio region
security:
  - ApiKeyAuth: []
paths:
  /v1/alert-rules/{rule_id}:
    patch:
      summary: Update an alert rule
      description: >-
        Update an alert rule. Only the fields included in the request body are
        changed.
      operationId: updateAlertRule
      parameters:
        - $ref: '#/components/parameters/RuleId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlertRuleUpdateRequest'
      responses:
        '200':
          description: Alert rule updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlertRuleResponse'
        '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:
    AlertRuleUpdateRequest:
      type: object
      description: >-
        Partial update for an alert rule. Include only the fields you want to
        change.
      properties:
        name:
          type: string
          description: Alert rule name
        project_id:
          type:
            - string
            - 'null'
          description: Project ID
        metric:
          $ref: '#/components/schemas/AlertMetric'
        operator:
          $ref: '#/components/schemas/AlertOperator'
        threshold_value:
          type: integer
          minimum: 0
        window_duration:
          $ref: '#/components/schemas/WindowDuration'
        enabled:
          type: boolean
      additionalProperties: false
      example:
        threshold_value: 2000
        enabled: false
    AlertRuleResponse:
      type: object
      description: >-
        An alert rule: its trigger condition, evaluation window, and current
        state.
      required:
        - id
        - name
        - metric
        - operator
        - threshold_value
        - window_duration
        - enabled
        - created_at
        - updated_at
      properties:
        id:
          type: string
          description: Alert rule ID
          pattern: ^ar_[A-Za-z0-9]+$
          example: ar_0Kx4mNpQ8rWvYb2dFgHjLs
        name:
          type: string
          description: Alert rule name
        project_id:
          type:
            - string
            - 'null'
          description: Project ID
        metric:
          $ref: '#/components/schemas/AlertMetric'
          description: Metric being monitored
        operator:
          $ref: '#/components/schemas/AlertOperator'
          description: Comparison operator
        threshold_value:
          type: integer
          description: Threshold value
          minimum: 0
        window_duration:
          $ref: '#/components/schemas/WindowDuration'
          description: Window duration (5m, 10m, or 60m)
        enabled:
          type: boolean
          description: Whether the alert is enabled
        current_state:
          $ref: '#/components/schemas/AlertState'
          description: Current alert state
        since:
          type:
            - string
            - 'null'
          format: date-time
          description: When the current state started
        last_evaluated_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Last evaluation timestamp
        current_value:
          type:
            - integer
            - 'null'
          description: Current metric value
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
    AlertMetric:
      type: string
      description: Metric to monitor.
      enum:
        - turn_latency_p50
        - turn_latency_p95
        - api_errors
        - function_errors
        - call_crashes
        - call_volume
    AlertOperator:
      type: string
      description: Comparison operator used by the alert rule.
      enum:
        - '>'
        - <
        - '>='
        - <=
    WindowDuration:
      type: string
      description: 'Evaluation window duration. Allowed values: `5m`, `10m`, or `60m`.'
      enum:
        - 5m
        - 10m
        - 60m
    AlertState:
      type: string
      description: Current state of an alert rule.
      enum:
        - ok
        - alert
        - no_data
        - unknown
    Error:
      type: object
      properties:
        message:
          type: string
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ValidationError:
      type: object
      required:
        - loc
        - msg
        - type
      properties:
        loc:
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          type: string
        type:
          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/HTTPValidationError'
    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
      description: >-
        An API key is a token that you provide when making API calls. Include
        the token in a header parameter called `X-API-KEY`.

````