Product Analytics API
The Product Analytics API provides direct HTTP access to track events and identify users. For most use cases, we recommend using the JavaScript or React SDKs, which provide a simpler interface and handle session management automatically.
Successful responses return ok: true, an optional task_id, and nullable error_code. A task_id identifies asynchronous processing; it does not mean processing has finished.
See the deployed OpenAPI contract for machine-readable schemas.
Authentication
All API requests require a public Product Analytics API key for the target environment.
Method | Value |
|---|---|
X-API-Key header | X-API-Key: {{API_KEY}} |
Authorization header | Authorization: Bearer {{API_KEY}} |
Query parameter | ?apiKey={{API_KEY}} |
These keys accept product events and identity updates. They do not authorize lakehouse SQL queries or access to historical analytics data. Prefer a header over the query parameter so the key does not appear in request URLs and access logs.
See the Authentication guide for details on obtaining and managing API keys.
Response statuses
- 200: JSON acceptance response, as shown for each endpoint.
- 400: JSON rejection such as
{"ok":false,"error_code":"environment-not-found"}. The endpoint sections list domain error codes. - 401: plain-text authentication error:
API key is requiredorUnauthorized.
All three endpoints accept one JSON object or an array. Send Content-Type: application/json.
POST /track
- Authentication
- Public Product Analytics API key
- Permission
- Write events
Parameters
- syncboolean· query · Optional
- Wait for ingestion to finish before returning when true.
- environmentstring· body · Optional
- Environment slug. Omit to use the API key environment; required for keys without an environment binding.
- eventstring· body · Required
- Event name.
- propertiesobject· body · Required
- Custom key-value properties. Send an empty object when no properties apply.
- distinct_idstring· body · Optional
- User or visitor identifier.
- anonymous_idstring· body · Optional
- Anonymous identifier used before the user is known.
- device_idstring· body · Optional
- Device identifier.
- session_idstring· body · Optional
- Session identifier.
- timestampinteger | ISO 8601 string· body · Optional
- Event time as Unix milliseconds or an ISO 8601 timestamp.
Error codes
environment-not-foundproduct-analytics-not-enabledinvalid-headersunknown-built-in-propertyevent-name-too-longproperty-name-too-long
Event names and property names can contain up to 400 characters. Requests with longer names are rejected before ingestion.
POST /identify
- Authentication
- Public Product Analytics API key
- Permission
- Write identities
Parameters
- syncboolean· query · Optional
- Wait for ingestion to finish before returning when true.
- environmentstring· body · Optional
- Environment slug. Omit to use the API key environment; required for keys without an environment binding.
- distinct_idstring· body · Required
- The user's unique identifier.
- anonymous_idstring· body · Optional
- Previous visitor ID used to link anonymous events.
- traitsobject· body · Optional
- User traits to shallow-merge into the existing identity.
- timestampinteger | ISO 8601 string· body · Optional
- Timestamp used for last-write-wins ordering.
Error codes
environment-not-foundproduct-analytics-not-enabledtrait-name-too-long
Trait names can contain up to 400 characters. Requests with longer trait names are rejected before ingestion.
POST /alias
- Authentication
- Public Product Analytics API key
- Permission
- Write identities
Parameters
- syncboolean· query · Optional
- Wait for the task to finish before returning.
- environmentstring· body · Optional
- Environment slug. Omit to use the API key environment; required for keys without an environment binding.
- distinct_idstring· body · Required
- Existing ID to merge into the target user.
- new_user_idstring· body · Required
- Target user ID that should remain.
Use /alias only when changing ID systems or attaching an external identifier to a known user. Most login and signup flows should use /identify.
The API also accepts an array of alias payloads for batch merges.
Error codes
environment-not-foundproduct-analytics-not-enabled
Related guides
- Set up tracking to install and initialize an SDK.
- Track events to choose events and properties.
- Identify users to link activity to user profiles.
- Alias users to merge identifiers.