Skip to main content
Integrations · PostHog
A Guild agent can query your PostHog project, read analytics data, and manage feature flags without ever handling your API key. Guild stores the credential server-side and injects it through its credential proxy, so your key stays out of agent code, prompts, and state. Credential policies let you restrict which operations each agent can call, and every request is governed before it leaves Guild.

Book a demo

See how teams govern agents that use PostHog.

Start free

Connect PostHog and scope your first agent.

What the PostHog integration exposes

The integration provides tools that cover HogQL queries, events, persons, session recordings, cohorts, dashboards, experiments, actions, feature flags, insights, and annotations on PostHog US Cloud. Tools are prefixed with posthog_us_. The posthog_us_list_projects tool returns project IDs that other tools accept as project_id. Use pick() from the SDK to include only the tools your agent needs.

How it works

1

Create a PostHog personal API key

In PostHog, open your account settings, go to Personal API keys, and create a key with the scopes your agent needs. For example, reading feature flags requires feature_flag:read; changing them requires feature_flag:write.
2

Connect the credential in Guild

Go to Access & setup > Credentials, click Connect, select posthog-us, and paste the key into API Key. Guild sends the key as a bearer token in the Authorization header on every request.
3

Add the tools to your agent

Import PosthogUsTools from the integration package and spread it into your agent’s tools object. Use pick() to include only the tools your agent needs, such as posthog_us_list_projects and posthog_us_run_query.

Why PostHog access needs governing

PostHog personal API keys act as the user who created them, limited only by the scopes granted at creation time. An agent with a broad key can read person profiles, delete persons and their events, create or delete feature flags, and run arbitrary HogQL queries. Guild’s credential policies let you write ALLOW and DENY rules that the credential proxy enforces before any request reaches PostHog, scoped to specific operations, agents, or workspaces. Credentials can be scoped to an account, a single workspace, a single member, or one installed agent, so the right key is used in the right context. Guild stores and injects the key server-side; agent code never sees it. Without this, every agent that needed PostHog access would require its own secret management, with no central audit of what was called or blocked.

About the PostHog integration

The PostHog integration connects agents to a PostHog project on US Cloud (us.posthog.com). Agents can run HogQL queries; read events, persons, session recordings, cohorts, dashboards, experiments, and actions; manage feature flags; and create insights and annotations. The integration is guildai~posthog-us.

Authentication

  • Type: Personal API key
  • Header: Guild sends the key as a bearer token in the Authorization header
A personal API key acts as the PostHog user who created it, limited to the scopes you give it. Grant the scopes for the tools your agent uses: for example, reading feature flags needs feature_flag:read, and changing them needs feature_flag:write.

Setup

1

Create a personal API key

In PostHog, open your account settings, go to Personal API keys, and create a key with the scopes your agent needs.
2

Connect PostHog

In Guild, go to Access & setup > Credentials, click Connect, select posthog-us, and paste the key into API Key.
See Credentials for workspace, member, and agent-scoped credentials.

Usage

Selecting specific tools

Tools are named with the posthog_us_ prefix. posthog_us_list_projects returns each project’s ID, which other tools take as project_id. Use pick() to include only what your agent needs.

Tools

Tools in the latest published version of guildai~posthog-us:

Limitations

  • US Cloud only. Requests go to us.posthog.com, so projects on EU Cloud or self-hosted PostHog aren’t reachable.

Frequently asked questions

No. Requests go to us.posthog.com, so projects on EU Cloud or self-hosted PostHog are not reachable with this integration.
Write a credential policy with DENY rules for mutating operations, or ALLOW rules that cover only read operations such as posthog_us_list_*, posthog_us_get_*, and posthog_us_run_query. Guild’s credential proxy enforces these rules before any request leaves Guild. See credential policies for rule syntax.
Yes. Connect a credential dedicated to that agent from the installed agent’s page in Guild. Guild checks for an agent-dedicated credential before falling back to workspace or account credentials, so that agent uses its own key while others use the shared one.
Not yet. The catalog entry for guildai~posthog-us lists no webhook events, so agents cannot be triggered by PostHog events through this integration.

Put a governed agent on PostHog this week

Book a demo

See how teams govern agents that use PostHog.

Start free

Connect PostHog and scope your first agent.
Read: Docs: Credential policies · Credentials · Tools in agents
Last modified on October 16, 2026