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

# PUT /audiences/{audienceId}/rules

> Replace all rules for an audience. Deletes existing rules and creates new ones.



## OpenAPI

````yaml /api/openapi/admin-api.json put /audiences/{audienceId}/rules
openapi: 3.1.0
info:
  description: Admin API for Fanfare
  title: Fanfare Admin API
  version: 1.0.0
servers:
  - description: Production
    url: https://admin.fanfare.io/api
  - description: Local development
    url: http://localhost:4800
security:
  - SecretKeyAuth: []
paths:
  /audiences/{audienceId}/rules:
    put:
      tags:
        - Audiences
      description: >-
        Replace all rules for an audience. Deletes existing rules and creates
        new ones.
      operationId: putAudiencesByAudienceIdRules
      parameters:
        - in: path
          name: audienceId
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                rules:
                  items:
                    properties:
                      audienceId:
                        format: uuid
                        type: string
                      field:
                        type: string
                      groupId:
                        format: uuid
                        nullable: true
                        type: string
                      operator:
                        enum:
                          - EQUALS
                          - NOT_EQUALS
                          - GREATER_THAN
                          - GREATER_THAN_OR_EQUAL
                          - LESS_THAN
                          - LESS_THAN_OR_EQUAL
                          - BETWEEN
                          - CONTAINS
                          - NOT_CONTAINS
                          - IN
                          - NOT_IN
                          - EXISTS
                          - NOT_EXISTS
                        type: string
                      position:
                        nullable: true
                        type: number
                      values:
                        items:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                            - type: 'null'
                        type: array
                    required:
                      - audienceId
                      - field
                      - operator
                      - values
                    type: object
                  type: array
              required:
                - rules
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  properties:
                    audienceId:
                      format: uuid
                      type: string
                    field:
                      type: string
                    groupId:
                      anyOf:
                        - format: uuid
                          type: string
                        - type: 'null'
                    id:
                      format: uuid
                      type: string
                    operator:
                      enum:
                        - EQUALS
                        - NOT_EQUALS
                        - GREATER_THAN
                        - GREATER_THAN_OR_EQUAL
                        - LESS_THAN
                        - LESS_THAN_OR_EQUAL
                        - BETWEEN
                        - CONTAINS
                        - NOT_CONTAINS
                        - IN
                        - NOT_IN
                        - EXISTS
                        - NOT_EXISTS
                    organizationId:
                      format: uuid
                      type: string
                    position:
                      anyOf:
                        - type: number
                        - type: 'null'
                      default: 0
                    values:
                      items:
                        anyOf:
                          - type: string
                          - type: number
                          - type: boolean
                          - type: 'null'
                      type: array
                  required:
                    - id
                    - organizationId
                    - audienceId
                    - field
                    - operator
                    - values
                  type: object
                type: array
          description: Audience rules replaced successfully
        '400':
          content:
            application/json:
              schema:
                properties:
                  error:
                    const: validation_error
                  issues:
                    items:
                      properties:
                        expected:
                          type: string
                        kind:
                          type: string
                        message:
                          type: string
                        path:
                          items:
                            properties:
                              input: {}
                              key:
                                type: string
                              origin:
                                type: string
                              type:
                                type: string
                            required:
                              - type
                              - origin
                              - input
                              - key
                            type: object
                          type: array
                        received:
                          type: string
                        type:
                          type: string
                      required:
                        - kind
                        - type
                        - expected
                        - received
                        - message
                        - path
                      type: object
                    type: array
                required:
                  - error
                  - issues
                type: object
          description: Bad Request - Invalid input schema
        '401':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Unauthorized - Authentication required
        '403':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Forbidden - User must be authenticated
        '500':
          content:
            application/json:
              schema:
                properties:
                  error:
                    type: string
                required:
                  - error
                type: object
          description: Internal server error
components:
  securitySchemes:
    SecretKeyAuth:
      description: Fanfare secret key. Keep secret credentials on your server.
      scheme: bearer
      type: http

````