Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

9.8 KB
Raw Blame
// AUTO-GENERATED by posthog/scopes_projection.py from posthog/scopes.py.
// Regenerate with `hogli build:projections`. Do not edit.
//
// The OAuth scopes a client can request, from get_oauth_scopes_supported().
// The MCP server publishes this list as `scopes_supported` in its
// protected-resource metadata (RFC 9728). The web app's consent screen
// expands a wildcard grant to the read scopes in this list when the server
// sends no computed list. The OAuth authorization server publishes the same
// list at `/.well-known/oauth-authorization-server`. If the lists differ, a
// spec-compliant client (e.g. Claude Code) fails sign-in with `invalid_scope`.

export const OAUTH_SCOPES_SUPPORTED = [
    'openid',
    'profile',
    'email',
    'introspection',
    'action:read',
    'action:write',
    'access_control:read',
    'access_control:write',
    'account:read',
    'account:write',
    'activity_log:read',
    'activity_log:write',
    'alert:read',
    'alert:write',
    'annotation:read',
    'annotation:write',
    'approvals:read',
    'approvals:write',
    'autoresearch:read',
    'autoresearch:write',
    'batch_export:read',
    'batch_export:write',
    'batch_import:read',
    'batch_import:write',
    'billing:read',
    'billing:write',
    'business_knowledge:read',
    'business_knowledge:write',
    'canvas:read',
    'canvas:write',
    'cohort:read',
    'cohort:write',
    'comment:read',
    'comment:write',
    'conversation:read',
    'conversation:write',
    'cross_project_dashboard:read',
    'cross_project_dashboard:write',
    'customer_analytics:read',
    'customer_analytics:write',
    'customer_task:read',
    'customer_task:write',
    'customer_journey:read',
    'customer_journey:write',
    'customer_profile_config:read',
    'customer_profile_config:write',
    'data_catalog:read',
    'data_catalog:write',
    'data_catalog_approval:read',
    'data_catalog_approval:write',
    'data_deletion:read',
    'data_deletion:write',
    'dashboard:read',
    'dashboard:write',
    'event_filter:read',
    'event_filter:write',
    'dashboard_template:read',
    'dashboard_template:write',
    'dataset:read',
    'dataset:write',
    'early_access_feature:read',
    'early_access_feature:write',
    'endpoint:read',
    'endpoint:write',
    'engineering_analytics:read',
    'engineering_analytics:write',
    'error_tracking:read',
    'error_tracking:write',
    'evaluation:read',
    'evaluation:write',
    'element:read',
    'element:write',
    'event_definition:read',
    'event_definition:write',
    'experiment:read',
    'experiment:write',
    'experiment_holdout:read',
    'experiment_holdout:write',
    'experiment_saved_metric:read',
    'experiment_saved_metric:write',
    'export:read',
    'export:write',
    'external_data_schema:read',
    'external_data_schema:write',
    'external_data_source:read',
    'external_data_source:write',
    'feature_flag:read',
    'feature_flag:write',
    'file_system:read',
    'file_system:write',
    'file_system_shortcut:read',
    'file_system_shortcut:write',
    'group:read',
    'group:write',
    'health_issue:read',
    'health_issue:write',
    'heatmap:read',
    'heatmap:write',
    'hog_flow:read',
    'hog_flow:write',
    'hog_function:read',
    'hog_function:write',
    'inbox:read',
    'inbox:write',
    'ingestion_warning:read',
    'ingestion_warning:write',
    'insight:read',
    'insight:write',
    'insight_variable:read',
    'insight_variable:write',
    'integration:read',
    'integration:write',
    'knowledge_writer:read',
    'knowledge_writer:write',
    'legal_document:read',
    'legal_document:write',
    'link:read',
    'link:write',
    'live_debugger:read',
    'live_debugger:write',
    'llm_analytics:read',
    'llm_analytics:write',
    'ai_observability_clusters:read',
    'ai_observability_clusters:write',
    'llm_playground:read',
    'llm_playground:write',
    'llm_prompt:read',
    'llm_prompt:write',
    'llm_provider_key:read',
    'llm_provider_key:write',
    'llm_skill:read',
    'llm_skill:write',
    'logs:read',
    'logs:write',
    'loop:read',
    'loop:write',
    'marketing_analytics:read',
    'marketing_analytics:write',
    'mcp_analytics:read',
    'mcp_analytics:write',
    'mcp_registry:read',
    'mcp_registry:write',
    'metrics:read',
    'metrics:write',
    'notebook:read',
    'notebook:write',
    'offline_evaluation_ingestion:read',
    'offline_evaluation_ingestion:write',
    'organization:read',
    'organization:write',
    'organization_integration:read',
    'organization_integration:write',
    'organization_member:read',
    'organization_member:write',
    'person:read',
    'person:write',
    'plugin:read',
    'plugin:write',
    'product_enablement:read',
    'product_enablement:write',
    'product_tour:read',
    'product_tour:write',
    'project:read',
    'project:write',
    'property_definition:read',
    'property_definition:write',
    'query:read',
    'query:write',
    'replay_scanner:read',
    'replay_scanner:write',
    'review_hog:read',
    'review_hog:write',
    'revenue_analytics:read',
    'revenue_analytics:write',
    'session_recording:read',
    'session_recording:write',
    'session_recording_playlist:read',
    'session_recording_playlist:write',
    'sharing_configuration:read',
    'sharing_configuration:write',
    'signal_scout:read',
    'signal_scout:write',
    'signal_usage:read',
    'signal_usage:write',
    'stamphog:read',
    'stamphog:write',
    'streamlit_app:read',
    'streamlit_app:write',
    'subscription:read',
    'subscription:write',
    'support_ticket:read',
    'support_ticket:write',
    'survey:read',
    'survey:write',
    'tagger:read',
    'tagger:write',
    'ticket:read',
    'ticket:write',
    'task:read',
    'task:write',
    'today:read',
    'today:write',
    'toolbar:read',
    'toolbar:write',
    'tracing:read',
    'tracing:write',
    'transactional_email:read',
    'transactional_email:write',
    'field_note:read',
    'field_note:write',
    'uploaded_media:read',
    'uploaded_media:write',
    'usage_metric:read',
    'usage_metric:write',
    'user:read',
    'user:write',
    'user_interview:read',
    'user_interview:write',
    'vision_action:read',
    'vision_action:write',
    'vision_alert:read',
    'vision_alert:write',
    'visual_review:read',
    'visual_review:write',
    'warehouse_objects:read',
    'warehouse_objects:write',
    'warehouse_table:read',
    'warehouse_table:write',
    'warehouse_view:read',
    'warehouse_view:write',
    'web_analytics:read',
    'web_analytics:write',
    'webhook:read',
    'webhook:write',
    'workload_trust_policy:read',
    'workload_trust_policy:write',
    'workload_trust_policy_request:read',
    'workload_trust_policy_request:write',
] as const

