Endpoint
Authentication
Authenticate using your project API key (also calledapi_key or token).
Request Body
The capture endpoint accepts a single event payload with the following structure:Your PostHog project API key. This identifies which project the event belongs to.
The name of the event being tracked. Use descriptive names like
user_signed_up, button_clicked, or PostHog’s special events like $pageview.A unique identifier for the user or entity performing the event. This is used to associate events with users and track behavior over time.Can be a user ID, email, device ID, or any unique identifier. PostHog uses this to group events by user.
An object containing event properties. These are custom key-value pairs that provide context about the event.Common properties include:
- Custom properties: Any data relevant to your event
$current_url: The current page URL$browser: Browser name$device_type: Device type (Desktop, Mobile, Tablet)
Property values can be strings, numbers, booleans, or nested objects.
ISO 8601 formatted timestamp for when the event occurred. If not provided, PostHog uses the current server time.Example:
2024-03-15T14:30:00.000ZISO 8601 formatted timestamp for when the event was sent by the client. Used to calculate clock skew between client and server.
Whether to process the person profile for this event. Set to
false to skip person profile updates and improve ingestion performance for high-volume events.Response
The capture endpoint returns a simple acknowledgment response.HTTP status code.
200 indicates successful capture.Examples
Special Events
PostHog recognizes several special event names that trigger specific functionality:$pageview- Page view tracking$autocapture- Automatically captured user interactions$snapshot- Session replay snapshots$performance_event- Performance monitoring data$snapshot_items- Session replay data items
Person Profile Processing
By default, PostHog processes person profiles for each event, which:- Creates or updates person records
- Associates the
distinct_idwith a person - Updates person properties
$process_person_profile to false in the properties:
Rate Limiting
The capture endpoint has rate limits to prevent abuse. If you hit rate limits:- Implement exponential backoff
- Batch events when possible using your SDK
- Consider upgrading your plan for higher limits
Use PostHog’s official SDKs when possible. They handle batching, retries, and edge cases automatically.
Best Practices
- Use descriptive event names:
user_completed_checkoutis better thanevent_5 - Keep properties flat when possible: Avoid deeply nested objects
- Use consistent naming: Decide on
snake_caseorcamelCaseand stick with it - Include context: Add properties that help you understand the event later
- Avoid PII in event names: Use properties instead for sensitive data
- Use appropriate data types: Numbers for metrics, booleans for flags, strings for categories