An independently authored, type-safe SDK and confirmation-first CLI for the documented PostHog public project-token runtime API:
POST /i/v0/e/— capture one eventPOST /batch/— capture events in a batchPOST /flags?v=2— evaluate runtime feature flags
It deliberately excludes PostHog's personal-API-key management API, local evaluation bootstrap, SSE/workflow APIs, and deprecated routes. This is not an official PostHog SDK.
pnpm add @pontx/posthogimport { createPostHogClient } from "@pontx/posthog";
const client = createPostHogClient({ projectToken: process.env.POSTHOG_PROJECT_TOKEN! });
const preview = client.capture.previewCaptureEvent({
event: "checkout_completed",
distinct_id: "user_123",
properties: { plan: "pro" },
});
console.log(preview); // token is redacted
await client.capture.captureEvent({
event: "checkout_completed",
distinct_id: "user_123",
}, { confirm: true });All three remote calls require { confirm: true }. Capture can create or
update event, person, and group data; flag evaluation can consume quota.
pnpm add --global @pontx/posthog
export POSTHOG_PROJECT_TOKEN='set-only-in-your-local-shell'
pontx-posthog preview captureEvent --json '{"event":"checkout_completed","distinct_id":"user_123"}'
pontx-posthog execute captureEvent --json '{"event":"checkout_completed","distinct_id":"user_123"}' --confirmpreview never sends a provider request. execute fails unless --confirm
is present and never prints the project token.