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

# Update a monitor alert rule

> Patches one or more fields of an alert rule. The merged rule (patch over the stored row) is what gets validated. The type and the kind of target (metric family or Specification) cannot change: delete the rule and create a new one. A webhook URL set for the first time gets its signing secret generated; read it with regenerate-alert-rule-webhook-secret.



## OpenAPI

````yaml https://api.galtea.ai/openapi.json patch /monitors/{monitorId}/alert-rules/{alertRuleId}
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /monitors/{monitorId}/alert-rules/{alertRuleId}:
    patch:
      tags:
        - monitors
      summary: Update a monitor alert rule
      description: >-
        Patches one or more fields of an alert rule. The merged rule (patch over
        the stored row) is what gets validated. The type and the kind of target
        (metric family or Specification) cannot change: delete the rule and
        create a new one. A webhook URL set for the first time gets its signing
        secret generated; read it with regenerate-alert-rule-webhook-secret.
      operationId: updateMonitorAlertRule
      parameters:
        - schema:
            type: string
            description: Monitor ID
            example: monitor_123
          required: true
          description: Monitor ID
          name: monitorId
          in: path
        - schema:
            type: string
            description: Alert rule ID
            example: monitorAlertRule_123
          required: true
          description: Alert rule ID
          name: alertRuleId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMonitorAlertRuleRequest'
      responses:
        '204':
          description: Alert rule updated successfully
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateMonitorAlertRuleRequest:
      type: object
      properties:
        metricGroupId:
          type: string
          minLength: 1
          description: >-
            A metric family this monitor scores. Only a rule that watches a
            metric family accepts it. Mutually exclusive with specificationId.
          example: metricGroup_123
        specificationId:
          type: string
          minLength: 1
          description: >-
            A Specification this monitor binds. Only a rule that watches a
            Specification accepts it. Mutually exclusive with metricGroupId.
          example: specification_123
        window:
          type: string
          enum:
            - FIFTEEN_MINUTES
            - ONE_HOUR
            - SIX_HOURS
            - TWENTY_FOUR_HOURS
          description: The trailing window the rule evaluates
          example: ONE_HOUR
        badSessionScore:
          type: number
          nullable: true
          description: >-
            BAD_SESSION_COUNT only: a session counts as bad at or below this
            score. Must be null or left out for NO_SCORE_RATE.
          example: 0.5
        threshold:
          type: number
          description: >-
            The value the rule fires on, by type: a whole count of bad sessions
            for BAD_SESSION_COUNT, a percent above 0 and at most 100 for
            NO_SCORE_RATE
          example: 3
        recipients:
          type: array
          items:
            type: string
          maxItems: 20
          description: >-
            Email addresses notified when the rule fires (0 to 20). A rule needs
            at least one address or a webhookUrl.
          example:
            - team@example.com
        webhookUrl:
          type: string
          nullable: true
          minLength: 1
          maxLength: 2048
          description: >-
            URL that receives a signed POST when an alert opens or recovers. It
            must use https, unless the deployment allows http. A Slack
            incoming-webhook URL posts a message to its channel. Write-only:
            responses show only its host and port. On update, null removes it
            and leaving it out keeps it. Read the signing secret with
            regenerate-alert-rule-webhook-secret.
          example: https://hooks.slack.com/services/T000/B000/XXXX
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.