contentstack Attributes API

Attributes represent individual user data characteristics such as age, location, or browsing history used to define audience segments.

OpenAPI Specification

contentstack-attributes-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Contentstack Analytics Accounts Attributes 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: Attributes
  description: Attributes represent individual user data characteristics such as age, location, or browsing history used to define audience segments.
paths:
  /attributes:
    get:
      operationId: getAllAttributes
      summary: Get all attributes
      description: Retrieves all user attribute definitions configured in the Personalize project. Attributes are used to build audience segment rules.
      tags:
      - Attributes
      parameters:
      - $ref: '#/components/parameters/ProjectUid'
      responses:
        '200':
          description: A list of all attributes in the project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttributeList'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createAttribute
      summary: Create an attribute
      description: Creates a new user attribute definition in the Personalize project. Attributes can be of various types including string, number, boolean, and date, and are used to build audience segment rules.
      tags:
      - Attributes
      parameters:
      - $ref: '#/components/parameters/ProjectUid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAttributeRequest'
      responses:
        '201':
          description: The newly created attribute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Attribute'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /attributes/{id}:
    put:
      operationId: updateAttribute
      summary: Update an attribute
      description: Updates the configuration of an existing attribute in the Personalize project including its name, key, and data type.
      tags:
      - Attributes
      parameters:
      - $ref: '#/components/parameters/AttributeId'
      - $ref: '#/components/parameters/ProjectUid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAttributeRequest'
      responses:
        '200':
          description: The updated attribute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Attribute'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: deleteAttribute
      summary: Delete an attribute
      description: Permanently deletes an attribute from the Personalize project. Attributes referenced in audience rules cannot be deleted until those references are removed.
      tags:
      - Attributes
      parameters:
      - $ref: '#/components/parameters/AttributeId'
      - $ref: '#/components/parameters/ProjectUid'
      responses:
        '200':
          description: Attribute deleted successfully.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    Attribute:
      type: object
      description: A user attribute definition used in audience segment rules.
      properties:
        uid:
          type: string
          description: Unique identifier of the attribute.
        name:
          type: string
          description: Display name of the attribute.
        key:
          type: string
          description: Machine-readable key used to reference this attribute in rules and SDKs.
        data_type:
          type: string
          description: Data type of the attribute.
          enum:
          - string
          - number
          - boolean
          - date
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the attribute was created.
    CreateAttributeRequest:
      type: object
      description: Parameters for creating or updating an attribute.
      required:
      - name
      - key
      - data_type
      properties:
        name:
          type: string
          description: Display name for the attribute.
        key:
          type: string
          description: Machine-readable key for the attribute.
        data_type:
          type: string
          description: Data type of the attribute.
          enum:
          - string
          - number
          - boolean
          - date
    AttributeList:
      type: object
      description: A list of user attribute definitions.
      properties:
        data:
          type: array
          description: Array of attribute objects.
          items:
            $ref: '#/components/schemas/Attribute'
    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.
  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'
  parameters:
    ProjectUid:
      name: x-project-uid
      in: header
      required: true
      description: The UID of the Contentstack Personalize project.
      schema:
        type: string
    AttributeId:
      name: id
      in: path
      required: true
      description: The unique identifier of the attribute.
      schema:
        type: string
  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