building-on-capture-v1
How to build on capture v1, PostHog's batch event intake API (`/i/v1/analytics/events`, `/i/v1/ai/events`). Use when sending events to capture from PostHog…
by PostHog★ 41,278 GitHub stars
Install building-on-capture-v1 in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Building on capture v1
Capture v1 is the batch intake API that the v1 SDKs and PostHog's internal senders use.
Legacy capture (/batch, /e, /capture, /i/v0/e) still serves older SDKs and stays supported, but new senders use v1.
Sources of truth, in the order to read them:
rust/capture/src/v1/README.md: the request, response and options contract, and how capture hands events to ingestion.- The
capturespec in PostHog/sdk-specs: what every v1 SDK does. - Public docs: the capture v1 API for HTTP senders, and the per-SDK migration guides (Python, Go, Rust, Node.js) for SDK users.
Send events from PostHog code
- On behalf of a customer team, from Django: use
capture_internalorcapture_batch_internalfor analytics events, andcapture_ai_internalfor$ai_*events, fromposthog/api/capture.py. They implement the headers, retries and per-event results, so do not write a new HTTP client. - From Node: follow
push-capture.ts. From Rust: followbatch-import-worker/src/emit/capture.rs. - PostHog's own telemetry (team 2): use the PostHog SDK for the language, on its v1 major.
- Never produce to the ingestion Kafka topics directly. Capture owns quotas, restrictions, deduplication and routing.
- Some internal senders and internal SDK installs still use legacy capture at the first v1 release. references/internal-senders.md lists every sender and which capture it uses. Those move to v1 soon after the release; update the list and this skill when they do. Do not move one in an unrelated PR.
Compose a v1 event
- Put settings in
optionsexplicitly, for example{"process_person_profile": false}. Never set them as$process_person_profile,$cookieless_mode,$ignore_sent_ator$product_tour_idproperties. An HTTP sender has no SDK to move those properties into options, and capture ignores$ignore_sent_atand$product_tour_idinproperties. - Send
session_idandwindow_idas event fields, not as$session_idand$window_idproperties. - For events sent on a customer's behalf, set
"capture_internal": trueon the batch, not inproperties. Capture then records127.0.0.1instead of the PostHog server's IP. Capture v1 ignores acapture_internalproperty, which is where legacy capture reads it. - Send
$ai_*events to/i/v1/ai/eventsand every other event to/i/v1/analytics/events. Capture still routes$ai_*events from the analytics endpoint to the AI topic, but only for now. Do not rely on it. The AI endpoint, and an SDK's AI capture call, drop every event that is not$ai_*withmisrouted_event. That includes$mcp_*events: send them to the analytics endpoint. - Give every event its own UUID. On a retry, resend only the events with result
retry, with the same uuid,PostHog-Request-Idandcreated_at,PostHog-Attemptplus one, and a newPostHog-Request-Timestamp. - Set
PostHog-Sdk-Infoto<sender>/<version>. Ingestion uses it as$liband$lib_versiononly when the event has no$lib.
Choose an option or a property
Why options exist. Legacy capture took settings as $ properties inside the event data.
Capture forwards properties to Kafka as raw JSON, and the client controls them, so capture could not act on a setting and ingestion could not trust one.
Capture v1 moves settings into a separate options object.
Capture validates each option, acts on it, and publishes it beside the event in the Kafka message, outside the client-controlled data.
Ingestion then writes the matching $ property, so products and queries read the same property as before.
The rule:
- Add an option when capture must read, act on or change the value: timestamps, partitioning, quotas, routing or a drop decision. If services after capture also need the value, ingestion copies the option into a property.
- Add a property when only ingestion or later services read or change the value. A new property needs no capture change.
Any v1 sender can put any string key with any JSON value in options, as with properties.
Every v1 SDK passes unknown option keys through unchanged, so a new option needs no SDK change.
The v1 SDKs move the four legacy $ properties into options under the option names (see the mapping in the capture v1 API docs and the [sdk-specs capture spec](https://github.com/
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- references/internal-senders.md
- references/sdk-implementations.md
FAQ
What does the building-on-capture-v1 skill do?
How to build on capture v1, PostHog's batch event intake API (`/i/v1/analytics/events`, `/i/v1/ai/events`). Use when sending events to capture from PostHog code, changing any capture code under `rust/capture/` (legacy or v1) or the `capture_internal` helpers, adding a per-event option (`event.options`) or a property that capture or ingestion must read, changing how Node ingestion or livestream applies capture `options`, changing the v1 request, batch, header or event schema, or checking whether an SDK or internal service uses capture v1 or legacy capture (`/batch`, `/e`, `/capture`, `$process_person_profile` or `$cookieless_mode` set as properties). Covers when to add an option versus a property and why options exist, the files to change for a new option, how to compose a v1 event at a call site, internal senders, and how to tell a v1 SDK from a legacy one.
How do I install the building-on-capture-v1 skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the building-on-capture-v1 skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…