: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from posthog.jwt import PosthogJwtAudience
from posthog.scoped_service_jwt import ScopedServiceJwtPurpose
# Minted by the plugin server's "Create AI task" workflow action, verified by the
# workflow_tasks endpoint. Empty (so disabled) in production until provisioned.
TASKS_CREATE_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.TASKS_CREATE,
settings_name="TASKS_CREATE_JWT_SECRETS",
)
# A dedicated key, not TASKS_CREATE_PURPOSE's: both mint from the plugin server for a workflow
# step, but the scoped-JWT rule is narrowest scope, mint a new key for a new use case rather than
# widen an existing one's — a leak of one can't forge the other's calls, on top of the audience
# claim already blocking a legitimate token from replaying at the wrong endpoint.
WORKFLOW_SCOUT_RUN_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.WORKFLOW_SCOUT_RUN,
settings_name="WORKFLOW_SCOUT_RUN_JWT_SECRETS",
)
# Its own key for the same narrowest-scope reason as WORKFLOW_SCOUT_RUN_PURPOSE.
WORKFLOW_CLASSIFY_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.WORKFLOW_CLASSIFY,
settings_name="WORKFLOW_CLASSIFY_JWT_SECRETS",
)
# Its own key, for the same narrowest-scope reason as WORKFLOW_SCOUT_RUN_PURPOSE.
WORKFLOW_VISION_REQUEST_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.WORKFLOW_VISION_REQUEST,
settings_name="WORKFLOW_VISION_REQUEST_JWT_SECRETS",
)
# Its own key, for the same narrowest-scope reason as WORKFLOW_SCOUT_RUN_PURPOSE.
WORKFLOW_ADD_TO_STATIC_COHORT_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.WORKFLOW_ADD_TO_STATIC_COHORT,
settings_name="WORKFLOW_ADD_TO_STATIC_COHORT_JWT_SECRETS",
)
# Its own key, for the same narrowest-scope reason as WORKFLOW_SCOUT_RUN_PURPOSE.
WORKFLOW_MESSAGE_OPT_OUT_PURPOSE = ScopedServiceJwtPurpose(
audience=PosthogJwtAudience.WORKFLOW_MESSAGE_OPT_OUT,
settings_name="WORKFLOW_MESSAGE_OPT_OUT_JWT_SECRETS",
)