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

# Create alert

> Create an alert that notifies its channels when an event happens to a resource.



## OpenAPI

````yaml POST /api/v1/alerts
openapi: 3.0.3
info:
  title: Infisical API
  description: List of all available APIs that can be consumed
  version: 0.0.1
servers:
  - url: https://us.infisical.com
    description: Production server (US)
  - url: https://eu.infisical.com
    description: Production server (EU)
  - url: http://localhost:8080
    description: Local server
security: []
paths:
  /api/v1/alerts:
    post:
      tags:
        - Alerting
      description: >-
        Create an alert that notifies its channels when an event happens to a
        resource.
      operationId: createAlert
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: The name of the alert.
                description:
                  type: string
                  maxLength: 1000
                  description: The description of the alert.
                resourceType:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    The type of resource the alert watches, for example
                    `cert-manager.application`.
                resourceId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The ID of the resource the alert watches. Set to null to
                    watch every resource of this type, where the resource type
                    supports it.
                eventType:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    The event that triggers the alert, for example
                    `cert-manager.application.certificate.expiry`.
                condition:
                  description: >-
                    The settings of the alert's event, for example `alertBefore`
                    on an expiry event. The accepted fields depend on
                    `eventType`.
                enabled:
                  type: boolean
                  description: Whether the alert is enabled. Defaults to true.
                projectId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The ID of the project to create the alert in. Optional when
                    the resource belongs to a project.
                channels:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 255
                      channelType:
                        type: string
                        enum:
                          - email
                          - slack
                          - webhook
                          - pagerduty
                      config:
                        type: object
                        additionalProperties: {}
                        default: {}
                      enabled:
                        type: boolean
                      recipients:
                        type: array
                        items:
                          type: object
                          properties:
                            principalType:
                              type: string
                              enum:
                                - user
                                - group
                                - email
                                - project-members
                            principalId:
                              type: string
                              minLength: 1
                              maxLength: 255
                          required:
                            - principalType
                            - principalId
                          additionalProperties: false
                        maxItems: 20
                    required:
                      - name
                      - channelType
                    additionalProperties: false
                  minItems: 1
                  maxItems: 10
                  description: >-
                    The channels the alert notifies. Each is email, Slack,
                    webhook, or PagerDuty.
              required:
                - name
                - resourceType
                - eventType
                - channels
              additionalProperties: false
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  alert:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      name:
                        type: string
                      description:
                        type: string
                        nullable: true
                      resourceType:
                        type: string
                      resourceId:
                        type: string
                        nullable: true
                      eventType:
                        type: string
                      triggerType:
                        type: string
                      condition:
                        nullable: true
                      enabled:
                        type: boolean
                      orgId:
                        type: string
                      projectId:
                        type: string
                        nullable: true
                      resourceName:
                        type: string
                        nullable: true
                      filters:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                                nullable: true
                            required:
                              - id
                              - name
                            additionalProperties: false
                        description: >-
                          The resources named in the alert's condition, such as
                          applications, certificate profiles, and signers, each
                          as `{ id, name }`. `name` is null for a deleted
                          resource.
                      channels:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                            name:
                              type: string
                            channelType:
                              type: string
                            enabled:
                              type: boolean
                            config:
                              type: object
                              additionalProperties: {}
                            recipients:
                              type: array
                              items:
                                type: object
                                properties:
                                  principalType:
                                    type: string
                                  principalId:
                                    type: string
                                required:
                                  - principalType
                                  - principalId
                                additionalProperties: false
                          required:
                            - id
                            - name
                            - channelType
                            - enabled
                            - config
                            - recipients
                          additionalProperties: false
                      lastRun:
                        type: object
                        properties:
                          timestamp:
                            type: string
                            format: date-time
                          status:
                            type: string
                            enum:
                              - success
                              - partial
                              - failed
                        required:
                          - timestamp
                          - status
                        additionalProperties: false
                        nullable: true
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                    required:
                      - id
                      - name
                      - description
                      - resourceType
                      - resourceId
                      - eventType
                      - triggerType
                      - enabled
                      - orgId
                      - projectId
                      - channels
                      - createdAt
                      - updatedAt
                    additionalProperties: false
                required:
                  - alert
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 400
                  message:
                    type: string
                  error:
                    type: string
                  details: {}
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 401
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 403
                  message:
                    type: string
                  details: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 404
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '422':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 422
                  message: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - error
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 500
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false

````

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