Source profileQuality 97/100

PostHog/skills/skills/omnibus/consuming-endpoints-from-client-code/SKILL.md

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 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".

Source repository stars
60
Declared platforms
0
Static risk flags
1
Last source update
2026-08-24
Source checked
2026-08-25

Decision brief

What it does: where it fits

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.

Best for

  • "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

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/PostHog/skills --skill "skills/omnibus/consuming-endpoints-from-client-code"
Safe inspection promptEditorial

Inspect the Agent Skill "consuming-endpoints-from-client-code" from https://github.com/PostHog/skills/blob/870cdf070c94f2bf39d8b2a9d4916cfd44779cce/skills/omnibus/consuming-endpoints-from-client-code/SKILL.md at commit 870cdf070c94f2bf39d8b2a9d4916cfd44779cce. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Workflow

    1. Confirm endpoint name. If unknown, list them with execute-sql on system.datamodelingendpoints (or endpoints-get-all). 2. endpoint-get to see the full shape: variables, materialisation status, query kind. 3. Decide the auth posture: personal API key on a server, never client-s…

    Confirm endpoint name. If unknown, list them with execute-sql onendpoint-get to see the full shape: variables, materialisation status, query kind.Decide the auth posture: personal API key on a server, never client-side.
  2. 02

    When to use this skill

    If the user is creating the endpoint, use creating-an-endpoint first.

    "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
  3. 03

    Available tools

    Review the “Available tools” section in the pinned source before continuing.

    Review and apply the “Available tools” source section.
  4. 04

    The endpoint URL

    POST is the canonical method. GET also works for simple cases without a request body but POST is preferred — variables go in the body.

    teamid is the project ID (numeric). Available in PostHog under project settings, or vianame is the endpoint name — see endpoints-get-all if the user isn't sure.The trailing /run is required.
  5. 05

    Auth

    Endpoints are authenticated with a personal API key. The header is:

    Endpoints are authenticated with a personal API key. The header is: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, whic…

Permission review

Static risk signals and limitations

Network access

medium · line 208

The documentation includes network, browsing, or remote request actions.

**Re-generate the client when the query changes.** Each new endpoint version may add or

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score97/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars60SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
PostHog/skills
Skill path
skills/omnibus/consuming-endpoints-from-client-code/SKILL.md
Commit
870cdf070c94f2bf39d8b2a9d4916cfd44779cce
License
MIT
Collected
2026-08-25
Default branch
main
View the original SKILL.md

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

ToolPurpose
endpoint-getFull config for a named endpoint, including the query shape and required variables
endpoint-openapi-specOpenAPI 3.0 spec for one endpoint, ready to feed to a code generator
endpoint-runA 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 posthog-get-projects 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"
}
FieldNotes
variablesKeyed by code_name for HogQL endpoints; for insight endpoints with breakdowns, key is the breakdown property name
limitMax rows returned.
offsetSkip 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:

LanguageToolCommand shape
TypeScript@hey-api/openapi-tsopenapi-ts -i spec.json -o ./generated
TypeScriptopenapi-generator-cliopenapi-generator-cli generate -i spec.json -g typescript-fetch -o ./generated
Pythonopenapi-generator-cliopenapi-generator-cli generate -i spec.json -g python -o ./generated
Gooapi-codegenoapi-codegen -package=client spec.json > client.go

The generated client gives the user types for the variables payload and the response shape. Re- generate when the endpoint's query changes (each new version may have different variables).

If the user has multiple endpoints, generate a spec per endpoint and either combine them, or generate one client per endpoint and use them side-by-side.

Response shape

A typical successful response:

{
  "results": [[...], [...]],
  "columns": ["col_a", "col_b"],
  "types": ["Int64", "String"],
  "hasMore": false,
  "name": "endpoint_name",
  "endpoint_version": 4,
  "endpoint_version_created_at": "2026-01-15T..."
}
  • results is an array of rows; each row is an array of cell values in the order of columns.
  • endpoint_version tells the client which version actually ran — useful for logging and for pinning to a known version with ?version=N.

For insight endpoints, the response shape depends on the query kind (TrendsQuery, LifecycleQuery, RetentionQuery) — the OpenAPI spec captures the right shape for the current version. Insight kinds that can't be materialised (e.g. FunnelsQuery) still return their inline result shape.

Calling from the PostHog CLI

For local testing, scripts, or CI, the repo's posthog-cli calls endpoints without hand-rolling HTTP:

  • posthog-cli exp endpoints run — execute an endpoint (from a local YAML definition)
  • posthog-cli exp endpoints {list,get,pull,push,diff} — inspect endpoints, or manage them as YAML files in version control (GitOps-style)

Auth uses the same personal API key, via posthog-cli login or the POSTHOG_CLI_API_KEY / POSTHOG_CLI_PROJECT_ID / POSTHOG_CLI_HOST env vars. (These live under exp — experimental, may change.)

Error responses to handle

