Skip to content

feat(backend): add the enterpriseConnection.created webhook event type - #10950

Open
paulogdm wants to merge 2 commits into
mainfrom
feat/backend-enterprise-connection-created-webhook
Open

paulogdm wants to merge 2 commits into
mainfrom
feat/backend-enterprise-connection-created-webhook

Conversation

@paulogdm

Copy link
Copy Markdown
Contributor

Description

Clerk is adding an enterpriseConnection.created webhook, sent whenever an enterprise (SSO) connection is created: through the Backend API, through organization self-serve SSO, or in the Dashboard. WebhookEvent doesn't know this event type, so verifyWebhook() can't narrow it, and a handler that switches on evt.type gets no typed payload for it.

This adds EnterpriseConnectionWebhookEvent to WebhookEvent and exports it. The payload is the same enterprise connection object the Backend API returns, so it reuses the existing EnterpriseConnectionJSON. data.id keeps the string | undefined type existing handlers rely on across all events.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude Code

Clerk is adding an enterpriseConnection.created webhook whose payload is the
Backend API enterprise connection object. Add it to WebhookEvent so
verifyWebhook() narrows the event to EnterpriseConnectionJSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 23, 2026 3:49pm UTC
mosaic-docs Ready Ready Preview Nov 23, 2026 3:49pm UTC
swingset Ready Ready Preview Nov 23, 2026 3:49pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6161697

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/swingset Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The backend webhook event types now include enterpriseConnection.created with an EnterpriseConnectionJSON payload. The public API exports the new event type. Related JSON types gain optional directory_path and redirect_uri fields. Type-level tests cover event membership and payload types. A changeset documents the addition.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: jescalan, mauricioabreu, tmilewski

Merge Risk: Minimal · up to 61616

This adds a typed enterpriseConnection.created webhook event and two optional fields. It is additive and type-only, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding the enterpriseConnection.created webhook event type to the backend package. The changeset adds EnterpriseConnectionWebhookEvent to WebhookEvent and exports it, …
Description check Passed The description explains the new enterpriseConnection.created webhook, why WebhookEvent lacked it, and the change that adds EnterpriseConnectionWebhookEvent and reuses EnterpriseConnectionJSON. It dir…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: adding the enterpriseConnection.created webhook event type to the backend package. The changeset adds EnterpriseConnectionWebhookEvent to WebhookEvent and exports it, which matches the title. The title is concise and specific.

Full details: Description check

Explanation

