Getting started with endpoints
Create an insight or SQL query
Endpoints can be created from existing insights or SQL queries in PostHog. Start by creating the query that defines the data you want to expose. You can do this directly from the endpoints page by clicking new and choosing the type or directly from a SQL query or an insight.
Option 1: Create an insight
Create an insight in PostHog that shows the data you want to expose. This could be:
- A trend showing daily active users
- A funnel tracking user conversion
- A retention analysis
- Any other insight type


Option 2: Write a SQL query
Alternatively, you can create a SQL query in the SQL editor that returns the data you need.


Create an endpoint
Once you have your insight or SQL query, create an endpoint from it. This will give you a stable API endpoint you can call to retrieve the data.
Option 1: Create endpoint from insight
- Open your insight
- Click on the info & actions button (the three dots button in the top right)
- Click the
Create endpointaction

- Give your endpoint a descriptive name (e.g.,
daily_active_usersoraccount_users_activity) and optionally a description - Create the endpoint
Option 2: Create endpoint from a SQL query
- If you've written a SQL query, you can click on the
Endpointtab:

- Give your endpoint a descriptive name (e.g.,
daily_active_usersoraccount_users_activity) and optionally a description - Create the endpoint
Choose descriptive names for your endpoints. They'll appear in the URL:
- Recommended:
daily_active_users,account_users_activity,signup_funnel - Avoid:
endpoint1,test,query
Endpoint names should be URL-friendly (lowercase, underscores instead of spaces).
Call your endpoint
Now you can call your endpoint from your application. You'll need:
- Your personal API key: The key needs to have the
endpoint:readscope assigned. Create one in your user settings. - Your endpoint URL: You can find it in the endpoints overview page.


Replace the ph_app_host, project_id and endpoint_name placeholders and set your POSTHOG_PERSONAL_API_KEY environment variable.
Use in your application
Endpoints are perfect for embedding analytics in your own application. You can:
- Show analytics to your customers: Display dashboards with PostHog data in your app
- Build custom reports: Create reports tailored to your customers' needs
- Power internal tools: Use endpoints to power internal dashboards and tools
Best practices
- Materialization: If you're not seeing the performance you're looking for, try optimizing your SQL query and materializing it
- Handle errors gracefully: Always check response status codes and handle errors appropriately
- Respect rate limits: While endpoints will have higher limits than standard API endpoints, be mindful of your usage
- Use meaningful names: Choose endpoint names that clearly describe what data they return
That's it! You're ready to start using endpoints.