Skip to content

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

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

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

Conversation

@paulogdm

@paulogdm paulogdm commented Nov 23, 2026 •

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, with a new EnterpriseConnectionWebhookEventJSON payload type. The webhook carries object: 'enterprise_connection' and only the connection's id, organization_id, domains, active and created_at, not the full Backend API object, so a handler that needs the name, provider or SAML/OAuth details fetches the connection by id. 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 24, 2026 7:33pm UTC
mosaic-docs Ready Ready Preview Nov 24, 2026 7:33pm UTC
swingset Ready Ready Preview Nov 24, 2026 7:33pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7cb10ba

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 adds enterpriseConnection.created to the WebhookEvent union. Its payload type contains the connection ID, organization ID, domains, active state, and creation timestamp. The backend exports the event and payload types. Type-level tests check event union membership, payload fields, and the verified event resource ID type. A changeset documents the addition.

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

Suggested reviewers: mauricioabreu, tmilewski

Merge Risk: Minimal · up to 7cb10

This adds typing for the enterpriseConnection.created webhook event. It has no runtime behavior change, and existing exhaustive handlers may need a new case, which the changeset documents. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: adding the enterpriseConnection.created webhook event type to the backend package. The changeset adds EnterpriseConnectionWebhookEvent to the WebhookEvent union, along with…
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.
Description check Passed The description states that Clerk adds an enterpriseConnection.created webhook and that this PR adds EnterpriseConnectionWebhookEvent to WebhookEvent with a new EnterpriseConnectionWebhookEventJSON pa…
Full details: Title check

Explanation

The title names the change: adding the enterpriseConnection.created webhook event type to the backend package. The changeset adds EnterpriseConnectionWebhookEvent to the WebhookEvent union, along with its JSON payload type and exports. The title is specific and matches the main change. It uses the conventional feat(backend) prefix.

Full details: Description check

Explanation

The description states that Clerk adds an enterpriseConnection.created webhook and that this PR adds EnterpriseConnectionWebhookEvent to WebhookEvent with a new EnterpriseConnectionWebhookEventJSON payload type. This matches the changeset, the JSON.ts and Webhooks.ts changes, the index.ts exports, and the added type tests. It also covers the payload fields and the fetch-by-id guidance.

  • 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: ada00f0e-0087-44dc-97dc-22639041ce37
Commits

Reviewing files that changed from the base of the PR and between 4786359 and 7cb10ba.

Files selected for processing: 3

  • .changeset/enterprise-connection-created-webhook.md
  • packages/backend/src/__tests__/enterprise-connection-webhook.test.ts
  • packages/backend/src/api/resources/JSON.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.

@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: 7cb10ba

@blacksmith-sh

blacksmith-sh Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Matches verifyWebhook narrows enterpriseConnection.created

On 7cb10ba the handler narrows to the payload with object 'enterprise_connection' and five fields and compiles clean, rejecting name and a wrong object literal; a signed payload verifies at runtime.

Object literal narrows

Proof on 7cb10ba4 (from 4786359d) · Did Proof get it right? Yes · No

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

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-24T19:35:36.913Z

Summary

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

🤖 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) (90%): WebhookEvent is only used as an output type (the return of verifyWebhook via Promise<WebhookEvent>) and as the source for WebhookEventType; adding a new union member EnterpriseConnectionWebhookEvent only widens the output type, which callers already handle via discriminated-union exhaustiveness or switch/if chains that simply gain a new reachable case — existing well-typed consumer code continues to compile correctly.

🟢 Additions (8)

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

Added type alias EnterpriseConnectionWebhookEvent

Added: EnterpriseConnectionWebhookEventJSON
+ export interface EnterpriseConnectionWebhookEventJSON

Added interface EnterpriseConnectionWebhookEventJSON

Added: EnterpriseConnectionWebhookEventJSON.active
+ active: boolean;

Added property EnterpriseConnectionWebhookEventJSON.active

Added: EnterpriseConnectionWebhookEventJSON.created_at
+ created_at: number;

Added property EnterpriseConnectionWebhookEventJSON.created_at

Added: EnterpriseConnectionWebhookEventJSON.domains
+ domains: string[];

Added property EnterpriseConnectionWebhookEventJSON.domains

Added: EnterpriseConnectionWebhookEventJSON.id
+ id: string;

Added property EnterpriseConnectionWebhookEventJSON.id

Added: EnterpriseConnectionWebhookEventJSON.object
+ object: typeof ObjectType.EnterpriseConnection;

Added property EnterpriseConnectionWebhookEventJSON.object

Added: EnterpriseConnectionWebhookEventJSON.organization_id
+ organization_id: string | null;

Added property EnterpriseConnectionWebhookEventJSON.organization_id

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 a return/output type (the resolved Promise<WebhookEvent> from verifyWebhook); adding a new union variant EnterpriseConnectionWebhookEvent widens the output type, which is safe for callers who switch/narrow on it — they simply never encounter the new variant unless the webhook payload matches it.

🟢 Additions (1)

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

Added type alias EnterpriseConnectionWebhookEvent


Report generated by Break Check

Last ran on 7cb10ba.

The enterpriseConnection.created webhook no longer sends the full Backend
API enterprise connection object. Clerk now sends only the connection's
id, organization_id, domains, active and created_at, so typing the event
as EnterpriseConnectionJSON would promise fields like name, provider and
saml_connection that never arrive. Add EnterpriseConnectionWebhookEventJSON
with those five fields and narrow the event to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The webhook payload type was missing the object field Clerk now sends,
and its type test compared the payload to EnterpriseConnectionWebhookEventJSON
itself, so a changed or dropped field still passed. The branch also
carried redirect_uri and directory_path on the nested enterprise
connection JSON types from an earlier version of this PR; the resource
classes drop both in fromJSON, so SDK users never see them.

Add object: 'enterprise_connection' to the payload type, compare the
test against the literal wire shape, remove the two unused fields, move
the payload type next to EnterpriseConnectionJSON, and document that
created_at is in milliseconds.

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

This branch was successfully deployed

2 active deployments
Preview – swingset — 7cb10ba4 Deployed Nov 24, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 7cb10ba4 Deployed Nov 24, 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