·
Last changedVersion:
This version passed the hardening gate. Hardening updated the skill content and independently checked the resulting changes. Classified findings before hardening: 1. Classified findings closed: 0. Classified findings remaining: 1. Unclassified scanner findings remaining: 0. Review findings closed: 5. Review findings remaining: 7.
1
1
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Prompt Injection | Direct prompt injection | Medium | Open |
1 finding
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.
user_id" → materialised-endpoint variable
questionsIf the user is creating the endpoint, use creating-an-endpoint first.
| Tool | Purpose |
|---|---|
| Full config for a named endpoint, including the query shape and required variables |
| OpenAPI 3.0 spec for one endpoint, ready to feed to a code generator |
| A live call against the endpoint — useful to confirm a payload works before sharing it with the user's app |
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./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.
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, which holds the key.
| Field | Notes |
|---|---|
| Keyed by |
| Max rows returned. |
| Skip rows. Only HogQL endpoints |
|
|
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.
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.
The endpoint exposes its own OpenAPI 3.0 spec via endpoint-openapi-spec. Feed that into a code
generator:
| Language | Tool | Command shape |
|---|---|---|
TypeScript |
|
|
TypeScript |
|
|
Python |
|
|
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.
A typical successful response:
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.
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)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.)
| Status | When | Handling |
|---|---|---|
400 | Missing required variable on a materialised endpoint, or invalid variable type | Surface the error message; fix the call |
401 | Missing / wrong personal API key | Check the Authorization header |
403 | Key lacks | Adjust key scopes |
404 | Endpoint name typo, or endpoint not active | Confirm name; check |
429 | Rate limited — limits are per team, not per endpoint (see note below) | Exponential backoff; cache responses client-side if possible |
5xx | Query execution failure (ClickHouse error, timeout, etc.) | Retry with backoff. If persistent, hand off to |
Confirm endpoint name.
endpoint-get to see the full shape: variables, materialisation status, query kind.
Decide the auth posture: personal API key on a server, never client-side.
If the user wants generated types, call endpoint-openapi-spec, hand them the spec, and
recommend a generator for their language.
Build a sample request payload from the variable declarations and walk through a test call.
Wrap up with handling notes: the materialised-variables rule, the rate-limit shape, and
pinning to a version with ?version=N.
?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.data_freshness_seconds, but the client can layer another cache on top for hot paths. Be
mindful of total staleness (endpoint cache + client cache).Get started with chainctlchainctl skill install public/posthog/consuming-endpoints-from-client-code:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/posthog/skills/omnibus/consuming-endpoints-from-client-code:latest
MIT
HARDENING.md
LICENSE
SKILL.md