> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Endpoints Canonical URL: https://posthog.com/docs/endpoints Endpoints turn a saved insight or SQL query into a named, callable API route. You write the query once in PostHog, give it a name, and your app fetches the results over HTTP – no query strings to assemble in client code, and no query logic scattered across your services. Because the query lives in PostHog, you get versioning, execution logs, and optional [materialization](https://posthog.com/docs/endpoints/materialization.md) for free. That makes endpoints a good fit for customer-facing analytics and internal tools, where the same query runs constantly and needs to stay fast and predictable. Want to see one in production? Our [MCP leaderboard](https://posthog.com/mcp/leaderboard.md) is powered by two endpoints. See [public stats pages](https://posthog.com/docs/endpoints/best-practices.md#public-stats-pages) for how it works. [Get started](https://posthog.com/docs/endpoints/start-here.md) ## Where you can use it You build and monitor endpoints in the PostHog web app, then call them from your own code. MCP and PostHog Desktop are for creating and debugging endpoints from an AI tool. PostHog Web Create endpoints, test them in the playground, and watch usage and execution logs. [Build an endpoint →](https://posthog.com/docs/endpoints/surfaces/web-app.md) API Call your endpoint over HTTP from any language, or generate a typed client from its OpenAPI spec. [Call an endpoint →](https://posthog.com/docs/endpoints/surfaces/api.md) PostHog MCP Create, run, version, and debug endpoints from Claude Code, Cursor, or any MCP client. [Manage endpoints →](https://posthog.com/docs/endpoints/surfaces/mcp.md) ## Where its data comes from An endpoint doesn't store data of its own. It serves whatever its query returns, shaped by the variables you pass and the way it's executed. Insights Publish a saved insight as an endpoint and serve the same numbers your dashboards show. [Endpoint types →](https://posthog.com/docs/endpoints/endpoint-types.md) SQL queries Write SQL against your events, persons, and data warehouse tables, then expose the result. [Variables →](https://posthog.com/docs/endpoints/variables.md) Materialized tables Eligible queries are precomputed on a schedule so requests read a table instead of scanning events. [How materialization works →](https://posthog.com/docs/endpoints/materialization.md) Execution logs Every run records its duration, row count, cache path, and error, across all versions. [Usage and logs →](https://posthog.com/docs/endpoints/usage-analytics.md)