> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Personal API keys Canonical URL: https://posthog.com/docs/api/personal-api-keys > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://us.posthog.com` or `https://app.posthog.com` (app host for links). Personal API keys authenticate requests to PostHog's private `GET`, `POST`, `PATCH`, and `DELETE` endpoints. They're the right choice when you're using PostHog from your own scripts, automations, or any integration tied to your own account. > **Building an app that other PostHog users will install or connect to?** Use [OAuth](https://posthog.com/docs/api/oauth.md) instead so users can grant your app scoped access without sharing their own keys. Personal API keys can enable full access to your account, like logging in with your email and password. You can create multiple, give them different scopes, and each can be invalidated individually. This improves the security of your PostHog account. Personal API keys need to be kept private and shouldn't be used in the frontend. #### How to obtain a personal API key 1. Go to the [Personal API keys](https://us.posthog.com/settings/user-api-keys) section in your account settings 2. Click **\+ Create a personal API Key**. 3. Give your key a label - this is just for you, usually to describe the key's purpose. 4. Choose the scopes for your key. We recommended selecting only the scopes required for the API endpoints you really need. This is a security best practice. You can always modify the scopes later if you need to. See [API scopes](https://posthog.com/docs/api/scopes.md) for what each scope covers. 5. At the top of the list, you should see your brand new key. **Immediately** copy its value, as you'll **never** see it again after refreshing the page. You can create up to 10 personal API keys. Personal API keys are deleted when a user is deleted. #### Rolling and upgrading legacy keys Personal API keys created before February 2024 use legacy PBKDF2 hashing. These keys still work, but use an older, slower hashing method. They display a **Legacy** status tag in the keys table. To upgrade a legacy key to the modern sha256 hashing format: 1. Click on the key in the keys table to open the edit modal. 2. Click **Roll key** in the warning banner. 3. Confirm the action in the dialog. Rolling a key generates a new key value and invalidates the old one. Update the new key value wherever the old key was used. ## How to authenticate using the personal API key There are two options: 1. Use the `Authorization` header and `Bearer` authentication, like so: ```javascript const headers = { Authorization: `Bearer ${POSTHOG_PERSONAL_API_KEY}`, }; ``` 2. Put the key in request body, like so: ```javascript const body = { personal_api_key: POSTHOG_PERSONAL_API_KEY, }; ``` Any one of these methods works, but only the value encountered first (in the order above) will be used for authentication. ## Viewing keys with organization access Organization admins and owners can view all personal API keys that have access to their organization or its projects. This is useful for auditing which keys exist, who owns them, and what they can do. To view these keys, go to [**Settings** > **Organization** > **Security**](https://app.posthog.com/settings/organization-security#organization-personal-api-keys) and look for the **Personal API key access** section. The table lists every member's key that can reach the organization – including organization-scoped, project-scoped, and unscoped keys. For each key, you can see: - **Owner** – The member's name and email - **Masked value** – A display-safe hint (e.g., `phx_***1234`) that matches what the owner sees in their own settings - **Scopes** – The API scopes granted to the key (e.g., `insight:read`), or `*` for full access - **Access scope** – Whether the key applies organization-wide, to specific projects, or to all projects (unscoped) - **Last used** – When the key was last used to authenticate - **Created** – When the key was created You can search the table by owner name, email, or scope. Click any of the **Owner**, **Masked value**, **Last used**, or **Created** column headers to sort the table. The table is paginated at 25 rows per page. The actual key secret is never exposed – only the masked value is shown. > **Note:** This feature requires a plan that includes organization security settings and is only visible to organization admins and owners.