export type OAuthScope = (typeof OAUTH_SCOPES_SUPPORTED)[number]

// PAT-grantable but deliberately absent from OAUTH_SCOPES_SUPPORTED, so OAuth
// clients can never request them (mirrors OAUTH_SCOPES_HIDDEN in posthog/scopes.py).
// The MCP server shows a tool that requires one of these only to a staff user
// whose personal API key carries it (plus `user:read` for the staff lookup);
// `*` does not match. The web app's scope pickers never show these objects.
export const OAUTH_SCOPES_HIDDEN = [
    'batch_import_support:read',
    'batch_import_support:write',
    'messaging_preference:read',
    'messaging_preference:write',
    'query_performance:read',
    'query_performance:write',
    'wizard_run:read',
    'wizard_run:write',
    'wizard_session:read',
    'wizard_session:write',
] as const

// A new scope object mapped to the legacy one it split off (mirrors LEGACY_SCOPE_FALLBACKS
// in posthog/scopes.py). While old tokens carry only the legacy scope, a held
// `<legacy>:<action>` satisfies a required `<new>:<action>`.
export const LEGACY_SCOPE_FALLBACKS: ReadonlyMap<string, string> = new Map([
    ['inbox', 'task'],
    ['messaging_preference', 'hog_flow'],
    ['transactional_email', 'hog_flow'],
])

// What each risky scope lets a token do (mirrors RISKY_SCOPE_WARNINGS in posthog/scopes.py).
// Scope pickers show it next to the scope, so people add it with care.
export const RISKY_SCOPE_WARNINGS: Readonly<Record<string, string>> = {
    'access_control:write': 'Changes who can access resources in this project.',
    'approvals:write': 'Approves or rejects change requests that gate other changes.',
    'autoresearch:write': 'Starts agent runs that get their own longer-lived token.',
    'billing:read': "Reads the whole organization's billing details, not just this project's.",
    'billing:write': "Changes the organization's subscription and payment details.",
    'hog_flow:write': "Runs workflow code that can use the stored credentials of the project's integrations.",
    'hog_function:write':
        "Runs code, including on your website, that can use the stored credentials of the project's integrations.",
    'integration:write': 'Connects and changes third-party integrations and their stored credentials.',
    'llm_provider_key:write': 'Stores and changes LLM provider API keys.',
    'organization:write': 'Changes organization settings, including roles and OAuth apps.',
    'organization_integration:write':
        'Connects and changes organization-wide integrations and their stored credentials.',
    'organization_member:write':
        "Invites and removes organization members and changes their roles, so it can give people access beyond this token's scopes.",
    'sharing_configuration:read':
        'Reads the access tokens of public sharing links, which keep working after this token expires.',
    'sharing_configuration:write': 'Creates public sharing links that anyone with the link can open.',
    'user:read':
        'Reads the account details of the user the token acts as, including every organization and project they belong to.',
    'user:write': 'Changes the account of the user the token acts as.',
}