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

# Run a dimensional analytics query for a product

> Query one analytics metric (sov, citations, traffic, sentiment) grouped by at most one dimension, scoped by filters and a date window. Returns flat rows plus column metadata for generic rendering.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/analytics/explore
openapi: 3.1.0
info:
  title: The Prompting Company API
  version: 0.1.0
  description: >-
    Machine-readable contract for The Prompting Company organization-scoped API
    routes.
  contact:
    name: The Prompting Company
    url: https://promptingcompany.com/support
    email: support@promptingcompany.com
  license:
    name: Proprietary
    url: https://promptingcompany.com/terms
  termsOfService: https://promptingcompany.com/terms
servers:
  - url: https://app.promptingco.com
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags:
  - name: Visibility & Mentions
  - name: Knowledge
  - name: Content
  - name: Simulations
  - name: Apps & Publishing
  - name: Products
  - name: Service Status
paths:
  /api/v1/analytics/explore:
    post:
      tags:
        - Visibility & Mentions
      summary: Run a dimensional analytics query for a product
      description: >-
        Query one analytics metric (sov, citations, traffic, sentiment) grouped
        by at most one dimension, scoped by filters and a date window. Returns
        flat rows plus column metadata for generic rendering.
      operationId: postAnalyticsExplore
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                productId:
                  type: string
                  minLength: 1
                  description: Product ID to scope the query to.
                metric:
                  type: string
                  enum:
                    - sov
                    - citations
                    - traffic
                    - sentiment
                  description: >-
                    Metric to query. Ungrouped and date-dimension SoV use
                    trailing-30-day snapshots rather than additive period
                    totals.
                dimensions:
                  type: array
                  items:
                    type: string
                    minLength: 1
                  maxItems: 1
                  description: >-
                    At most one dimension to group by. Omit or pass [] for a
                    summary. For metric=sov when dimensions are omitted or
                    dimensions=[date], sov, mentions, and runs are
                    trailing-30-day snapshot values. Omit dimensions to return
                    only the latest available snapshot in the requested window,
                    or use dimensions=[date] to return one snapshot per date.
                    The window selects eligible snapshot dates; it is not a
                    period aggregation. Do not sum mentions or runs across dated
                    rows because their rolling windows overlap. Capabilities —
                    sov: dimensions [date, prompt, topic, engine, competitor],
                    filters [viewId, promptId, topicId, engine, regionId],
                    sortBy [sov, mentions, runs, label]; citations: dimensions
                    [source, category, type, author, model, date], filters
                    [viewId, topicId, regionId, category, contentType, model,
                    author, searchTerm, productMentioned], sortBy [citations,
                    mentions]; traffic: dimensions [date, page, model,
                    category], filters [trafficType, provider, category];
                    sentiment: dimensions [prompt], filters [viewId, promptId,
                    topicId].
                filters:
                  type: object
                  properties:
                    viewId:
                      type: string
                      minLength: 1
                      description: >-
                        Scope to a saved view's prompts (sov, citations,
                        sentiment).
                    promptId:
                      type: string
                      minLength: 1
                      description: >-
                        Scope to a single prompt (sov date drilldown,
                        sentiment).
                    topicId:
                      type: string
                      minLength: 1
                      description: >-
                        Scope to a single topic/category (sov, citations,
                        sentiment). With metric=sov and dimensions=[competitor]
                        this returns the industry ranking within that topic.
                    engine:
                      type: string
                      minLength: 1
                      description: Answer engine filter for sov, e.g. chatgpt or sonar.
                    regionId:
                      type: string
                      minLength: 1
                      description: Region scope.
                    category:
                      type: string
                      minLength: 1
                      description: Source category (citations) or page category (traffic).
                    contentType:
                      type: string
                      minLength: 1
                      description: Citations content type, e.g. article or youtube.
                    model:
                      type: string
                      minLength: 1
                      description: 'Citations: answer engine/model that cited the source.'
                    author:
                      type: string
                      minLength: 1
                      description: 'Citations: author name filter.'
                    searchTerm:
                      type: string
                      minLength: 1
                      description: 'Citations: case-insensitive URL/title search.'
                    productMentioned:
                      type: string
                      enum:
                        - mentioned
                        - not_mentioned
                      description: >-
                        Citations: only sources where the product was (not)
                        mentioned.
                    trafficType:
                      type: string
                      enum:
                        - ai
                        - human
                      description: 'Traffic: ai (default) or human.'
                    provider:
                      type: string
                      minLength: 1
                      description: 'Traffic: AI provider/bot filter, e.g. openai.'
                  additionalProperties: false
                window:
                  type: object
                  properties:
                    start:
                      type: string
                      description: ISO date (YYYY-MM-DD).
                    end:
                      type: string
                      description: ISO date (YYYY-MM-DD).
                  description: >-
                    Date window; both start and end or neither. Defaults to the
                    last 30 days. For metric=sov when dimensions are omitted or
                    dimensions=[date], sov, mentions, and runs are
                    trailing-30-day snapshot values. Omit dimensions to return
                    only the latest available snapshot in the requested window,
                    or use dimensions=[date] to return one snapshot per date.
                    The window selects eligible snapshot dates; it is not a
                    period aggregation. Do not sum mentions or runs across dated
                    rows because their rolling windows overlap.
                granularity:
                  type: string
                  enum:
                    - day
                    - week
                    - month
                  description: >-
                    Time bucket for metric=traffic with the date dimension.
                    Defaults to day.
                compare:
                  type: string
                  enum:
                    - wow
                  description: Week-over-week comparison, metric=sentiment only.
                page:
                  type: integer
                  minimum: 1
                pageSize:
                  type: integer
                  minimum: 1
                  maximum: 100
                sortBy:
                  type: string
                  minLength: 1
                sortDirection:
                  type: string
                  enum:
                    - asc
                    - desc
              required:
                - productId
                - metric
              additionalProperties: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      metric:
                        type: string
                        enum:
                          - sov
                          - citations
                          - traffic
                          - sentiment
                      dimensions:
                        type: array
                        items:
                          type: string
                      scope:
                        type: object
                        properties:
                          product:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                              slug:
                                type: string
                            required:
                              - id
                              - name
                              - slug
                        required:
                          - product
                      window:
                        type: object
                        properties:
                          start:
                            type: string
                          end:
                            type: string
                        required:
                          - start
                          - end
                      granularity:
                        type: string
                        enum:
                          - day
                          - week
                          - month
                      compare:
                        type: string
                        enum:
                          - wow
                      columns:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                            label:
                              type: string
                            kind:
                              type: string
                              enum:
                                - dimension
                                - metric
                            type:
                              type: string
                              enum:
                                - string
                                - number
                                - date
                          required:
                            - key
                            - label
                            - kind
                            - type
                      rows:
                        type: array
                        items:
                          type: object
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: number
                              - type: boolean
                              - type: 'null'
                      pagination:
                        type: object
                        properties:
                          page:
                            type: integer
                          pageSize:
                            type: integer
                          total:
                            type: integer
                          totalPages:
                            type: integer
                        required:
                          - page
                          - pageSize
                          - total
                          - totalPages
                      totals:
                        type: object
                        additionalProperties:
                          type: number
                    required:
                      - metric
                      - dimensions
                      - scope
                      - window
                      - columns
                      - rows
                required:
                  - ok
                  - data
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                  code:
                    type: string
                  message:
                    type: string
                  details: {}
                required:
                  - ok
                  - code
                  - message
      security:
        - apiKeyAuth: []
        - bearerAuth: []
        - cookieAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Organization-scoped API key. Available scopes:

        - content:read: Read site pages, markdown content, and llms.txt files

        - content:write: Create, update, and delete site pages and content

        - prompts:read: Read prompts, topics, and prompt analysis results

        - prompts:write: Create, update, archive prompts

        - simulations:read: Read agent-simulation tasks, runs, environments, and
        analytics

        - simulations:write: Create and trigger simulation runs

        - logs:read: Read AI-traffic logs and request-level audit events

        - analytics:read: Read analytics aggregates (rankings, mentions,
        sources, SOV)

        - analytics:write: Write events to analytics

        - products:read: Read product metadata and competitor data

        - products:write: Update product settings and competitor lists
      x-scopes:
        content:read: Read site pages, markdown content, and llms.txt files
        content:write: Create, update, and delete site pages and content
        prompts:read: Read prompts, topics, and prompt analysis results
        prompts:write: Create, update, archive prompts
        simulations:read: Read agent-simulation tasks, runs, environments, and analytics
        simulations:write: Create and trigger simulation runs
        logs:read: Read AI-traffic logs and request-level audit events
        analytics:read: Read analytics aggregates (rankings, mentions, sources, SOV)
        analytics:write: Write events to analytics
        products:read: Read product metadata and competitor data
        products:write: Update product settings and competitor lists
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Bearer session or OAuth access token. Available OAuth scopes:

        - content:read: Read site pages, markdown content, and llms.txt files

        - content:write: Create, update, and delete site pages and content

        - prompts:read: Read prompts, topics, and prompt analysis results

        - prompts:write: Create, update, archive prompts

        - simulations:read: Read agent-simulation tasks, runs, environments, and
        analytics

        - simulations:write: Create and trigger simulation runs

        - logs:read: Read AI-traffic logs and request-level audit events

        - analytics:read: Read analytics aggregates (rankings, mentions,
        sources, SOV)

        - analytics:write: Write events to analytics

        - products:read: Read product metadata and competitor data

        - products:write: Update product settings and competitor lists
      x-scopes:
        content:read: Read site pages, markdown content, and llms.txt files
        content:write: Create, update, and delete site pages and content
        prompts:read: Read prompts, topics, and prompt analysis results
        prompts:write: Create, update, archive prompts
        simulations:read: Read agent-simulation tasks, runs, environments, and analytics
        simulations:write: Create and trigger simulation runs
        logs:read: Read AI-traffic logs and request-level audit events
        analytics:read: Read analytics aggregates (rankings, mentions, sources, SOV)
        analytics:write: Write events to analytics
        products:read: Read product metadata and competitor data
        products:write: Update product settings and competitor lists
    cookieAuth:
      type: apiKey
      in: cookie
      name: better-auth.session_token
      description: First-party browser session cookie.

````