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

# Set the audience of a WhatsApp campaign

> Sets who a draft WhatsApp campaign, official or unofficial, goes to: every customer or up to 20 segments (customers in more than one get it once), minus the customers of up to 20 excluded segments. Each call sets the whole audience, exclusions included. Only drafts change; nothing is sent. Requires an API key with the write scope.



## OpenAPI

````yaml /openapi.en.json post /v1/whatsapp-campaigns/{campaign_id}/audience
openapi: 3.1.0
info:
  title: Bevits API
  version: 1.0.0
  description: >-
    Bevits public API for querying and managing CRM data, customers, purchases,
    segments, tags, automations, recipes, campaigns, email templates, brand kit,
    custom events, and webhooks.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.bevits.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: System
    description: API availability.
  - name: Identity
    description: Organization and API key identity.
  - name: Customers
    description: Customers and their relationships.
  - name: Segments
    description: Customer segments.
  - name: Purchases
    description: >-
      Purchases from store integrations and purchases created through the API by
      organizations that sell through their own system.
  - name: CRM data
    description: Tags and attribute definitions.
  - name: Automations
    description: Automation flows.
  - name: Campaigns
    description: Email, WhatsApp, and SMS campaigns.
  - name: Account and brand
    description: Account context, brand kit, and images.
  - name: Recipes
    description: Ready-made automations created from recipes, with undo.
  - name: Email templates
    description: Creating and importing email templates.
  - name: Events
    description: Custom events sent by the store and their types.
  - name: Webhooks
    description: Endpoints that receive the store's events, and the delivery log.
