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

# Create or update notification configuration

> Set where an org sends one kind of notification Kosli raises itself.

The targets replace the recipients Kosli would otherwise derive. Admins only.



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json put /notification-config/{org}/{notification_type}
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /notification-config/{org}/{notification_type}:
    put:
      tags:
        - Notification Config
      summary: Create or update notification configuration
      description: >-
        Set where an org sends one kind of notification Kosli raises itself.


        The targets replace the recipients Kosli would otherwise derive. Admins
        only.
      operationId: create_or_update_notification_config
      parameters:
        - name: notification_type
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/NotificationType'
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotificationConfigPutInput'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotificationConfigResponse'
        '400':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__ValidationErrorResponse___locals___ValidationErrorResponseModel__17
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    NotificationType:
      type: string
      enum:
        - api_key_expiry
      title: NotificationType
      description: |-
        A kind of notification a customer can configure.

        A new kind is a new member here, not a new field or a new collection.
    NotificationConfigPutInput:
      properties:
        targets:
          items:
            oneOf:
              - $ref: '#/components/schemas/SlackActionTarget'
              - $ref: '#/components/schemas/WebhookActionTarget'
              - $ref: '#/components/schemas/EmailActionTarget'
            discriminator:
              propertyName: type
              mapping:
                EMAIL:
                  $ref: '#/components/schemas/EmailActionTarget'
                SLACK:
                  $ref: '#/components/schemas/SlackActionTarget'
                WEBHOOK:
                  $ref: '#/components/schemas/WebhookActionTarget'
          type: array
          minItems: 1
          title: Targets
          description: >-
            Where notifications of this type go, replacing the recipients Kosli
            would otherwise derive. At least one target: delete the
            configuration instead to restore the derived recipients.
      additionalProperties: false
      type: object
      required:
        - targets
      title: NotificationConfigPutInput
    NotificationConfigResponse:
      properties:
        notification_type:
          $ref: '#/components/schemas/NotificationType'
          description: The kind of notification this configuration applies to
        scope:
          anyOf:
            - type: string
            - type: 'null'
          title: Scope
          description: The entity the configuration applies to, or null for the whole org
        targets:
          items:
            oneOf:
              - $ref: '#/components/schemas/SlackNotificationTargetResponse'
              - $ref: '#/components/schemas/WebhookNotificationTargetResponse'
              - $ref: '#/components/schemas/EmailNotificationTargetResponse'
            discriminator:
              propertyName: type
              mapping:
                EMAIL:
                  $ref: '#/components/schemas/EmailNotificationTargetResponse'
                SLACK:
                  $ref: '#/components/schemas/SlackNotificationTargetResponse'
                WEBHOOK:
                  $ref: '#/components/schemas/WebhookNotificationTargetResponse'
          type: array
          title: Targets
          description: >-
            Where notifications of this type go. Empty when the org has not
            configured any, in which case Kosli derives the recipients.
        detection:
          additionalProperties: true
          type: object
          title: Detection
          description: What counts as a condition, for the types that have one
        last_notified_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Notified At
          description: >-
            When a notification of this type was last sent for the org, as epoch
            seconds, or null if none has been
        last_failure:
          anyOf:
            - $ref: '#/components/schemas/NotificationFailureResponse'
            - type: 'null'
          description: >-
            The most recent failed delivery, when nothing has been sent since
            it; null otherwise
      type: object
      required:
        - notification_type
        - scope
        - targets
        - detection
      title: NotificationConfigResponse
    fastapi_app__errors__ValidationErrorResponse___locals___ValidationErrorResponseModel__17:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: ValidationErrorResponseModel
      examples:
        - errors:
            email: Field must be a valid email address
            name: Field cannot be empty
          message: Input payload validation failed
    SlackActionTarget:
      properties:
        type:
          type: string
          const: SLACK
          title: Type
          default: SLACK
        last_success_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Success At
        last_failure_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Failure At
        webhook:
          type: string
          pattern: ^https://
          title: Webhook
        context:
          anyOf:
            - $ref: '#/components/schemas/SlackAppContext'
            - type: 'null'
      type: object
      required:
        - webhook
      title: SlackActionTarget
    WebhookActionTarget:
      properties:
        type:
          type: string
          const: WEBHOOK
          title: Type
          default: WEBHOOK
        last_success_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Success At
        last_failure_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Failure At
        webhook:
          type: string
          pattern: ^https://
          title: Webhook
        payload_version:
          type: string
          const: '1.0'
          title: Payload Version
          default: '1.0'
      type: object
      required:
        - webhook
      title: WebhookActionTarget
    EmailActionTarget:
      properties:
        type:
          type: string
          const: EMAIL
          title: Type
          default: EMAIL
        last_success_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Success At
        last_failure_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Failure At
        emails:
          items:
            type: string
            format: email
          type: array
          title: Emails
      type: object
      required:
        - emails
      title: EmailActionTarget
    SlackNotificationTargetResponse:
      properties:
        type:
          type: string
          const: SLACK
          title: Type
        webhook:
          type: string
          title: Webhook
          description: Slack incoming webhook URL
      type: object
      required:
        - type
        - webhook
      title: SlackNotificationTargetResponse
    WebhookNotificationTargetResponse:
      properties:
        type:
          type: string
          const: WEBHOOK
          title: Type
        webhook:
          type: string
          title: Webhook
          description: URL the notification is POSTed to
        payload_version:
          type: string
          title: Payload Version
          description: Version of the webhook payload format
      type: object
      required:
        - type
        - webhook
        - payload_version
      title: WebhookNotificationTargetResponse
    EmailNotificationTargetResponse:
      properties:
        type:
          type: string
          const: EMAIL
          title: Type
        emails:
          items:
            type: string
          type: array
          title: Emails
          description: Addresses the notification is sent to
      type: object
      required:
        - type
        - emails
      title: EmailNotificationTargetResponse
    NotificationFailureResponse:
      properties:
        failed_at:
          type: number
          title: Failed At
          description: When the delivery failed, as epoch seconds
        error:
          type: string
          title: Error
          description: Why the delivery failed
      type: object
      required:
        - failed_at
        - error
      title: NotificationFailureResponse
    SlackAppContext:
      properties:
        channel_id:
          type: string
          title: Channel Id
        channel_name:
          type: string
          title: Channel Name
        team_id:
          type: string
          title: Team Id
      type: object
      required:
        - channel_id
        - channel_name
        - team_id
      title: SlackAppContext
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````