Keys / PostHog
POSTHOG_API_KEY
The project token your app sends events and evaluates feature flags with. PostHog says it's fine to make public: it can't read your data.
- Starts with
phc_- Expires
- never, until you reset it
- API
- reset with the projects
reset_tokenendpoint
Get it
Create one on us.posthog.com/settings/project. The steps aren't recorded yet.
Set it
POSTHOG_API_KEY=phc_...
The PHP SDK reads it when POSTHOG_PROJECT_TOKEN isn't set, and the Rails generator's config reads it. Other SDKs take the token as an argument. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- Resetting the project token stops the old one at once, so events and feature flags fail until every client has the new token. Prepare the rollout first.
- In the project settings, reset the project token, then deploy it everywhere that reads
POSTHOG_API_KEY, including frontend builds. - Check that events arrive again in the project.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.