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

# Run a HogQL query on PostHog

> Runs a HogQL query on PostHog with the date tokens filled for the latest complete `period`, and returns up to `limit` rows (at most 100), writing nothing. HogQL is not parsed here: this is how a query is checked before you save it with POST /v1/integrations/posthog/queries. A query PostHog cannot run is a 422; a 502 when PostHog refuses or does not answer. Needs integrations:write: the rows can hold any PostHog data.



## OpenAPI

````yaml /api/statisfy-api.openapi.json post /v1/integrations/posthog/preview
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/integrations/posthog/preview:
    post:
      tags:
        - integrations
      summary: Run a HogQL query on PostHog
      description: >-
        Runs a HogQL query on PostHog with the date tokens filled for the latest
        complete `period`, and returns up to `limit` rows (at most 100), writing
        nothing. HogQL is not parsed here: this is how a query is checked before
        you save it with POST /v1/integrations/posthog/queries. A query PostHog
        cannot run is a 422; a 502 when PostHog refuses or does not answer.
        Needs integrations:write: the rows can hold any PostHog data.
      operationId: integrations_posthog_preview
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                limit:
                  default: 10
                  description: The most rows to return
                  maximum: 100
                  minimum: 1
                  title: Limit
                  type: integer
                period:
                  default: WEEKLY
                  description: Fills the date tokens with the latest complete period
                  enum:
                    - DAILY
                    - WEEKLY
                    - MONTHLY
                  title: Period
                  type: string
                query:
                  description: >-
                    A HogQL SELECT. It may hold the date tokens {START_DATE},
                    {END_DATE}, {START_DATE_SQL}, {END_DATE_SQL},
                    {START_DATE_MS} and {END_DATE_MS}
                  maxLength: 100000
                  minLength: 1
                  title: Query
                  type: string
                week_start_day:
                  anyOf:
                    - maximum: 6
                      minimum: 0
                      type: integer
                    - type: 'null'
                  default: null
                  description: >-
                    0 = Monday … 6 = Sunday. The config's week start day when
                    left out
                  title: Week Start Day
              required:
                - query
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostHogPreviewRows'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    PostHogPreviewRows:
      properties:
        columns:
          description: The column names of the first row
          items:
            type: string
          title: Columns
          type: array
        row_count:
          description: How many rows are returned
          title: Row Count
          type: integer
        rows:
          description: The rows. They can hold any PostHog data, emails included
          items:
            additionalProperties: true
            type: object
          title: Rows
          type: array
        truncated:
          description: True when PostHog had more rows than `limit`
          title: Truncated
          type: boolean
      required:
        - columns
        - rows
        - row_count
        - truncated
      title: PostHogPreviewRows
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.