paths:
  /v1/whatsapp-campaigns/{campaign_id}/audience:
    post:
      tags:
        - Campaigns
      summary: Set the audience of a WhatsApp campaign
      description: >-
        Sets who a draft WhatsApp campaign, official or unofficial, goes to:
        every customer or up to 20 segments (customers in more than one get it
        once), minus the customers of up to 20 excluded segments. Each call sets
        the whole audience, exclusions included. Only drafts change; nothing is
        sent. Requires an API key with the write scope.
      operationId: setWhatsAppCampaignAudience
      parameters:
        - name: campaign_id
          in: path
          required: true
          description: Public ID of the WhatsApp campaign.
          schema:
            type: string
            pattern: ^tcp_[A-Za-z0-9_-]+$
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetWhatsAppCampaignAudienceRequest'
            example:
              audience: everyone
              excluded_segment_ids:
                - seg_2d9c4e1a7b
      responses:
        '200':
          $ref: '#/components/responses/WhatsAppCampaignWrite'
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/WriteScopeRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Unique key for the operation, 1 to 255 characters (a UUID, for example).
        Repeating the same key with the same body within 24 hours returns the
        original response instead of running it again.
      schema:
        type: string
  schemas:
    SetWhatsAppCampaignAudienceRequest:
      type: object
      properties:
        audience:
          type: string
          enum:
            - everyone
            - segments
          description: >-
            everyone: every customer the campaign reaches. segments: the
            customers of the segments in segment_ids.
        segment_ids:
          minItems: 1
          maxItems: 20
          type: array
          items:
            type: string
            pattern: ^seg_[A-Za-z0-9_-]+$
          description: >-
            Segments that get the campaign, up to 20. Customers in more than one
            get it once.
        segment_id:
          type: string
          pattern: ^seg_[A-Za-z0-9_-]+$
          deprecated: true
          description: >-
            Compatibility alias: one segment, the same as segment_ids with that
            id. Send segment_ids or segment_id, not both.
        excluded_segment_ids:
          maxItems: 20
          type: array
          items:
            type: string
            pattern: ^seg_[A-Za-z0-9_-]+$
          description: >-
            Segments left out, up to 20: customers in any of them don't get the
            campaign, even when every customer or an included segment has them.
            A segment both included and excluded is excluded. Omit it or send []
            to exclude nobody.
        operation_id:
          $ref: '#/components/schemas/OperationId'
      required:
        - audience
    OperationId:
      type: string
      minLength: 8
      maxLength: 128
      description: >-
        Optional unique id for this call, such as a UUID. Reuse the same value
        only to retry the same call: the retry returns the first result instead
        of creating again. The same value with a different body is rejected with
        409.
    WhatsAppCampaignWrite:
      type: object
      required:
        - object
        - campaign
        - pending
        - next_step
      properties:
        object:
          type: string
          const: whatsapp_campaign_write
        campaign:
          $ref: '#/components/schemas/TemplateCampaign'
        pending:
          type: array
          items:
            type: string
          description: What the draft still needs before it is sent.
        next_step:
          type: string
          description: What the campaign still needs before it can be sent.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    RateLimitErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          required:
            - retry_after
          properties:
            retry_after:
              type: integer
              minimum: 1
              description: Seconds before retrying.
    TemplateCampaign:
      type: object
      required:
        - object
        - id
        - status
        - channel
        - is_official
        - scheduling_type
        - recipient_type
        - created_at
        - updated_at
      properties:
        object:
          type: string
          const: template_campaign
        id:
          type: string
          pattern: ^tcp_[A-Za-z0-9_-]+$
        name:
          type: string
        status:
          type: string
        channel:
          type: string
          enum:
            - whatsapp
            - sms
        is_official:
          type: boolean
        scheduling_type:
          type: string
        recipient_type:
          type: string
        scheduled_for:
          type: string
          format: date-time
        sent_at:
          type: string
          format: date-time
        templates:
          type: array
          items:
            type: object
            required:
              - id
              - order
              - weight
            properties:
              id:
                type: string
              name:
                type: string
              category:
                type: string
              language:
                type: string
              order:
                type: integer
                minimum: 0
              weight:
                type: integer
                minimum: 1
              status:
                type: string
        metrics:
          type: object
          required:
            - recipients
            - sent
            - delivered
            - read
            - failed
          properties:
            recipients:
              type: integer
              minimum: 0
            sent:
              type: integer
              minimum: 0
            delivered:
              type: integer
              minimum: 0
            read:
              type: integer
              minimum: 0
            failed:
              type: integer
              minimum: 0
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        html_url:
          type: string
          format: uri
    Error:
      type: object
      required:
        - type
        - message
        - request_id
      properties:
        type:
          type: string
          enum:
            - authentication_error
            - conflict
            - internal_error
            - invalid_request
            - not_found
            - permission_denied
            - rate_limited
            - service_unavailable
            - validation_error
        code:
          type: string
          description: >-
            Stable, machine-readable reason within type, such as
            invalid_event_name. Present when the error has a named reason.
        message:
          type: string
        param:
          type: string
          description: >-
            Full path of the offending field, such as customer.email or
            events[3].name.
        suggestion:
          type: string
          description: A value that would be accepted, when there is an obvious one.
        request_id:
          type: string
          pattern: ^req_[a-f0-9]{24}$
  responses:
    WhatsAppCampaignWrite:
      description: Draft updated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WhatsAppCampaignWrite'
    InvalidBody:
      description: >-
        Missing request body, a body that is not a JSON object, or an invalid
        route parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, expired, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: authentication_error
              message: Invalid API key.
              request_id: req_07f6cdc3c20249d6afcd90b4
    WriteScopeRequired:
      description: The API key does not have the write scope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: permission_denied
              code: missing_scope
              message: This API key does not have the required "write" scope.
              param: scope
              request_id: req_07f6cdc3c20249d6afcd90b4
    NotFound:
      description: Resource does not exist or belongs to another organization.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    IdempotencyConflict:
      description: The Idempotency-Key was already used with a different request body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: A parameter failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              type: validation_error
              message: Invalid query parameters.
              param: limit
              request_id: req_07f6cdc3c20249d6afcd90b4
    RateLimited:
      description: Request limit exceeded.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitErrorResponse'
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  headers:
    RetryAfter:
      description: Seconds before retrying.
      schema:
        type: integer
        minimum: 1
    RateLimitLimit:
      description: Total limit for the current window.
      schema:
        type: integer
        example: 600
    RateLimitRemaining:
      description: Requests remaining in the current window.
      schema:
        type: integer
        example: 599
    RateLimitReset:
      description: UTC instant when the current window ends.
      schema:
        type: string
        format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: bvt_live_...
      description: API key created in the organization settings.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.