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

# QueryPageAnalyticsAPI mirrors the erdo_page_analytics_query MCP tool: run a


> read-only HogQL query against the caller org's page-analytics events. Thin — resolves the caller's org from ctx and hands the query to the organization service (which re-checks member RBAC and pins the query to the org's own project). A rejected HogQL propagates as InvalidArgument with PostHog's own message, deliberately, so the caller can fix and retry.




## OpenAPI

````yaml /api/openapi.json post /v1/page-analytics/query
openapi: 3.0.0
info:
  title: Erdo API
  description: >-
    Erdo's REST API: query and write datasets, run agents, manage threads,
    integrations, pages, evals, workstreams, and experiments. Authenticate with
    a Bearer API key (erdo_api_...) or scoped token (erdo_token_...).
  version: '2026-07-25'
servers:
  - url: https://api.erdo.ai
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/page-analytics/query:
    post:
      summary: >
        QueryPageAnalyticsAPI mirrors the erdo_page_analytics_query MCP tool:
        run a
      description: >
        read-only HogQL query against the caller org's page-analytics events.
        Thin — resolves the caller's org from ctx and hands the query to the
        organization service (which re-checks member RBAC and pins the query to
        the org's own project). A rejected HogQL propagates as InvalidArgument
        with PostHog's own message, deliberately, so the caller can fix and
        retry.
      operationId: POST:mcp.QueryPageAnalyticsAPI
      requestBody:
        content:
          application/json:
            schema:
              properties:
                query:
                  type: string
              type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  columns:
                    items:
                      type: string
                    type: array
                  enabled:
                    description: >
                      should suggest enabling it rather than treating empty as
                      "no traffic".
                    title: >
                      Enabled is false when the org hasn't turned on page
                      analytics — the caller
                    type: boolean
                  rows:
                    description: >
                      nested) because the shape is whatever the caller SELECTed
                      — Encore's API schema has no \`any\`, and re-marshalling
                      raw cells is lossless anyway.
                    items:
                      items:
                        type: object
                      type: array
                    title: >
                      Rows are positional per Columns; cells stay raw JSON
                      (string/number/null/
                    type: array
                  truncated:
                    title: |
                      Truncated is true when Rows was cut at maxAnalyticsRows.
                    type: boolean
                  types:
                    description: |
                      with Columns; empty when the response omitted them.
                    items:
                      type: string
                    title: >
                      Types are PostHog's column types (e.g. UInt64,
                      Nullable(String)), aligned
                    type: array
                type: object
          description: Success response
        default:
          $ref: '#/components/responses/APIError'
components:
  responses:
    APIError:
      content:
        application/json:
          schema:
            externalDocs:
              url: https://pkg.go.dev/encore.dev/beta/errs#Error
            properties:
              code:
                description: Error code
                example: not_found
                externalDocs:
                  url: https://pkg.go.dev/encore.dev/beta/errs#ErrCode
                type: string
              details:
                description: Error details
                type: object
              message:
                description: Error message
                type: string
            title: APIError
            type: object
      description: Error response
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An Erdo API key (erdo_api_...) or scoped token (erdo_token_...).

````