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

# Create monitor alert

> Saves an alert on the monitor. An issues alert on a signal monitor returns 400. A rule has one kind: count (more than N matching traces in a window), rate (more than a percent of judged traces in a window, once the window has min_sample traces), spike (today's matches rise above the usual range of the previous 7 days), every_match (any trace matches), quiet (no matches in a window after at least min_prior_matches in the window before it), or issues (tool monitors only: a new issue, or a resolved one coming back). A level kind (count, rate, spike) has a cooldown of 1h, 6h or 24h. An event kind (every_match, issues) has a cooldown of none, 5m or 1h. A quiet alert has none: it sends once until matches return. Alerts are enabled per organization; without it every alert call returns 404. A monitor can have at most 10 alerts: another returns 409 monitor_alert_limit_reached. Alerts post to the project's Slack channel.



## OpenAPI

````yaml https://api.uselemma.ai/openapi.json post /monitors/{monitor_id}/alerts
openapi: 3.1.0
info:
  title: Lemma Platform API
  description: Lemma Platform HTTP API for AI observability and workspace operations.
  version: 0.1.0
servers:
  - url: https://api.uselemma.ai
    description: Lemma production API
security:
  - bearerAuth: []
paths:
  /monitors/{monitor_id}/alerts:
    post:
      tags:
        - Monitors
      summary: Create monitor alert
      description: >-
        Saves an alert on the monitor. An issues alert on a signal monitor
        returns 400. A rule has one kind: count (more than N matching traces in
        a window), rate (more than a percent of judged traces in a window, once
        the window has min_sample traces), spike (today's matches rise above the
        usual range of the previous 7 days), every_match (any trace matches),
        quiet (no matches in a window after at least min_prior_matches in the
        window before it), or issues (tool monitors only: a new issue, or a
        resolved one coming back). A level kind (count, rate, spike) has a
        cooldown of 1h, 6h or 24h. An event kind (every_match, issues) has a
        cooldown of none, 5m or 1h. A quiet alert has none: it sends once until
        matches return. Alerts are enabled per organization; without it every
        alert call returns 404. A monitor can have at most 10 alerts: another
        returns 409 monitor_alert_limit_reached. Alerts post to the project's
        Slack channel.
      operationId: create_monitor_alert
      parameters:
        - name: monitor_id
          in: path
          required: true
          description: Monitor ID.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotency_key:
                  type: string
                  minLength: 1
                  maxLength: 200
                rule:
                  oneOf:
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: count
                        threshold:
                          type: integer
                          minimum: 1
                        window:
                          type: string
                          enum:
                            - 1h
                            - 24h
                            - 7d
                        cooldown:
                          type: string
                          enum:
                            - 1h
                            - 6h
                            - 24h
                      required:
                        - kind
                        - threshold
                        - window
                        - cooldown
                      additionalProperties: false
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: rate
                        percent:
                          type: number
                          exclusiveMinimum: 0
                          maximum: 100
                        window:
                          type: string
                          enum:
                            - 1h
                            - 24h
                            - 7d
                        cooldown:
                          type: string
                          enum:
                            - 1h
                            - 6h
                            - 24h
                        min_sample:
                          type: integer
                          minimum: 1
                          default: 20
                      required:
                        - kind
                        - percent
                        - window
                        - cooldown
                      additionalProperties: false
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: spike
                        cooldown:
                          type: string
                          enum:
                            - 1h
                            - 6h
                            - 24h
                      required:
                        - kind
                        - cooldown
                      additionalProperties: false
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: every_match
                        cooldown:
                          type: string
                          enum:
                            - none
                            - 5m
                            - 1h
                      required:
                        - kind
                        - cooldown
                      additionalProperties: false
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: quiet
                        window:
                          type: string
                          enum:
                            - 1h
                            - 24h
                            - 7d
                        min_prior_matches:
                          type: integer
                          minimum: 1
                          default: 1
                      required:
                        - kind
                        - window
                      additionalProperties: false
                    - type: object
                      properties:
                        kind:
                          type: string
                          const: issues
                        issue_returns:
                          type: boolean
                        cooldown:
                          type: string
                          enum:
                            - none
                            - 5m
                            - 1h
                      required:
                        - kind
                        - issue_returns
                        - cooldown
                      additionalProperties: false
              required:
                - idempotency_key
                - rule
              additionalProperties: false
      responses:
        '201':
          description: Created alert
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  monitor_id:
                    type: string
                    format: uuid
                  rule:
                    oneOf:
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: count
                          threshold:
                            type: integer
                            minimum: 1
                          window:
                            type: string
                            enum:
                              - 1h
                              - 24h
                              - 7d
                          cooldown:
                            type: string
                            enum:
                              - 1h
                              - 6h
                              - 24h
                        required:
                          - kind
                          - threshold
                          - window
                          - cooldown
                        additionalProperties: false
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: rate
                          percent:
                            type: number
                            exclusiveMinimum: 0
                            maximum: 100
                          window:
                            type: string
                            enum:
                              - 1h
                              - 24h
                              - 7d
                          cooldown:
                            type: string
                            enum:
                              - 1h
                              - 6h
                              - 24h
                          min_sample:
                            type: integer
                            minimum: 1
                        required:
                          - kind
                          - percent
                          - window
                          - cooldown
                          - min_sample
                        additionalProperties: false
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: spike
                          cooldown:
                            type: string
                            enum:
                              - 1h
                              - 6h
                              - 24h
                        required:
                          - kind
                          - cooldown
                        additionalProperties: false
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: every_match
                          cooldown:
                            type: string
                            enum:
                              - none
                              - 5m
                              - 1h
                        required:
                          - kind
                          - cooldown
                        additionalProperties: false
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: quiet
                          window:
                            type: string
                            enum:
                              - 1h
                              - 24h
                              - 7d
                          min_prior_matches:
                            type: integer
                            minimum: 1
                        required:
                          - kind
                          - window
                          - min_prior_matches
                        additionalProperties: false
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: issues
                          issue_returns:
                            type: boolean
                          cooldown:
                            type: string
                            enum:
                              - none
                              - 5m
                              - 1h
                        required:
                          - kind
                          - issue_returns
                          - cooldown
                        additionalProperties: false
                  firing:
                    type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - armed
                          - sending
                          - cooling_down
                          - quiet_latched
                      suppressed_count:
                        type: integer
                        minimum: 0
                      cooldown_until:
                        type:
                          - string
                          - 'null'
                        format: date-time
                    required:
                      - status
                      - suppressed_count
                      - cooldown_until
                    additionalProperties: false
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
                required:
                  - id
                  - monitor_id
                  - rule
                  - firing
                  - created_at
                  - updated_at
                additionalProperties: false
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                  retryable:
                    type: boolean
                  retry_after_seconds:
                    type: number
                    minimum: 0
                required:
                  - detail
                  - code
                  - retryable
                additionalProperties: false
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                required:
                  - detail
                additionalProperties: false
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                  retryable:
                    type: boolean
                  retry_after_seconds:
                    type: number
                    minimum: 0
                required:
                  - detail
                  - code
                  - retryable
                additionalProperties: false
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                  retryable:
                    type: boolean
                  retry_after_seconds:
                    type: number
                    minimum: 0
                required:
                  - detail
                  - code
                  - retryable
                additionalProperties: false
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                  retryable:
                    type: boolean
                  retry_after_seconds:
                    type: number
                    minimum: 0
                required:
                  - detail
                  - code
                  - retryable
                additionalProperties: false
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
                    const: internal_error
                  retryable:
                    type: boolean
                    const: false
                  request_id:
                    type: string
                required:
                  - detail
                  - code
                  - retryable
                  - request_id
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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