/consuming-endpoints-from-client-code
Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a typed client with openapi-generator or @hey-api/openapi-ts, sending the right auth header, shaping the variables payload (HogQL code_name vs insight breakdown property), handling
$ npx -y skills add posthog/posthog --skill consuming-endpoints-from-client-code --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/consuming-endpoints-from-client-code
Context preview
The summary Claude sees to decide when to auto-load this skill.
Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a typed client with openapi-generator or @hey-api/openapi-ts, sending the right auth header, shaping the variables payload (HogQL code_name vs insight breakdown property), handling
SKILL.md
consuming-endpoints-from-client-code.SKILL.mdname: consuming-endpoints-from-client-code
description: >
Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a
typed client with openapi-generator or @hey-api/openapi-ts, sending the right auth header,
shaping the variables payload (HogQL code_name vs insight breakdown property), handling
rate-limit and materialised-endpoint error responses. Use when the user says "how do I call my
endpoint", "generate a client for this", or "what auth header do I use".
Consuming endpoints from client code
This skill is the **caller-side** counterpart to `creating-an-endpoint`. It helps integrate an existing endpoint into a separate codebase — a mobile app, server backend, customer dashboard, or downstream pipeline. No PostHog code is modified here.
When to use this skill
- "How do I call my endpoint?" / "What does a request look like?"
- "Generate a typed TypeScript / Python / Go client for this endpoint"
- "I'm getting a 401 calling the endpoint" / auth questions
- "The endpoint rejects my call when I omit `user_id`" → materialised-endpoint variable
questions
- "How do I handle rate limits?"
If the user is **creating** the endpoint, use `creating-an-endpoint` first.
Available tools
| Tool | Purpose | | ----------------------- | ---------------------------------------------------------------------------------------------------------- | | `endpoint-get` | Full config for a named endpoint, including the query shape and required variables | | `endpoint-openapi-spec` | OpenAPI 3.0 spec for one endpoint, ready to feed to a code generator | | `endpoint-run` | A live call against the endpoint — useful to confirm a payload works before sharing it with the user's app |
The endpoint URL
/api/projects/{team_id}/endpoints/{name}/run- `team_id` is the project ID (numeric). Available in PostHog under project settings, or via
`projects-get` if the user doesn't know it.
- `name` is the endpoint name — see `endpoints-get-all` if the user isn't sure.
- The trailing `/run` is required.
`POST` is the canonical method. `GET` also works for simple cases without a request body but POST is preferred — variables go in the body.
Auth
Endpoints are authenticated with a **personal API key**. The header is:
Authorization: Bearer <key>
Keys are scoped — for endpoints, the key needs at least `endpoint:read`. If the user gets a 403, they're usually missing the scope; if they get a 401, the key is missing or malformed.
Never put a personal API key in client-side code that's shipped to end users (mobile apps, browser JS). Personal API keys grant scoped account access. For customer-facing apps, route through the user's own backend, which holds the key.
The request payload
{
"variables": { "code_name_1": value, "code_name_2": value },
"limit": 100,
"offset": 0,
"refresh": "cache"
}| Field | Notes | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `variables` | Keyed by `code_name` for HogQL endpoints; for insight endpoints with breakdowns, key is the **breakdown property name** | | `limit` | Max rows returned. | | `offset` | Skip rows. Only HogQL endpoints | | `refresh` | `"cache"` (return cached results if fresh enough), `"force"` (always recalculate), `"direct"` (bypass materialisation, materialised endpoints only). Default is `"cache"` |
Call `endpoint-get` to see the exact variable shape. The response includes the query definition with declared variables — each variable's `code_name` is what the client should send.
Materialised endpoints: all variables are required
If `endpoint-get` shows `is_materialized: true` on the current version, the endpoint requires **every declared variable** to be passed on each call. This is a security boundary — without filters, a single call would return the entire pre-aggregated dataset.
Common symptom: the user's app worked when the endpoint was unmaterialised, then started returning 400 errors after materialisation was enabled. The error message lists which variables are missing.
Optional/partial variables on materialised endpoints are a known limitation the PostHog team plans to lift. If requiring every variable is blocking the user's use case, send a note via the `agent-feedback` tool — that demand signal is how the team prioritises it.
Generating a typed client
The endpoint exposes its own OpenAPI 3.0 spec via `endpoint-openapi-spec`. Feed that into a code generator:
| Language | Tool | Command shape | | ---------- | ----------------------- | -------------------------------------------------------------------------------- | | TypeScript | `@hey-api/openapi-ts` | `openapi-ts -i spec.json -o ./generated` | | TypeScript | `openapi-generator-cli` | `openapi-generator-cli generate -i spec.json -g typescript-fetch -o ./generated` | | Python | `openapi-generator-cli` | `openapi-generator-cli generate -i spec.json -g python -o ./generated` | | Go | `oapi-code
Read more
name: consuming-endpoints-from-client-code description: > Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a typed client with openapi-generator or @hey-api/openapi-ts, sending the right auth header, shaping the variables payload (HogQL code_name vs insight breakdown property), handling rate-limit and materialised-endpoint error responses. Use when the user says "how do I call my endpoint", "generate a client for this", or "what auth header do I use".
Consuming endpoints from client code
This skill is the **caller-side** counterpart to `creating-an-endpoint`. It helps integrate an existing endpoint into a separate codebase — a mobile app, server backend, customer dashboard, or downstream pipeline. No PostHog code is modified here.
When to use this skill
- "How do I call my endpoint?" / "What does a request look like?"
- "Generate a typed TypeScript / Python / Go client for this endpoint"
- "I'm getting a 401 calling the endpoint" / auth questions
- "The endpoint rejects my call when I omit `user_id`" → materialised-endpoint variable
questions
- "How do I handle rate limits?"
If the user is **creating** the endpoint, use `creating-an-endpoint` first.
Available tools
| Tool | Purpose | | ----------------------- | ---------------------------------------------------------------------------------------------------------- | | `endpoint-get` | Full config for a named endpoint, including the query shape and required variables | | `endpoint-openapi-spec` | OpenAPI 3.0 spec for one endpoint, ready to feed to a code generator | | `endpoint-run` | A live call against the endpoint — useful to confirm a payload works before sharing it with the user's app |
The endpoint URL
/api/projects/{team_id}/endpoints/{name}/run- `team_id` is the project ID (numeric). Available in PostHog under project settings, or via
`projects-get` if the user doesn't know it.
- `name` is the endpoint name — see `endpoints-get-all` if the user isn't sure.
- The trailing `/run` is required.
`POST` is the canonical method. `GET` also works for simple cases without a request body but POST is preferred — variables go in the body.
Auth
Endpoints are authenticated with a **personal API key**. The header is:
Authorization: Bearer <key>
Keys are scoped — for endpoints, the key needs at least `endpoint:read`. If the user gets a 403, they're usually missing the scope; if they get a 401, the key is missing or malformed.
Never put a personal API key in client-side code that's shipped to end users (mobile apps, browser JS). Personal API keys grant scoped account access. For customer-facing apps, route through the user's own backend, which holds the key.
The request payload
{
"variables": { "code_name_1": value, "code_name_2": value },
"limit": 100,
"offset": 0,
"refresh": "cache"
}| Field | Notes | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `variables` | Keyed by `code_name` for HogQL endpoints; for insight endpoints with breakdowns, key is the **breakdown property name** | | `limit` | Max rows returned. | | `offset` | Skip rows. Only HogQL endpoints | | `refresh` | `"cache"` (return cached results if fresh enough), `"force"` (always recalculate), `"direct"` (bypass materialisation, materialised endpoints only). Default is `"cache"` |
Call `endpoint-get` to see the exact variable shape. The response includes the query definition with declared variables — each variable's `code_name` is what the client should send.
Materialised endpoints: all variables are required
If `endpoint-get` shows `is_materialized: true` on the current version, the endpoint requires **every declared variable** to be passed on each call. This is a security boundary — without filters, a single call would return the entire pre-aggregated dataset.
Common symptom: the user's app worked when the endpoint was unmaterialised, then started returning 400 errors after materialisation was enabled. The error message lists which variables are missing.
Optional/partial variables on materialised endpoints are a known limitation the PostHog team plans to lift. If requiring every variable is blocking the user's use case, send a note via the `agent-feedback` tool — that demand signal is how the team prioritises it.
Generating a typed client
The endpoint exposes its own OpenAPI 3.0 spec via `endpoint-openapi-spec`. Feed that into a code generator:
| Language | Tool | Command shape | | ---------- | ----------------------- | -------------------------------------------------------------------------------- | | TypeScript | `@hey-api/openapi-ts` | `openapi-ts -i spec.json -o ./generated` | | TypeScript | `openapi-generator-cli` | `openapi-generator-cli generate -i spec.json -g typescript-fetch -o ./generated` | | Python | `openapi-generator-cli` | `openapi-generator-cli generate -i spec.json -g python -o ./generated` | | Go | `oapi-code
:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Repo: posthog/posthog
Other skills on posthog.
- /analyzing-expensive-users
Analyze the most expensive users in AI observability and explain why they cost so much. Use when the user asks about top spenders, expensive users, per-user LLM cost, user-level cost drivers, or patterns behind high AI observability spend.
Open skill - /creating-online-evaluations
Author continuously-running online evaluations in PostHog AI observability, grounded in real failure modes you've identified. Use when the user wants evaluations that automatically score new generations or whole traces going forward — "create an eval to catch X", "continuously
Open skill - /exploring-ai-failures
Find where an AI/LLM application is failing in production and surface the failure patterns, working from real traces. Use when someone wants to understand what's going wrong with an AI feature, find and categorize failure modes, triage errors, or investigate quality issues
Open skill - /exploring-llm-clusters
Investigate AI observability clusters — understand usage patterns in AI/LLM traffic, compare cluster behavior, compute cost/latency metrics, and drill into individual traces within clusters.
Open skill - /exploring-llm-costs
Investigate LLM spend in PostHog — total cost over time, cost by model, provider, user, trace, or custom dimension, token and cache-hit economics, and cost regressions. Use when the user asks "how much are we spending on LLMs?", "which model / user / feature is most expensive?",
Open skill - /exploring-llm-evaluations
Investigate AI observability evaluations — `hog` (deterministic code-based), `llm_judge` (LLM-prompt-based), and `sentiment` (user-message sentiment). Find existing evaluations, inspect their configuration, run them against specific generations, query individual results, and
Open skill

