AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

querying-posthog-data

Explains how to query PostHog data, defaulting to typed runners for supported product analytics. Read it before you write HogQL/SQL. Also read it before you call execute-sql against PostHog. Use it to find or aggregate PostHog entities. These entities include insights, dashboards, cohorts, feature flags, experiments, surveys, hog flows, warehouse data, and persons. Use it for trends, funnels, retention, lifecycle, paths, stickiness, web analytics, error tracking, logs, sessions, and LLM traces. Before you calculate a governed business or telemetry measure, check system.information_schema.metrics for an approved definition. Examples include MRR, activation, billable usage, active organizations, and failure rates. Use the approved definition before you derive a measure from raw events or use a typed domain tool. It also covers HogQL differences, system table schemas, functions, query examples, and schema discovery.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--querying-posthog-data at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 65

references/models-endpoints.md

Data Modeling Endpoints

Endpoint (system.data_modeling_endpoints)

API endpoints that expose saved HogQL or insight queries as callable API routes.

Columns

Column | Type | Nullable | Description --- | --- | --- | --- id | String | NOT NULL | Endpoint UUID. team_id | Integer | NOT NULL | name | String | NOT NULL | Endpoint name, used to call it. is_active | Integer | NOT NULL | 1 if the endpoint is active and callable, 0 otherwise. current_version | Integer | NOT NULL | Version number currently served; joins to data_modeling_endpoint_versions.version. derived_from_insight | String | NOT NULL | Short id of the insight this endpoint was created from, if any. created_by_id | Integer | NULL | User who created the endpoint. created_at | DateTime | NOT NULL | When the endpoint was created. updated_at | DateTime | NOT NULL | When the endpoint was last updated. last_executed_at | DateTime | NOT NULL | When the endpoint was last called/executed. deleted | Integer | NOT NULL |

Example Queries

-- List all active endpoints with their current version
SELECT name, is_active, current_version
FROM system.data_modeling_endpoints
WHERE is_active = 1

-- Find endpoints that haven't been executed recently
SELECT name, last_executed_at
FROM system.data_modeling_endpoints
WHERE last_executed_at < now() - INTERVAL 30 DAY

-- Join with versions to get current version description
SELECT e.name, ev.description, ev.version
FROM system.data_modeling_endpoints e
LEFT JOIN system.data_modeling_endpoint_versions ev
  ON ev.endpoint_id = e.id AND ev.version = e.current_version

Important Notes

  • Endpoints are looked up by name, not id
  • Use system.data_modeling_endpoint_versions to access version-specific details
  • Boolean fields (is_active) are exposed as integers (0/1) for HogQL compatibility

Endpoint Version (system.data_modeling_endpoint_versions)

Immutable query snapshots. A new version is created each time an endpoint's query changes.

Columns

Column | Type | Nullable | Description --- | --- | --- | --- id | String | NOT NULL | Endpoint version UUID. team_id | Integer | NOT NULL | endpoint_id | String | NOT NULL | Parent endpoint; joins to data_modeling_endpoints.id. version | Integer | NOT NULL | Version number within the endpoint. description | String | NOT NULL | Description of this endpoint version. query | JSON | NOT NULL | JSON HogQL query executed by this version. data_freshness_seconds | Integer | NOT NULL | Max age, in seconds, of cached results before re-running. created_at | DateTime | NOT NULL | When this version was created. is_active | Integer | NOT NULL | 1 if this version can be executed, 0 if inactive; independent of the endpoint's current_version. columns | JSON | NOT NULL | JSON schema of the version's output columns.

Example Queries

-- Get version history for an endpoint
SELECT ev.version, ev.description, ev.created_at
FROM system.data_modeling_endpoint_versions ev
LEFT JOIN system.data_modeling_endpoints e ON e.id = ev.endpoint_id
WHERE e.name = 'my-endpoint'
ORDER BY ev.version DESC