The description explains the new enterpriseConnection.created webhook, why WebhookEvent lacked it, and the change that adds EnterpriseConnectionWebhookEvent and reuses EnterpriseConnectionJSON. It directly describes the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: clerk/javascript
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: f9d5b3a
  • Layers: Repository YAML (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 1770c05b-36a0-4500-a167-66db2fedca94
Commits

Reviewing files that changed from the base of the PR and between f9d5b3a and 6161697.

Files selected for processing: 5

  • .changeset/enterprise-connection-created-webhook.md
  • packages/backend/src/__tests__/enterprise-connection-webhook.test.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/resources/Webhooks.ts
  • packages/backend/src/index.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

Finishing Touches
Fix failing CI checks

  • Commit to this branch
  • Create a new PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10950

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10950

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10950

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10950

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10950

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10950

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10950

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10950

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10950

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10950

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10950

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10950

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10950

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10950

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10950

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10950

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10950

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10950

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10950

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10950

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10950

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10950

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10950

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10950

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10950

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10950

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10950

commit: 6161697

@blacksmith-sh

blacksmith-sh Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Matches verifyWebhook narrows enterpriseConnection.created

The same handler fails tsc on the base build (5 errors, event type not in union) and compiles clean on the PR head; a signed enterpriseConnection.created payload verifies at runtime.

Base fails, head passes

Proof on 61616971 · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@github-actions

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-23T15:57:16.268Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 2
🟢 Additions 4

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/backend

Current version: 3.31.4
Recommended bump: MINOR → 3.32.0

Subpath .

🟡 Non-breaking Changes (1)

Modified: WebhookEvent
- export type WebhookEvent = UserWebhookEvent | SessionWebhookEvent | EmailWebhookEvent | EmailDeliveryWebhookEvent | SMSWebhookEvent | DirectoryGroupWebhookEvent | DirectoryGroupMembershipWebhookEvent | OrganizationWebhookEvent | OrganizationDomainWebhookEvent | OrganizationMembershipWebhookEvent | OrganizationInvitationWebhookEvent | OrganizationInvitationAcceptedWebhookEvent | RoleWebhookEvent | PermissionWebhookEvent | WaitlistEntryWebhookEvent | BillingPaymentAttemptWebhookEvent | BillingSubscriptionWebhookEvent | BillingSubscriptionItemWebhookEvent;
+ export type WebhookEvent = UserWebhookEvent | SessionWebhookEvent | EmailWebhookEvent | EmailDeliveryWebhookEvent | SMSWebhookEvent | DirectoryGroupWebhookEvent | DirectoryGroupMembershipWebhookEvent | EnterpriseConnectionWebhookEvent | OrganizationWebhookEvent | OrganizationDomainWebhookEvent | OrganizationMembershipWebhookEvent | OrganizationInvitationWebhookEvent | OrganizationInvitationAcceptedWebhookEvent | RoleWebhookEvent | PermissionWebhookEvent | WaitlistEntryWebhookEvent | BillingPaymentAttemptWebhookEvent | BillingSubscriptionWebhookEvent | BillingSubscriptionItemWebhookEvent;

Static analyzer: Breaking change in type alias WebhookEvent: Type changed: import("@clerk/backend").BillingPaymentAttemptWebhookEvent|import("@clerk/backend").BillingSubscriptionItemWebhookEvent… → import("@clerk/backend").BillingPaymentAttemptWebhookEvent|import("@clerk/backend").BillingSubscriptionItemWebhookEvent…

🤖 AI review (reclassified as non-breaking) (95%): Adding EnterpriseConnectionWebhookEvent to the WebhookEvent union only widens the return type of verifyWebhook; existing consumers reading the discriminated union may encounter a new variant in exhaustive checks (e.g., switch statements), but no previously well-typed code stops compiling — discriminant-narrowed branches still work, and the new variant is simply an addition to a union that is exclusively an output type.

🟢 Additions (3)

Added: EnterpriseConnectionCustomAttributeJSON.directory_path
+ directory_path?: string;

Added property EnterpriseConnectionCustomAttributeJSON.directory_path

Added: EnterpriseConnectionOauthConfigJSON.redirect_uri
+ redirect_uri?: string;

Added property EnterpriseConnectionOauthConfigJSON.redirect_uri

Added: EnterpriseConnectionWebhookEvent
+ export type EnterpriseConnectionWebhookEvent = Webhook<'enterpriseConnection.created', EnterpriseConnectionJSON>;

Added type alias EnterpriseConnectionWebhookEvent

Subpath ./webhooks

🟡 Non-breaking Changes (1)

Modified: WebhookEvent
- export type WebhookEvent = UserWebhookEvent | SessionWebhookEvent | EmailWebhookEvent | EmailDeliveryWebhookEvent | SMSWebhookEvent | DirectoryGroupWebhookEvent | DirectoryGroupMembershipWebhookEvent | OrganizationWebhookEvent | OrganizationDomainWebhookEvent | OrganizationMembershipWebhookEvent | OrganizationInvitationWebhookEvent | OrganizationInvitationAcceptedWebhookEvent | RoleWebhookEvent | PermissionWebhookEvent | WaitlistEntryWebhookEvent | BillingPaymentAttemptWebhookEvent | BillingSubscriptionWebhookEvent | BillingSubscriptionItemWebhookEvent;
+ export type WebhookEvent = UserWebhookEvent | SessionWebhookEvent | EmailWebhookEvent | EmailDeliveryWebhookEvent | SMSWebhookEvent | DirectoryGroupWebhookEvent | DirectoryGroupMembershipWebhookEvent | EnterpriseConnectionWebhookEvent | OrganizationWebhookEvent | OrganizationDomainWebhookEvent | OrganizationMembershipWebhookEvent | OrganizationInvitationWebhookEvent | OrganizationInvitationAcceptedWebhookEvent | RoleWebhookEvent | PermissionWebhookEvent | WaitlistEntryWebhookEvent | BillingPaymentAttemptWebhookEvent | BillingSubscriptionWebhookEvent | BillingSubscriptionItemWebhookEvent;

Static analyzer: Breaking change in type alias WebhookEvent: Type changed: import("@clerk/backend").BillingPaymentAttemptWebhookEvent|import("@clerk/backend").BillingSubscriptionItemWebhookEvent… → import("@clerk/backend").BillingPaymentAttemptWebhookEvent|import("@clerk/backend").BillingSubscriptionItemWebhookEvent…

🤖 AI review (reclassified as non-breaking) (95%): WebhookEvent is only used as an output type (return value of Promise<WebhookEvent> from verifyWebhook); adding a new union member EnterpriseConnectionWebhookEvent widens the return type, which consumers reading the value must handle, but since WebhookEvent is a discriminated union and existing switch/if logic on known type discriminators is unaffected by an additional variant, this is a pure addition to an output union that does not break existing well-typed consumer code.

🟢 Additions (1)

Added: EnterpriseConnectionWebhookEvent
+ export type EnterpriseConnectionWebhookEvent = Webhook<'enterpriseConnection.created', EnterpriseConnectionJSON>;

Added type alias EnterpriseConnectionWebhookEvent


Report generated by Break Check

Last ran on 6161697.

This branch was successfully deployed

2 active deployments
Preview – swingset — 61616971 Deployed Nov 23, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 61616971 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant