contentstack Audiences API

Audiences are defined segments of users grouped by demographic, behavioral, or other attribute-based criteria for targeted content experiences.

OpenAPI Specification

contentstack-audiences-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Contentstack Analytics Accounts Audiences API
  description: The Contentstack Analytics API provides access to usage and performance metrics for CMS, Launch, and Automate products within a Contentstack organization. Developers can retrieve analytics data programmatically to build custom dashboards, monitor content delivery performance, and track platform usage against plan limits. The API returns structured data suitable for aggregation with external analytics and business intelligence tools. Access is restricted to organization Owners and Admins. Requests use async job-based processing where initial POST calls queue the job and a subsequent GET call retrieves the results.
  version: v2
  contact:
    name: Contentstack Support
    url: https://www.contentstack.com/contact
  termsOfService: https://www.contentstack.com/legal/terms-of-service
servers:
- url: https://api.contentstack.io
  description: AWS North America Production Server
- url: https://eu-api.contentstack.com
  description: AWS Europe Production Server
- url: https://au-api.contentstack.com
  description: AWS Australia Production Server
security:
- bearerAuth: []
- authtokenAuth: []
tags:
- name: Audiences
  description: Audiences are defined segments of users grouped by demographic, behavioral, or other attribute-based criteria for targeted content experiences.
paths:
  /audiences:
    get:
      operationId: getAllAudiences
      summary: Get all audiences
      description: Retrieves all audience segment definitions in the Personalize project. Audiences define the user groups that experiences are targeted to.
      tags:
      - Audiences
      parameters:
      - $ref: '#/components/parameters/ProjectUid'
      responses:
        '200':
          description: A list of all audiences in the project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudienceList'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createAudience
      summary: Create an audience
      description: Creates a new audience segment in the Personalize project based on attribute conditions and behavioral rules.
      tags:
      - Audiences
      parameters:
      - $ref: '#/components/parameters/ProjectUid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAudienceRequest'
      responses:
        '201':
          description: The newly created audience.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Audience'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /audiences/{id}:
    put:
      operationId: updateAudience
      summary: Update an audience
      description: Updates the rules and configuration of an existing audience segment.
      tags:
      - Audiences
      parameters:
      - $ref: '#/components/parameters/AudienceId'
      - $ref: '#/components/parameters/ProjectUid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAudienceRequest'
      responses:
        '200':
          description: The updated audience.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Audience'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: deleteAudience
      summary: Delete an audience
      description: Permanently deletes an audience from the Personalize project. Audiences referenced in active experiences cannot be deleted.
      tags:
      - Audiences
      parameters:
      - $ref: '#/components/parameters/AudienceId'
      - $ref: '#/components/parameters/ProjectUid'
      responses:
        '200':
          description: Audience deleted successfully.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    AudienceId:
      name: id
      in: path
      required: true
      description: The unique identifier of the audience.
      schema:
        type: string
    ProjectUid:
      name: x-project-uid
      in: header
      required: true
      description: The UID of the Contentstack Personalize project.
      schema:
        type: string
  responses:
    Unauthorized:
      description: Authentication credentials are missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: The request is malformed or contains invalid parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    CreateAudienceRequest:
      type: object
      description: Parameters for creating or updating an audience.
      required:
      - name
      properties:
        name:
          type: string
          description: Display name for the audience.
        description:
          type: string
          description: Description of the audience targeting criteria.
        rules:
          type: object
          description: Logical conditions for audience membership.
    Audience:
      type: object
      description: An audience segment based on attribute rules and user behaviors.
      properties:
        uid:
          type: string
          description: Unique identifier of the audience.
        name:
          type: string
          description: Display name of the audience.
        description:
          type: string
          description: Description of the audience and its targeting criteria.
        rules:
          type: object
          description: Logical conditions that determine audience membership.
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the audience was created.
    AudienceList:
      type: object
      description: A list of audience segment definitions.
      properties:
        data:
          type: array
          description: Array of audience objects.
          items:
            $ref: '#/components/schemas/Audience'
    Error:
      type: object
      description: Standard error response.
      properties:
        message:
          type: string
          description: Human-readable description of the error.
        status:
          type: integer
          description: HTTP status code.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 Bearer token (M2M) with analytics access.
    authtokenAuth:
      type: apiKey
      in: header
      name: authtoken
      description: Contentstack user authtoken. Only organization Owners and Admins can access analytics.
externalDocs:
  description: Contentstack Analytics API Documentation
  url: https://www.contentstack.com/docs/developers/apis/analytics-api