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

# Create an analysis view

> Manage reusable definitions and their immutable versions.

Required scopes: `metrics:write`.


## OpenAPI

````yaml POST /api/v2/metrics/analysis-views
openapi: 3.1.1
info:
  title: chatobserver public API
  version: '2026-09-09'
  description: >-
    Track AI visibility, manage prompts, inspect collected answers and
    citations, and integrate workspace data with your own tools. Visibility
    endpoints use workspace API keys. Data endpoints use scoped service-account
    keys; spreadsheet client endpoints use authorised client sessions. See the
    authentication guide for each credential type.
  contact:
    name: chatobserver support
    url: https://chatobserver.com/contact
    email: support@chatobserver.com
servers:
  - url: https://app.chatobserver.com
    description: Production API
security:
  - WorkspaceKey: []
  - BearerKey: []
tags:
  - name: Workspace
    description: Validate access and list the workspace project and available platforms.
  - name: Prompts
    description: Create, schedule, organise, activate and retrieve tracked prompts.
  - name: Answers
    description: Retrieve collected AI answers, their analysis and visibility trends.
  - name: Brands
    description: Manage brands and compare their visibility in AI answers.
  - name: Sources and citations
    description: Analyse cited domains, pages and ownership across answers.
  - name: Visitor analytics
    description: Read website visitor and crawler analytics for the workspace.
  - name: Content opportunities
    description: Retrieve content-gap findings and recommendations for tracked prompts.
  - name: Usage
    description: Read workspace consumption and allowance summaries.
  - name: Data connections
    description: Discover authorised connections, source accounts and connector catalogues.
  - name: Data queries
    description: >-
      Create versioned queries, publish definitions and inspect integration
      contracts.
  - name: Data operations
    description: >-
      Execute, validate, cancel and inspect operations and page through result
      rows.
  - name: Data delivery
    description: Manage schedules, transfers, destinations and import workflows.
  - name: Data definitions
    description: Manage reusable definitions and their immutable versions.
  - name: Data webhooks
    description: >-
      Configure event delivery, inspect deliveries, replay events and rotate
      secrets.
  - name: Client authorisation
    description: Authorise spreadsheet clients using a user-approved challenge exchange.
  - name: Spreadsheet clients
    description: >-
      Access document-bound client sessions, queries, schedules, bindings and
      write claims.
  - name: AI visibility audits
    description: Create website visibility audits and retrieve their report links.
  - name: Version 1
    description: Integrate with the version 1 visibility and analytics endpoints.
paths:
  /api/v2/metrics/analysis-views:
    post:
      tags:
        - Data definitions
      summary: Create an analysis view
      description: >-
        Manage reusable definitions and their immutable versions. Required
        scopes: `metrics:write`.
      operationId: postV2MetricsAnalysisViews
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 16
            maxLength: 160
            pattern: ^[A-Za-z0-9:_-]+$
          description: >-
            Unique key for one logical command. Reuse it only when retrying the
            same request and payload.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postV2MetricsAnalysisViewsRequest'
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/postV2MetricsAnalysisViewsResponse200'
        '201':
          description: Created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/postV2MetricsAnalysisViewsResponse201'
        default:
          description: >-
            Request failed. Inspect the error code and request identifier; retry
            only when the failure is retryable.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/DataError'
                  - $ref: '#/components/schemas/ApiError'
