contentstack Variables API

Project variables are reusable key-value pairs that can be referenced across multiple automations within a project.

OpenAPI Specification

contentstack-variables-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Contentstack Analytics Accounts Variables 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: Variables
  description: Project variables are reusable key-value pairs that can be referenced across multiple automations within a project.
paths:
  /v1/organizations/{organization_uid}/projects/{project_uid}/variables:
    get:
      operationId: getAllVariables
      summary: Get all variables
      description: Retrieves all project variables defined for the automation project. Variables are reusable key-value pairs that can be referenced across automation configurations.
      tags:
      - Variables
      parameters:
      - $ref: '#/components/parameters/OrganizationUid'
      - $ref: '#/components/parameters/ProjectUid'
      responses:
        '200':
          description: A list of project variables.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VariableList'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createVariable
      summary: Create a variable
      description: Creates a new project variable that can be referenced in automation configurations. Variables can store API keys, URLs, or other configuration values that are used across multiple automations.
      tags:
      - Variables
      parameters:
      - $ref: '#/components/parameters/OrganizationUid'
      - $ref: '#/components/parameters/ProjectUid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVariableRequest'
      responses:
        '201':
          description: The newly created variable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Variable'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    ProjectUid:
      name: project_uid
      in: path
      required: true
      description: The unique identifier of the automation project.
      schema:
        type: string
    OrganizationUid:
      name: organization_uid
      in: path
      required: true
      description: The unique identifier of the organization.
      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'
  schemas:
    Variable:
      type: object
      description: A reusable configuration variable for use across automations.
      properties:
        uid:
          type: string
          description: Unique identifier of the variable.
        name:
          type: string
          description: Display name of the variable.
        key:
          type: string
          description: Machine-readable key for referencing the variable in automations.
        value:
          type: string
          description: The value stored in the variable. Sensitive values may be masked.
        is_secret:
          type: boolean
          description: Indicates whether the variable value is treated as a secret.
    CreateVariableRequest:
      type: object
      description: Parameters for creating a project variable.
      required:
      - name
      - key
      - value
      properties:
        name:
          type: string
          description: Display name for the variable.
        key:
          type: string
          description: Machine-readable key for the variable.
        value:
          type: string
          description: Value to store in the variable.
        is_secret:
          type: boolean
          description: Set to true to mark the variable as a secret.
          default: false
    Error:
      type: object
      description: Standard error response.
      properties:
        message:
          type: string
          description: Human-readable description of the error.
        error_code:
          type: integer
          description: Numeric error code.
    VariableList:
      type: object
      description: A list of project variables.
      properties:
        data:
          type: array
          description: Array of variable objects.
          items:
            $ref: '#/components/schemas/Variable'
  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