StatusWhenHandling
400Missing required variable on a materialised endpoint, or invalid variable typeSurface the error message; fix the call
401Missing / wrong personal API keyCheck the Authorization header
403Key lacks endpoint:read scope, or endpoint is in another projectAdjust key scopes
404Endpoint name typo, or endpoint not activeConfirm name; check is_active
429Rate limited — limits are per team, not per endpoint (see note below)Exponential backoff; cache responses client-side if possible
5xxQuery execution failure (ClickHouse error, timeout, etc.)Retry with backoff. If persistent, hand off to diagnosing-endpoint-performance

Workflow

  1. Confirm endpoint name. If unknown, list them with execute-sql on system.data_modeling_endpoints (or endpoints-get-all).
  2. endpoint-get to see the full shape: variables, materialisation status, query kind.
  3. Decide the auth posture: personal API key on a server, never client-side.
  4. If the user wants generated types, call endpoint-openapi-spec, hand them the spec, and recommend a generator for their language.
  5. Build a sample request payload from the variable declarations and walk through a test call.
  6. Optionally call endpoint-run from this skill to confirm the payload works.
  7. Wrap up with handling notes: the materialised-variables rule, the rate-limit shape, and pinning to a version with ?version=N.

Example interaction

User: "I want to call monthly_active_users from my Node.js backend.
       Can you help me wire it up with types?"

Agent steps:
- endpoint-get monthly_active_users → HogQL, variables: lookback_days
  (int, default 30), org_id (string, no default), is_materialized: true
- "Two things to know upfront:
   1. This endpoint is materialised, so both lookback_days and org_id
      must be passed on every call. Calls without them will be rejected.
   2. You'll need a personal API key with endpoint:read scope. Set it
      as PH_API_KEY in your server env — never ship it in client code."

- endpoint-openapi-spec monthly_active_users → returns spec

- "Here's the spec. Drop it in your repo and run:
     pnpm dlx @hey-api/openapi-ts -i spec.json -o ./generated/posthog
   That gives you typed client functions.

   A minimum call looks like:
     POST /api/projects/12345/endpoints/monthly_active_users/run
     Authorization: Bearer <PH_API_KEY>
     Content-Type: application/json

     { 'variables': { 'org_id': 'acme', 'lookback_days': 30 } }

   The response includes columns and rows — your client will pick that
   up from the generated types.

   Want me to do a sample call to verify the payload works?"

Important notes

  • Personal API keys are server-side only. Never ship them in mobile apps or browser JS.
  • Re-generate the client when the query changes. Each new endpoint version may add or remove variables — keep types in sync by re-fetching the spec.
  • Materialised endpoints reject calls missing variables. This is intentional. If the user reports a 400 after materialisation was enabled, the fix is in the call, not in the endpoint.
  • Pin to a version — don't rely on "latest". Always call with ?version=N. Without it the latest active version runs, so a future query edit (which cuts a new version) can silently change a caller's results. Bump the pinned version deliberately once you've validated the new one.
  • Caching on the client side is fair game. The endpoint already caches via data_freshness_seconds, but the client can layer another cache on top for hot paths. Be mindful of total staleness (endpoint cache + client cache).
  • Rate limits are per team, by category — not per endpoint. Calls to non-materialised endpoints share the team-wide API-query budget (~240/min burst, ~2400/hour sustained) with all other query traffic; materialised endpoints draw on a separate, higher shared bucket (~1200/min, ~12000/hour). There is no per-endpoint-name limit, so hammering one endpoint can starve others on the same team. Heavy callers should batch where possible and back off on 429.
  • Pricing. Calling endpoints isn't billed today, but it will be once endpoints ship alongside the managed warehouse. Flag this to the user if they're planning high-volume usage so the future cost isn't a surprise.
  • Tell PostHog what's missing. If an error, a limit, or a missing capability gets in the way, use the agent-feedback tool — it's the main signal the team uses to improve endpoints and these tools.

Frequently asked questions

What to verify before installation and use

What does the consuming-endpoints-from-client-code source document cover?

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.

How do I install consuming-endpoints-from-client-code?

The source record exposes this install command: npx skills add https://github.com/PostHog/skills --skill "skills/omnibus/consuming-endpoints-from-client-code". Inspect the command and pinned source before running it.

Which permission-related actions were detected?

Static rules flagged network in the source; the page lists the matching lines and excerpts.

Alternatives

Compare before choosing

Computed 100147

oaustegard/claude-skills

featuring

Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre

Computed 99238

enuno/unifi-mcp-server

unifi-mcp-tool-builder

Specialized guide for adding new MCP tools to the UniFi MCP Server following project standards, UniFi API patterns, and test-driven development practices. Use when implementing new UniFi Network Controller features as MCP tools.

Computed 9970

PaulRBerg/agent-skills

skill-writing

Create/scaffold/init a project-local agent skill under `.agents/skills` in an ordinary repository; defer to repository instructions that define a source catalog and lifecycle.

Computed 9916

NintendaDev/unikit-ai

unikit-docs

Generate and maintain the project's TECHNICAL documentation from its codebase — scans the project structure, tech stack, and module boundaries, then writes a lean README landing page plus detailed topic pages (architecture, modules, setup, build, APIs), only the docs that are relevant. Use whenever the user wants to create, update, or validate documentation of the CODE or the project itself, e.g. "generate documentation", "create docs", "write the README", "update the project docs", "document th