consuming-endpoints-from-client-code
What it does
This skill shows how to call a PostHog endpoint from a separate app, such as a mobile app or a server. It is for developers who want to use PostHog data inside their own product.
When to use it
- βWhen you want to call a PostHog endpoint from your own app or server.
- βWhen you need to generate a typed client from the endpoint's OpenAPI spec.
- βWhen a call to the endpoint fails with an authentication or rate limit error.
Skill link
https://github.com/PostHog/posthog/blob/master/products/endpoints/skills/consuming-endpoints-from-client-code/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow do I call my PostHog endpoint from my mobile app, and what does the request look like?β
5 new skills a week. 1 minute to read.
How it works
It reads the endpoint's configuration and OpenAPI spec, then shows how to send the right auth header and variables. It can also suggest a code generator to build a typed client.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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_idis the project ID (numeric). Available in PostHog under project settings, or viaprojects-getif the user doesn't know it.nameis the endpoint name β seeendpoints-get-allif the user isn't sure.- The trailing
/runis 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 limit
FAQ
Does this skill change anything in PostHog?
No. It only helps you connect to an endpoint from another codebase.
Can it generate a client in any language?
It covers generating typed clients for TypeScript, Python and Go, using generators such as openapi-generator or @hey-api/openapi-ts.
What if my call is rejected because a variable is missing?
The skill explains how the variables must be shaped for materialized endpoints, so the required values are included.
Details
Original description by the author
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".
repo: PostHog/posthog
Popularity
- GitHub stars
- 41k
- Ranking position
- #6858
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
depot-ci
41kHelps your agent set up and run Depot CI workflows, a GitHub Actions alternative, including migrating existing workflows and reading run logs.
depot-container-builds
41kHelps your agent build Docker images on Depot's remote builders, including multi-platform images, pushing to registries, and fixing build failures.
depot-github-runners
41kHelps your agent move GitHub Actions jobs to Depot-managed runners, choosing runner sizes and labels, and troubleshooting runner setup issues.
editing-agents-md
41kHelps your agent decide whether a rule belongs in an AGENTS.md or CLAUDE.md file, and write it so it sticks without bloating the file.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.