# How to build a PostHog integration with the provisioning API

DevFeed: [How to build a PostHog integration with the provisioning API](<https://devfeed.tech/articles/how-to-build-a-posthog-integration-with-the-provisioning-api-80509.md>)

Original publisher: [Read original article](<https://posthog.com/blog/embedded-analytics-provisioning-api>)

Author: Matt Brooker

Published: 2026-07-07T00:00:00Z

Content type: tutorial

Language: en

Sources: [PostHog](<https://devfeed.tech/sources/posthog.md>)

Topics: [Provisioning](<https://devfeed.tech/topics/provisioning.md>), [self-service](<https://devfeed.tech/topics/self-service.md>), [API Governance](<https://devfeed.tech/topics/api-governance.md>)

Tags: [about](<https://devfeed.tech/tags/about.md>), [access-tokens](<https://devfeed.tech/tags/access-tokens.md>), [account](<https://devfeed.tech/tags/account.md>), [added](<https://devfeed.tech/tags/added.md>), [api](<https://devfeed.tech/tags/api.md>), [arts](<https://devfeed.tech/tags/arts.md>), [better](<https://devfeed.tech/tags/better.md>), [build](<https://devfeed.tech/tags/build.md>), [farm](<https://devfeed.tech/tags/farm.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [i](<https://devfeed.tech/tags/i.md>), [integration](<https://devfeed.tech/tags/integration.md>), [little](<https://devfeed.tech/tags/little.md>), [live](<https://devfeed.tech/tags/live.md>), [my](<https://devfeed.tech/tags/my.md>), [plants](<https://devfeed.tech/tags/plants.md>), [provisioning](<https://devfeed.tech/tags/provisioning.md>), [shares](<https://devfeed.tech/tags/shares.md>), [website](<https://devfeed.tech/tags/website.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

HogFarm uses PostHog's provisioning API to create a project for each farm and show analytics inside its own dashboard. The integration registers a public Client ID Metadata Document (CIMD); its URL must match the client_id and be reachable, and its scopes cap what tokens may request. Since the client has no secret, token exchange uses PKCE. Account creation returns a code directly for a new email, but existing PostHog users must consent in a browser; API calls pin version 0.1d. The project response provides an API key and team ID. HogFarm publishes saved Endpoints for recurring dashboard queries; their default result caching can preserve an empty first response, so the example forces refresh for newly provisioned projects. Session recording also requires enabling it at project level. The example queries recordings and enables public sharing for an iframe, noting that anyone with the link can view a shared recording. For demo events with backdated timestamps, the regular capture pipeline makes them queryable within seconds, while historical_migration can take many minutes.

## Source excerpt

I live on a little farm and recently built a website to sell shares of hogs. My fellow farmers are better versed in the subtle arts of soil, plants...