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

# Upsert a notification rule

> Create or update a per-event per-channel notification rule. Requires admin or owner role.



## OpenAPI

````yaml https://api.surnex.io/openapi.json put /v1/organizations/{org_id}/notifications/rules
openapi: 3.1.0
info:
  title: Surnex API
  description: |-
    Surnex SEO Platform API — api.surnex.io

    Provides the complete backend for the Surnex SEO dashboard including:
    - Multi-tenant organization management
    - Project tracking (domains)
    - Keyword rank tracking (Phase 1+)
    - Backlink analysis (Phase 3+)
    - Site auditing (Phase 4+)
    - Stripe billing integration
    - MCP endpoint for AI agents at /mcp
  version: 0.1.0
servers: []
security: []
paths:
  /v1/organizations/{org_id}/notifications/rules:
    put:
      tags:
        - Notifications
      summary: Upsert a notification rule
      description: >-
        Create or update a per-event per-channel notification rule. Requires
        admin or owner role.
      operationId: >-
        upsert_notification_rule_v1_organizations__org_id__notifications_rules_put
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Org Id
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertNotificationRuleRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIResponse_NotificationRuleResponse_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UpsertNotificationRuleRequest:
      properties:
        event:
          type: string
          maxLength: 50
          minLength: 1
          title: Event
          description: Notification event type
        channel:
          type: string
          maxLength: 50
          minLength: 1
          title: Channel
          description: 'Notification channel: in_app, email, slack, discord'
        enabled:
          type: boolean
          title: Enabled
          description: Whether this event is enabled for this channel
      type: object
      required:
        - event
        - channel
        - enabled
      title: UpsertNotificationRuleRequest
      description: >-
        Request body for creating or updating a single notification rule
        (auto-save per toggle).
    APIResponse_NotificationRuleResponse_:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          anyOf:
            - $ref: '#/components/schemas/NotificationRuleResponse'
            - type: 'null'
      type: object
      title: APIResponse[NotificationRuleResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    NotificationRuleResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        org_id:
          type: string
          format: uuid
          title: Org Id
        event:
          type: string
          title: Event
        channel:
          type: string
          title: Channel
        enabled:
          type: boolean
          title: Enabled
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - org_id
        - event
        - channel
        - enabled
        - created_at
        - updated_at
      title: NotificationRuleResponse
      description: Response schema for a notification rule.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````