Analytics
PostHog in your product and your AI agents, through one API
The PostHog toolkit covers organizations and projects, event definitions, ad hoc queries, insights, dashboards, persons, cohorts and annotations. Your customer connects PostHog once with a personal API key, and your product or AI agent calls each operation through Connect, which stores the credentials and logs every execution.
15 days to try it. No credit card.
POST https://connect.reportei.com/api/tools/posthog_run_query/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json
{
"customer_toolkit": "<connection UUID>",
"arguments": {
"project_id": "<project_id>",
"query": {}
}
}How it works
From a connected customer to the first PostHog call.
- 1
Your customer connects the account
Your system opens a Connect session for the toolkit and your customer connects their PostHog account. You get the connection id.
- 2
Your product calls the tool
A POST to /api/tools/{tool}/execute with the connection id and arguments. On success, Connect preserves the app's response status and body.
- 3
Connect handles the rest
It stores the credential encrypted, renews tokens for OAuth connections that support renewal and records executions in an audit trail available through the API.
Use cases
What your product does with PostHog.
Analytics inside your product
Run a query and read insights and dashboard tiles with their cached results to show product analytics in your own screens.
Agent answers data questions
An AI agent lists event definitions and runs a query to answer questions about what users did, with each call kept in the audit log.
Mark launches on the charts
Create an annotation when a campaign or release ships, so the moment shows up on every chart of the project.
Tools
12 PostHog tools
- List organizationsGETLists the organizations the key reaches, each with its projects under teams. The project_id of each team is what the other tools ask for. Page with limit and offset.
- List event definitionsGETLists the events tracked in the project with name, description, tags and last_seen_at, to use in queries and annotations. Page with limit and offset.
- Run queryPOSTRuns an ad hoc analytics query and returns its results, up to 100 rows unless the SQL sets a LIMIT. It is not an export: PostHog refuses OFFSET, limits each project to 3 queries at a time and debits every query from an hourly read budget.
- List insightsGETLists the insights of the project with id, short_id, name, description and query. Unless basic is true, each one also carries its cached result. Page with limit and offset.
- Get insightGETReturns one insight with its query and result. By default the result comes from the cache, and refresh set to blocking calculates it again when it is stale.
- List dashboardsGETLists the dashboards of the project with id, name, description, pinned and tags. Page with limit and offset.
- Get dashboardGETReturns one dashboard with its filters and tiles, each tile with its insight and the cached result.
- List personsGETLists the persons of the project with their distinct_ids and properties. search finds them by email, name, person id or distinct id. Page with limit and offset.
- List cohortsGETLists the cohorts of the project with id, name, description, count of persons and whether they are static. Page with limit and offset.
- List annotationsGETLists the annotations of the project, the notes pinned to a moment on the charts, with id, content, date_marker and scope. Page with limit and offset.
API key
Your customer pastes the app's key on a Connect screen, or your system sends the key with POST /api/customer-toolkits, with no screen.
When connecting, your customer also enters {region}: the address of their account on the app's API.
Questions about the PostHog toolkit
Do I need to build against the PostHog API?
No. Connect ships 12 PostHog tools, described and ready. Your customer connects the account and your system calls every tool through the same endpoint, with the same request format.
How does my customer connect their PostHog account?
With the mode the toolkit accepts: API key. Connect stores the credential encrypted and never returns it to your system.
Does it work with AI agents?
Yes. Each tool's input is described in JSON Schema, which your agent uses directly as a tool definition. The agent picks the tool and the arguments, and your system makes the call to Connect.
Does my customer need a Reportei account?
No. Your customer connects the account on a Connect screen, or your system sends the credential through the API, and they keep using only your product.
See Connect applied to your product.
Try it for 15 days with no card, or walk our team through your use case.
