> ## 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 a query

> Access document-bound client sessions, queries, schedules, bindings and write claims.

Required scopes: `client:write`.


## OpenAPI

````yaml POST /api/v2/metrics/client/queries
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/client/queries:
    post:
      tags:
        - Spreadsheet clients
      summary: Create a query
      description: >-
        Access document-bound client sessions, queries, schedules, bindings and
        write claims. Required scopes: `client:write`.
      operationId: postV2MetricsClientQueries
      parameters:
        - name: x-metrics-client-audience
          in: header
          required: true
          schema:
            enum:
              - chatobserver-metrics-sheets
              - chatobserver-metrics-excel
            type: string
          description: The audience bound to the authorised client session.
        - name: x-metrics-document-reference
          in: header
          required: true
          schema:
            type: string
            pattern: ^[a-f0-9]{64}$
          description: The document reference hash bound to the client session.
        - 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/postV2MetricsClientQueriesRequest'
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/postV2MetricsClientQueriesResponse200'
        '201':
          description: Created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/postV2MetricsClientQueriesResponse201'
        default:
          description: >-
            Request failed. Inspect the error code and request identifier; retry
            only when the failure is retryable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataError'
      security:
        - ClientSession: []
components:
  schemas:
    postV2MetricsClientQueriesRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 150
        definition:
          type: object
          properties:
            sort:
              type: array
              items:
                type: object
                properties:
                  fieldId:
                    type: string
                    minLength: 1
                    maxLength: 256
                  direction:
                    enum:
                      - ascending
                      - descending
                    type: string
                  nulls:
                    enum:
                      - first
                      - last
                    type: string
                required:
                  - fieldId
                  - direction
                  - nulls
                additionalProperties: false
              maxItems: 20
            filter:
              anyOf:
                - type: 'null'
                - type: object
                  properties:
                    kind:
                      type: string
                      const: condition
                    fieldId:
                      type: string
                    operator:
                      enum:
                        - equals
                        - not_equals
                        - contains
                        - greater_than
                        - less_than
                        - in
                        - between
                        - is_null
                        - is_not_null
                        - not_in
                        - not_contains
                        - starts_with
                        - ends_with
                        - regex
                        - not_regex
                        - greater_than_or_equal
                        - less_than_or_equal
                      type: string
                    value:
                      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'
                    execution:
                      enum:
                        - pushdown_required
                        - pushdown_preferred
                        - platform_allowed
                      type: string
                  required:
                    - kind
                    - fieldId
                    - operator
                    - value
                    - execution
                - type: object
                  properties:
                    kind:
                      type: string
                      const: group
                    conjunction:
                      enum:
                        - and
                        - or
                      type: string
                    children:
                      type: array
                      items:
                        anyOf:
                          - type: object
                            properties:
                              kind:
                                type: string
                                const: condition
                              fieldId:
                                type: string
                              operator:
                                enum:
                                  - equals
                                  - not_equals
                                  - contains
                                  - greater_than
                                  - less_than
                                  - in
                                  - between
                                  - is_null
                                  - is_not_null
                                  - not_in
                                  - not_contains
                                  - starts_with
                                  - ends_with
                                  - regex
                                  - not_regex
                                  - greater_than_or_equal
                                  - less_than_or_equal
                                type: string
                              value:
                                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'
                              execution:
                                enum:
                                  - pushdown_required
                                  - pushdown_preferred
                                  - platform_allowed
                                type: string
                            required:
                              - kind
                              - fieldId
                              - operator
                              - value
                              - execution
                          - $ref: '#/components/schemas/ContractType94867'
                  required:
                    - kind
                    - conjunction
                    - children
            connectorKey:
              type: string
              minLength: 1
              maxLength: 96
              pattern: ^[a-z0-9]+(?:_[a-z0-9]+)*$
            schemaVersion:
              type: number
              const: 2
            currency:
              anyOf:
                - type: 'null'
                - type: string
                  minLength: 3
                  maxLength: 3
            fields:
              type: array
              items:
                type: object
                properties:
                  alias:
                    anyOf:
                      - type: 'null'
                      - type: string
                        minLength: 1
                        maxLength: 160
                  role:
                    enum:
                      - metric
                      - dimension
                      - identifier
                      - attribute
                    type: string
                  fieldId:
                    type: string
                    minLength: 1
                    maxLength: 256
                  aggregation:
                    anyOf:
                      - type: 'null'
                      - type: string
                        const: minimum
                      - type: string
                        const: maximum
                      - type: string
                        const: count
                      - type: string
                        const: none
                      - type: string
                        const: sum
                      - type: string
                        const: average
                      - type: string
                        const: count_distinct
                      - type: string
                        const: provider_default
                  outputPosition:
                    type: integer
                    minimum: 0
                required:
                  - alias
                  - role
                  - fieldId
                  - aggregation
                  - outputPosition
                additionalProperties: false
              minItems: 1
              maxItems: 250
            comparison:
              anyOf:
                - type: 'null'
                - type: object
                  properties:
                    mode:
                      enum:
                        - custom
                        - previous_period
                        - previous_year
                      type: string
                    enabled:
                      anyOf:
                        - type: boolean
                          const: false
                        - type: boolean
                          const: true
                    customRange:
                      anyOf:
                        - type: 'null'
                        - type: object
                          properties:
                            kind:
                              type: string
                              const: absolute
                            start:
                              type: string
                            end:
                              type: string
                          required:
                            - kind
                            - start
                            - end
                        - type: object
                          properties:
                            kind:
                              type: string
                              const: relative
                            count:
                              type: number
                            unit:
                              enum:
                                - day
                                - week
                                - month
                                - quarter
                                - year
                              type: string
                            offset:
                              type: number
                            includeCurrent:
                              anyOf:
                                - type: boolean
                                  const: false
                                - type: boolean
                                  const: true
                          required:
                            - kind
                            - count
                            - unit
                        - type: object
                          properties:
                            kind:
                              type: string
                              const: rolling
                            count:
                              type: number
                            unit:
                              enum:
                                - hour
                                - day
                                - week
                                - month
                              type: string
                            lag:
                              type: number
                          required:
                            - kind
                            - count
                            - unit
                        - type: object
                          properties:
                            kind:
                              type: string
                              const: incremental
                            unit:
                              enum:
                                - hour
                                - day
                              type: string
                            cursorFieldId:
                              type: string
                            initialStart:
                              type: string
                            lookbackUnits:
                              type: number
                          required:
                            - kind
                            - unit
                            - cursorFieldId
                            - initialStart
                            - lookbackUnits
                  required:
                    - mode
                    - enabled
                    - customRange
                  additionalProperties: false
            pivot:
              anyOf:
                - type: 'null'
                - type: object
                  properties:
                    rowFieldIds:
                      type: array
                      items:
                        type: string
                        minLength: 1
                        maxLength: 256
                      minItems: 1
                      maxItems: 25
                    columnFieldIds:
                      type: array
                      items:
                        type: string
                        minLength: 1
                        maxLength: 256
                      minItems: 1
                      maxItems: 10
                    valueFieldIds:
                      type: array
                      items:
                        type: string
                        minLength: 1
                        maxLength: 256
                      minItems: 1
                      maxItems: 25
                    includeRowTotals:
                      anyOf:
                        - type: boolean
                          const: false
                        - type: boolean
                          const: true
                    includeColumnTotals:
                      anyOf:
                        - type: boolean
                          const: false
                        - type: boolean
                          const: true
                    emptyValue:
                      enum:
                        - 'null'
                        - zero
                      type: string
                  required:
                    - rowFieldIds
                    - columnFieldIds
                    - valueFieldIds
                    - includeRowTotals
                    - includeColumnTotals
                    - emptyValue
                  additionalProperties: false
            queryType:
              type: string
              minLength: 1
              maxLength: 96
            timeZone:
              type: string
              minLength: 1
              maxLength: 128
            pagination:
              type: object
              properties:
                pageSize:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 100000
                maximumPages:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 100000
              required:
                - pageSize
                - maximumPages
              additionalProperties: false
            locale:
              type: string
              minLength: 2
              maxLength: 35
            accountSelector:
              anyOf:
                - type: object
                  properties:
                    kind:
                      type: string
                      const: accounts
                    sourceAccountIds:
                      type: array
                      items:
                        type: string
                  required:
                    - kind
                    - sourceAccountIds
                - type: object
                  properties:
                    kind:
                      type: string
                      const: account_tags
                    accountTagIds:
                      type: array
                      items:
                        type: string
                  required:
                    - kind
                    - accountTagIds
            customFieldVersionIds:
              type: array
              items:
                type: string
              maxItems: 100
            dateRange:
              anyOf:
                - type: object
                  properties:
                    kind:
                      type: string
                      const: absolute
                    start:
                      type: string
                    end:
                      type: string
                  required:
                    - kind
                    - start
                    - end
                - type: object
                  properties:
                    kind:
                      type: string
                      const: relative
                    count:
                      type: number
                    unit:
                      enum:
                        - day
                        - week
                        - month
                        - quarter
                        - year
                      type: string
                    offset:
                      type: number
                    includeCurrent:
                      anyOf:
                        - type: boolean
                          const: false
                        - type: boolean
                          const: true
                  required:
                    - kind
                    - count
                    - unit
                - type: object
                  properties:
                    kind:
                      type: string
                      const: rolling
                    count:
                      type: number
                    unit:
                      enum:
                        - hour
                        - day
                        - week
                        - month
                      type: string
                    lag:
                      type: number
                  required:
                    - kind
                    - count
                    - unit
                - type: object
                  properties:
                    kind:
                      type: string
                      const: incremental
                    unit:
                      enum:
                        - hour
                        - day
                      type: string
                    cursorFieldId:
                      type: string
                    initialStart:
                      type: string
                    lookbackUnits:
                      type: number
                  required:
                    - kind
                    - unit
                    - cursorFieldId
                    - initialStart
                    - lookbackUnits
            rowLimit:
              type: integer
              exclusiveMinimum: 0
              maximum: 100000000
            sample:
              type: object
              properties:
                enabled:
                  anyOf:
                    - type: boolean
                      const: false
                    - type: boolean
                      const: true
                maximumRows:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 1000000
              required:
                - enabled
                - maximumRows
              additionalProperties: false
            connectorOptions:
              type: object
              properties: {}
              additionalProperties: {}
            requiredCapabilities:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 128
              maxItems: 100
            parameters:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    minLength: 1
                    maxLength: 160
                  id:
                    type: string
                    minLength: 1
                    maxLength: 160
                  description:
                    anyOf:
                      - type: 'null'
                      - type: string
                        maxLength: 1000
                  target:
                    anyOf:
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: date_range_start
                        required:
                          - kind
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: date_range_end
                        required:
                          - kind
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: filter_value
                          fieldId:
                            type: string
                          occurrence:
                            type: number
                        required:
                          - kind
                          - fieldId
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: connector_option
                          optionId:
                            type: string
                        required:
                          - kind
                          - optionId
                      - type: object
                        properties:
                          kind:
                            type: string
                            const: row_limit
                        required:
                          - kind
                  defaultValue:
                    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'
                  valueType:
                    enum:
                      - string
                      - number
                      - boolean
                      - date
                      - datetime
                    type: string
                  required:
                    anyOf:
                      - type: boolean
                        const: false
                      - type: boolean
                        const: true
                  allowViewerOverride:
                    anyOf:
                      - type: boolean
                        const: false
                      - type: boolean
                        const: true
                required:
                  - name
                  - id
                  - description
                  - target
                  - defaultValue
                  - valueType
                  - required
                  - allowViewerOverride
                additionalProperties: false
              maxItems: 100
              default: []
            includeSourceAccount:
              anyOf:
                - type: boolean
                  const: false
                - type: boolean
                  const: true
              default: true
          required:
            - sort
            - filter
            - connectorKey
            - schemaVersion
            - currency
            - fields
            - comparison
            - pivot
            - queryType
            - timeZone
            - pagination
            - locale
            - accountSelector
            - customFieldVersionIds
            - dateRange
            - rowLimit
            - sample
            - connectorOptions
            - requiredCapabilities
          additionalProperties: false
        catalogSnapshotIds:
          type: array
          items:
            type: string
            format: uuid
          minItems: 1
          maxItems: 500
        description:
          anyOf:
            - type: 'null'
            - type: string
              maxLength: 4000
          default: null
        visibility:
          enum:
            - private
            - workspace
            - restricted
          default: private
          type: string
        publish:
          anyOf:
            - type: boolean
              const: false
            - type: boolean
              const: true
          default: false
      required:
        - name
        - definition
        - catalogSnapshotIds
      additionalProperties: false
    postV2MetricsClientQueriesResponse200:
      type: object
      properties:
        data:
          type: object
          properties:
            actorId:
              type: string
            canonicalHash:
              type: string
            queryId:
              type: string
            versionId:
              type: string
            versionNumber:
              type: number
            versionStatus:
              enum:
                - draft
                - published
                - superseded
              type: string
          required:
            - actorId
            - canonicalHash
            - queryId
            - versionId
            - versionNumber
            - versionStatus
        replayed:
          anyOf:
            - type: boolean
              const: false
            - type: boolean
              const: true
      required:
        - data
        - replayed
    postV2MetricsClientQueriesResponse201:
      type: object
      properties:
        data:
          type: object
          properties:
            actorId:
              type: string
            canonicalHash:
              type: string
            queryId:
              type: string
            versionId:
              type: string
            versionNumber:
              type: number
            versionStatus:
              enum:
                - draft
                - published
                - superseded
              type: string
          required:
            - actorId
            - canonicalHash
            - queryId
            - versionId
            - versionNumber
            - versionStatus
        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
    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'
    ContractType94867:
      type: object
      properties:
        kind:
          type: string
          const: group
        conjunction:
          enum:
            - and
            - or
          type: string
        children:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  kind:
                    type: string
                    const: condition
                  fieldId:
                    type: string
                  operator:
                    enum:
                      - equals
                      - not_equals
                      - contains
                      - greater_than
                      - less_than
                      - in
                      - between
                      - is_null
                      - is_not_null
                      - not_in
                      - not_contains
                      - starts_with
                      - ends_with
                      - regex
                      - not_regex
                      - greater_than_or_equal
                      - less_than_or_equal
                    type: string
                  value:
                    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'
                  execution:
                    enum:
                      - pushdown_required
                      - pushdown_preferred
                      - platform_allowed
                    type: string
                required:
                  - kind
                  - fieldId
                  - operator
                  - value
                  - execution
              - $ref: '#/components/schemas/ContractType94867'
      required:
        - kind
        - conjunction
        - children
  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.
    ClientSession:
      type: http
      scheme: bearer
      description: >-
        A client session token obtained through the client authorisation
        challenge flow.

````