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

# v2 Replace Audience

> Replace an audience for the current user. You can specify the attributes that you want to define your audiences, choosing from all data points in our taxonomy.



## OpenAPI

````yaml put /v2/saved/audiences/{id}
openapi: 3.0.0
info:
  contact: {}
  description: v2 audiences API
  license:
    name: GWI Platform Community
    url: https://github.com/orgs/GlobalWebIndex/teams/engineering-platform-2-0
  title: audiences-api
  version: 2.0.0
servers:
  - url: https://api.globalwebindex.com
security: []
paths:
  /v2/saved/audiences/{id}:
    put:
      tags:
        - Audiences
      summary: v2 Replace Audience
      description: >-
        Replace an audience for the current user. You can specify the attributes
        that you want to define your audiences, choosing from all data points in
        our taxonomy.
      operationId: v2AudiencePut
      parameters:
        - description: Audience id
          in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        $ref: '#/components/requestBodies/audiences.UpsertAudienceRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/audiences.AudienceResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: string
        '401':
          description: Invalid token
          content:
            application/json:
              schema:
                type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: string
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: string
      security:
        - ApiKeyAuth: []
components:
  requestBodies:
    audiences.UpsertAudienceRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/audiences.UpsertAudienceRequest'
      description: Audience body
      required: true
  schemas:
    audiences.AudienceResponse:
      properties:
        created_at:
          type: string
        datasets:
          description: The dataset codes used in the audience
          example:
            - ds-core
            - ds-96c906f1
          items:
            type: string
          type: array
        description:
          description: The generated description of the audience
          example: Male millennials aged 18-24 who use social media daily
          type: string
        expression:
          allOf:
            - $ref: '#/components/schemas/domain.Expression'
          description: The expression defining the audience criteria
        flags:
          description: The flags associated with the audience
          example:
            - authored
          items:
            type: string
          type: array
        folder_id:
          description: The folder ID containing the audience
          example: b140035b-3adc-43bf-a39d-8e8005c8af2a
          type: string
        id:
          description: The v2 UUID identifier of the audience
          example: b140035b-3adc-43bf-a39d-8e8005c8af2a
          type: string
        name:
          description: The name of the audience
          example: Male with credit card and short-term loan
          type: string
        permissions:
          allOf:
            - $ref: '#/components/schemas/domain.Permissions'
          description: The permissions for the audience
        position:
          description: The position for sorting
          example: 128
          type: number
        shared:
          description: Whether the audience is shared
          example: false
          type: boolean
        sharings:
          allOf:
            - $ref: '#/components/schemas/domain.Sharings'
          description: The sharing information for the audience
        updated_at:
          type: string
        user_id:
          description: The user ID who owns the audience
          example: 12345
          type: integer
        v1_id:
          description: The v1 ID of the audience
          example: 12345
          type: integer
      type: object
    audiences.UpsertAudienceRequest:
      properties:
        datasets:
          description: Dataset codes
          example:
            - ds-core
            - ds-96c906f1
          items:
            type: string
          type: array
        expression:
          allOf:
            - $ref: '#/components/schemas/domain.Expression'
          description: >-
            Defines the audience criteria using question and datapoint
            combinations
        flags:
          description: Additional flags about audience (authored, curated, isP2)
          example:
            - authored
            - curated
          items:
            type: string
          type: array
        folder:
          description: V1 folder ID (legacy, use folder_id for v2)
          type: integer
        folder_id:
          description: Null/nil uuid or folder uuid
          example: b140035b-3adc-43bf-a39d-8e8005c8af2a
          type: string
        name:
          description: Human readable name
          example: Male with credit card and short-term loan
          type: string
        position:
          description: Position to give to be able to sort
          example: 128
          type: number
        shared:
          description: Whether the audience is shared
          example: false
          type: boolean
      type: object
    domain.Expression:
      properties:
        and:
          items:
            $ref: '#/components/schemas/domain.Expression'
          type: array
        datapoints:
          example:
            - q2_1
          items:
            type: string
          type: array
        min_count:
          type: integer
        not:
          example: false
          type: boolean
        options:
          items:
            type: string
          type: array
        or:
          items:
            $ref: '#/components/schemas/domain.Expression'
          type: array
        question:
          example: q2
          type: string
        suffixes:
          example:
            - 1
          items:
            type: integer
          type: array
      type: object
    domain.Permissions:
      properties:
        audience_overall:
          $ref: '#/components/schemas/domain.AudiencePermission'
        meta:
          additionalProperties: true
          type: object
      type: object
    domain.Sharings:
      additionalProperties:
        $ref: '#/components/schemas/domain.SharingData'
      type: object
    domain.AudiencePermission:
      enum:
        - accessible
        - containsUnknownData
      type: string
      x-enum-varnames:
        - Accessible
        - ContainsUnknownData
    domain.SharingData:
      properties:
        organisation_ids:
          items:
            type: integer
          type: array
        sharer:
          $ref: '#/components/schemas/domain.SharingUser'
        users:
          items:
            $ref: '#/components/schemas/domain.SharingUser'
          type: array
      type: object
    domain.SharingUser:
      properties:
        email:
          type: string
        id:
          type: integer
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: Authorization
      type: apiKey

````