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

# Create rule

> Create a project-scoped notification rule.

Creates a project-scoped rule (for example when a deployment settles).


## OpenAPI

````yaml POST /orgs/{org_id}/projects/{project_id}/notifications/rules
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: analytics
    description: Project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/projects/{project_id}/notifications/rules:
    post:
      tags:
        - notifications
      summary: Create a project-scoped notification rule
      description: Create a project-scoped notification rule.
      operationId: create_project_notification_rule
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: project_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateNotificationRuleReq'
            examples:
              Email channel:
                value:
                  name: Deployment failures
                  event_type: project.deployment.failed
                  cooldown_seconds: 3600
                  channel:
                    type: email
                    config:
                      to: oncall@example.com
              Slack channel:
                value:
                  name: Deployment failures to Slack
                  event_type: project.deployment.failed
                  channel:
                    type: slack
                    config:
                      token: xoxb-1234567890123-1234567890123
                      channel: C0123456789
        required: true
      responses:
        '201':
          description: Rule and channel link created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateNotificationRuleOut'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: Forbidden
      security:
        - bearer_auth: []
components:
  schemas:
    CreateNotificationRuleReq:
      type: object
      description: >-
        Body for POST org-wide or project-scoped notification rules (same
        shape).
      required:
        - name
        - event_type
        - channel
      properties:
        channel:
          $ref: '#/components/schemas/CreateChannelReq'
          description: >-
            Channel: inline `type` + `config`, or reuse with `{ "id": <channel
            id> }` (same org).
        condition:
          type:
            - object
            - 'null'
        cooldown_seconds:
          type: integer
          format: int32
        event_type:
          $ref: '#/components/schemas/NotificationEventType'
        name:
          type: string
    CreateNotificationRuleOut:
      type: object
      required:
        - id
        - channel_id
        - channel_action
      properties:
        channel_action:
          $ref: '#/components/schemas/ChannelAction'
        channel_id:
          type: integer
          format: int64
        id:
          type: integer
          format: int64
    ErrorMessage:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code (e.g. `ALREADY_EXISTS`, `BAD_REQUEST`).
        message:
          type: string
          description: Human-readable description.
    CreateChannelReq:
      type: object
      properties:
        config:
          type: object
          description: Omitted or null when linking by `id` only.
        id:
          type:
            - string
            - 'null'
          description: >-
            Existing `NotificationChannels.id` for this org. When set, `type` /
            `config` / `name` are ignored.
        name:
          type:
            - string
            - 'null'
        type:
          $ref: '#/components/schemas/NotificationChannelType'
    NotificationEventType:
      type: string
      enum:
        - org.credits.usage
        - project.deployment.failed
        - project.deployment.running
    ChannelAction:
      type: string
      description: How the rule was wired to `NotificationChannels` for this create call.
      enum:
        - linked
        - reused
        - created
    NotificationChannelType:
      type: string
      enum:
        - email
        - slack
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````