Overview
Userpilot offers a REST API to identify users and track custom events, enabling the creation of detailed user segments and effective goal tracking. This API can be utilized in any programming language that supports HTTP requests by specifying yourAPI_key and the relevant user or event data.
Common use cases
- Historical user identification: Import historical data into Userpilot during migration or evaluation phases.
- Server-side event tracking: Capture events accessible only via your server, such as email confirmations, high-volume marketing events, or sensitive data like user lifetime value.
Authorization
Authenticate API requests using your Userpilot API token, available on the Environment Page. Keep your API key secure and avoid sharing it publicly. Use the following header for authentication:API Versioning:
Include the API version in your request headers:Identify User API:
Use theidentify endpoint to recognize users and append metadata. Invoke this after user login, signup, or profile updates.
Request Payload:
user_id(required): Unique identifier for the user.metadata(optional): Key-value pairs describing the user.company(optional): Key-value pairs describing the user’s company; if provided, anidis mandatory.
- Metadata and Company Values: Only primitive types (string, number, boolean, null) are supported. Arrays or objects as values are not allowed.
- Data Updates: To update user information, call the
identifyAPI with the modified data; only include fields that have changed.
Identify Company API:
Use theidentify company endpoint to recognize and track companies in real-time. This API creates or updates a company profile in Userpilot’s system, capturing key company data and providing insights into company engagement and usage patterns.
Request Payload:
company_id(required): Unique identifier for the company.metadata(optional): Key-value pairs describing the company (e.g., name, industry, plan, monthly_spend, etc.).
- Company-User Association: A company will not appear on the companies dashboard unless there is at least one associated user. Ensure that users are identified for the company to ensure visibility in the Userpilot dashboard.
- Metadata Values: Only primitive types (string, number, boolean, null) are supported. Arrays or objects as values are not allowed.
- Data Updates: To update company information, call the
identify companyAPI with the modified data; only include fields that have changed. inserted_atis auto-handled: Theinserted_atfield is managed by the API automatically. Any value passed forinserted_atfrom the caller will be ignored, and the API will use the current date and time as theinserted_atvalue.
- Missing
company_id(400 Bad Request):
- Invalid Authorization (401 Unauthorized):
- Rate Limit Exceeded (429 Too Many Requests):
Track Events API:
Thetrack endpoint records events associated with users, allowing you to monitor specific actions.
Request Payload:
user_id(required): Identifier of the user associated with the event.event_name(required): Name of the event to track.metadata(optional): Key-value pairs providing additional event details.