components:
  schemas:
    postV2MetricsAnalysisViewsRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 150
        definition:
          type: object
          properties:
            schemaVersion:
              type: number
              const: 1
            source:
              anyOf:
                - type: object
                  properties:
                    kind:
                      type: string
                      const: query
                    queryVersionId:
                      type: string
                    queryId:
                      type: string
                  required:
                    - kind
                    - queryVersionId
                    - queryId
                - type: object
                  properties:
                    kind:
                      type: string
                      const: model
                    modelVersionId:
                      type: string
                  required:
                    - kind
                    - modelVersionId
                - type: object
                  properties:
                    kind:
                      type: string
                      const: table_group
                    tableGroupVersionId:
                      type: string
                    tableId:
                      type: string
                  required:
                    - kind
                    - tableGroupVersionId
                    - tableId
                - type: object
                  properties:
                    kind:
                      type: string
                      const: managed_dataset
                    tableId:
                      anyOf:
                        - type: 'null'
                        - type: string
                    managedDatasetVersionId:
                      type: string
                  required:
                    - kind
                    - tableId
                    - managedDatasetVersionId
                - type: object
                  properties:
                    kind:
                      type: string
                      const: imported_dataset
                    importedDatasetVersionId:
                      type: string
                  required:
                    - kind
                    - importedDatasetVersionId
            fields:
              type: array
              items:
                type: object
                properties:
                  label:
                    type: string
                    minLength: 1
                    maxLength: 160
                  role:
                    enum:
                      - date
                      - metric
                      - dimension
                      - identifier
                      - attribute
                    type: string
                  fieldId:
                    type: string
                    minLength: 1
                    maxLength: 256
                  format:
                    enum:
                      - number
                      - date
                      - automatic
                      - percent
                      - currency
                      - datetime
                      - text
                    type: string
                required:
                  - label
                  - role
                  - fieldId
                  - format
                additionalProperties: false
              minItems: 1
              maxItems: 200
            filters:
              type: array
              items:
                type: object
                properties:
                  values:
                    type: array
                    items:
                      anyOf:
                        - type: 'null'
                        - type: string
                        - type: number
                        - type: boolean
                          const: false
                        - type: boolean
                          const: true
                        - type: array
                          items:
                            $ref: '#/components/schemas/ContractType54286'
                        - type: object
                          properties: {}
                          additionalProperties:
                            $ref: '#/components/schemas/ContractType54286'
                    maxItems: 100
                  fieldId:
                    type: string
                    minLength: 1
                    maxLength: 256
                  operator:
                    enum:
                      - equals
                      - not_equals
                      - contains
                      - greater_than
                      - less_than
                      - in
                      - between
                      - is_null
                      - is_not_null
                    type: string
                required:
                  - values
                  - fieldId
                  - operator
                additionalProperties: false
              maxItems: 100
            comparison:
              type: object
              properties:
                mode:
                  enum:
                    - none
                    - previous_period
                    - previous_year
                    - saved_run
                  type: string
                baselineRunId:
                  anyOf:
                    - type: 'null'
                    - type: string
              required:
                - mode
                - baselineRunId
              additionalProperties: false
            presentation:
              type: object
              properties:
                description:
                  anyOf:
                    - type: 'null'
                    - type: string
                      maxLength: 2000
                title:
                  type: string
                  minLength: 1
                  maxLength: 240
                chartType:
                  enum:
                    - map
                    - table
                    - scorecard
                    - line
                    - bar
                    - area
                    - pie
                    - scatter
                    - pivot
                  type: string
                theme:
                  enum:
                    - workspace
                    - editorial
                    - executive
                    - contrast
                    - minimal
                  type: string
                showLegend:
                  anyOf:
                    - type: boolean
                      const: false
                    - type: boolean
                      const: true
                showLabels:
                  anyOf:
                    - type: boolean
                      const: false
                    - type: boolean
                      const: true
              required:
                - description
                - title
                - chartType
                - theme
                - showLegend
                - showLabels
              additionalProperties: false
            refresh:
              type: object
              properties:
                mode:
                  enum:
                    - manual
                    - latest_saved_result
                  type: string
                artifactId:
                  anyOf:
                    - type: 'null'
                    - type: string
              required:
                - mode
                - artifactId
              additionalProperties: false
          required:
            - schemaVersion
            - source
            - fields
            - filters
            - comparison
            - presentation
            - refresh
          additionalProperties: false
        description:
          anyOf:
            - type: 'null'
            - type: string
              maxLength: 4000
          default: null
        visibility:
          type: string
          const: workspace
          description: Service-account resources must be visible to the workspace.
        publish:
          anyOf:
            - type: boolean
              const: false
            - type: boolean
              const: true
          default: false
      required:
        - name
        - definition
      additionalProperties: false
    postV2MetricsAnalysisViewsResponse200:
      type: object
      properties:
        data:
          type: object
          properties:
            actorId:
              type: string
            analysisViewId:
              type: string
            versionId:
              type: string
            versionNumber:
              type: number
            versionStatus:
              enum:
                - draft
                - published
                - superseded
              type: string
            canonicalHash:
              type: string
          required:
            - actorId
            - analysisViewId
            - versionId
            - versionNumber
            - versionStatus
            - canonicalHash
        replayed:
          anyOf:
            - type: boolean
              const: false
            - type: boolean
              const: true
      required:
        - data
        - replayed
    postV2MetricsAnalysisViewsResponse201:
      type: object
      properties:
        data:
          type: object
          properties:
            actorId:
              type: string
            analysisViewId:
              type: string
            versionId:
              type: string
            versionNumber:
              type: number
            versionStatus:
              enum:
                - draft
                - published
                - superseded
              type: string
            canonicalHash:
              type: string
          required:
            - actorId
            - analysisViewId
            - versionId
            - versionNumber
            - versionStatus
            - canonicalHash
        replayed:
          anyOf:
            - type: boolean
              const: false
            - type: boolean
              const: true
      required:
        - data
        - replayed
    DataError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              enum:
                - internal
                - validation_failed
                - authentication_required
                - forbidden
                - not_found
                - conflict
                - precondition_failed
                - idempotency_conflict
                - capability_unavailable
                - connection_unavailable
                - reauthentication_required
                - provider_rate_limited
                - workspace_limit_exceeded
                - result_expired
                - operation_failed
                - temporarily_unavailable
              type: string
            fieldPath:
              type: array
              items:
                anyOf:
                  - type: string
                  - type: number
            parameters:
              type: object
              properties: {}
              additionalProperties:
                anyOf:
                  - type: 'null'
                  - type: string
                  - type: number
                  - type: boolean
                    const: false
                  - type: boolean
                    const: true
            repairActions:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 96
              maxItems: 10
            requestId:
              type: string
              minLength: 1
              maxLength: 160
            retryable:
              anyOf:
                - type: boolean
                  const: false
                - type: boolean
                  const: true
            retryAfterSeconds:
              anyOf:
                - type: 'null'
                - type: integer
                  exclusiveMinimum: 0
          required:
            - code
            - fieldPath
            - parameters
            - repairActions
            - requestId
            - retryable
            - retryAfterSeconds
          additionalProperties: false
      required:
        - error
      additionalProperties: false
    ApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
          required:
            - code
            - message
        requestId:
          type: string
      required:
        - error
        - requestId
    ContractType54286:
      anyOf:
        - type: 'null'
        - type: string
        - type: number
        - type: boolean
          const: false
        - type: boolean
          const: true
        - type: array
          items:
            $ref: '#/components/schemas/ContractType54286'
        - type: object
          properties: {}
          additionalProperties:
            $ref: '#/components/schemas/ContractType54286'
  securitySchemes:
    WorkspaceKey:
      type: apiKey
      in: header
      name: x-chatobserver-key
      description: >-
        A workspace API key. Data endpoints require a service-account key with
        the specified scopes.
    BearerKey:
      type: http
      scheme: bearer
      description: The workspace or service-account API key as a bearer token.

````