Linking Clerk as a source

Let AI connect your sources for you

Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog.

Learn more
PostHog Wizard hedgehog

Contents

The Clerk connector can link users, organizations, organization memberships, and invitations to PostHog. The users, organizations, and organization_memberships tables also support webhook syncing for near-real-time updates.

Choosing a sync mode

Clerk tables can be synced in one of two modes:

  • Webhook sync (recommended for supported tables). Clerk pushes events to PostHog in real time, so creates and updates land within seconds. This is the only way to get near-real-time Clerk data because the Clerk API doesn't support filtering by updated_at. Available for the users, organizations, and organization_memberships tables. See Setting up webhooks for real-time syncing below.
  • Full refresh sync. PostHog re-downloads every row each sync. This is the only option for tables that don't support webhooks. The larger your Clerk instance gets, the slower and more costly each sync becomes.

Webhook sync does not remove deleted records. Clerk delete events (user.deleted, organization.deleted) only carry the record ID, so PostHog cannot match them to existing rows. To remove deleted records, resync the table.

To link Clerk:

  1. Go to the sources tab of the data pipeline section in PostHog.

  2. Click + New source and then click Link next to Clerk.

  3. Next, you need a secret key from Clerk. Go to your API keys settings in Clerk. Copy the Secret key value.

  4. Back in PostHog, paste the secret key in the Secret key field and click Next.

  5. On the next page, set up the schemas you want to sync and modify the method and frequency as needed. Once done, click Import.

Once the syncs are complete, you can start using Clerk data in PostHog.

Configuration

OptionTypeRequired
Secret keypasswordYes

Supported tables

TableDescriptionSync methodIncremental fieldPrimary key
users

A user account in the Clerk instance, including identity and authentication details.

Webhook, Full refresh——
organizations

An organization in the Clerk instance that groups users into a shared team.

Webhook, Full refresh——
organization_memberships

A membership linking a user to an organization, with their role in it.

Webhook, Full refresh——
invitations

An invitation sent to an email address to join the Clerk instance.

Full refresh——
sessions

A session created when a user signs in, tracking that sign-in until it ends or expires.

Full refresh——
organization_invitations

An invitation asking a user to join an organization in the Clerk instance.

Full refresh——
organization_domains

A verified email domain attached to an organization, used to enroll matching users.

Full refresh——
organization_roles

A role that can be assigned to members of an organization, with the permissions it grants.

Full refresh——
organization_permissions

A permission that can be granted to an organization role.

Full refresh——
role_sets

A named set of organization roles, including the default and creator roles it assigns.

Full refresh——
waitlist_entries

An email address on the instance waitlist, with where it is in the waitlist flow.

Full refresh——
allowlist_identifiers

An email address, phone number or domain allowed to sign up to the Clerk instance.

Full refresh——
blocklist_identifiers

An email address, domain, phone number or wallet blocked from signing up to the instance.

Full refresh——
domains

A primary or satellite domain the Clerk instance is served from.

Full refresh——
saml_connections

A SAML connection linking the Clerk instance to an external identity provider.

Full refresh——
enterprise_connections

An enterprise SSO connection (SAML, OIDC or EASIE) configured on the Clerk instance.

Full refresh——
oauth_applications

An OAuth application registered on the Clerk instance so other apps can sign users in with it.

Full refresh——
machines

A machine identity that can authenticate to the Clerk instance without a user.

Full refresh——
api_keys

An API key issued by the Clerk instance to a user, organization or machine.

Full refresh——
m2m_tokens

A machine-to-machine token minted for a machine identity.

Full refresh——
redirect_urls

A URL allowed as a redirect target for the Clerk instance's authentication flows.

Full refresh——
jwt_templates

A template describing the claims Clerk puts into JWTs it mints for your app.

Full refresh——
email_templates

An email template the Clerk instance sends, either the Clerk default or your override.

Full refresh——
sms_templates

An SMS template the Clerk instance sends, either the Clerk default or your override.

Full refresh——
commerce_plans

A billing plan users or organizations can subscribe to through Clerk billing.

Full refresh——
commerce_subscription_items

A subscription to a Clerk billing plan held by a user or an organization.

Full refresh——

Setting up webhooks for real-time syncing

Webhook syncing is the recommended mode for users, organizations, and organization_memberships. Without it, every sync is a full refresh that re-downloads all rows.

Clerk does not support automatic webhook creation, so you need to set up the webhook manually in the Clerk Dashboard.

  1. In PostHog, go to your Clerk source in the data pipeline sources tab and click the Webhook tab. Copy the webhook URL shown there.
  2. In the Clerk Dashboard, go to Configure > Webhooks and click Add Endpoint.
  3. Paste the PostHog webhook URL into the Endpoint URL field.
  4. Subscribe to the events for the tables you want to sync (see table below).
  5. Save the endpoint, then click on it to reveal the Signing Secret (it starts with whsec_).
  6. Back in PostHog, paste the signing secret into the Signing secret field on the Webhook tab and save.

Which events to subscribe to

PostHog tableClerk webhook events
usersuser.created, user.updated
organizationsorganization.created, organization.updated
organization_membershipsorganizationMembership.created, organizationMembership.updated

Do not subscribe to delete events (user.deleted, organization.deleted, etc.). They only carry the record ID and cannot be processed. To remove deleted records, resync the table.

Still have questions?

Was this page useful?