Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/blue-teeth-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/backend': minor
---

Add `user_id` field to `organizationInvitation.accepted` webhook events.

Creates a new `OrganizationInvitationAcceptedJSON` interface that extends `OrganizationInvitationJSON` with a required `user_id` field, and updates the webhook type system to use this interface specifically for `organizationInvitation`.accepted events.
4 changes: 4 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ export interface OrganizationInvitationJSON extends ClerkResourceJSON {
expires_at: number;
}

export interface OrganizationInvitationAcceptedJSON extends OrganizationInvitationJSON {
user_id: string;
}

Comment on lines +395 to +398
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the Coderabbit nitpick comment:

Suggested change
export interface OrganizationInvitationAcceptedJSON extends OrganizationInvitationJSON {
user_id: string;
}
export interface OrganizationInvitationAcceptedJSON extends OrganizationInvitationJSON {
status: 'accepted';
user_id: string;
}

/**
* @interface
*/
Expand Down
9 changes: 8 additions & 1 deletion packages/backend/src/api/resources/Webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
DeletedObjectJSON,
EmailJSON,
OrganizationDomainJSON,
OrganizationInvitationAcceptedJSON,
OrganizationInvitationJSON,
OrganizationJSON,
OrganizationMembershipJSON,
Expand Down Expand Up @@ -52,10 +53,15 @@ export type OrganizationMembershipWebhookEvent = Webhook<
>;

export type OrganizationInvitationWebhookEvent = Webhook<
'organizationInvitation.accepted' | 'organizationInvitation.created' | 'organizationInvitation.revoked',
'organizationInvitation.created' | 'organizationInvitation.revoked',
OrganizationInvitationJSON
>;

export type OrganizationInvitationAcceptedWebhookEvent = Webhook<
'organizationInvitation.accepted',
OrganizationInvitationAcceptedJSON
>;
Comment on lines +60 to +63
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new OrganizationInvitationAcceptedWebhookEvent type should be included in the main webhook union types to ensure it's properly recognized by the webhook handling system. Consider adding it to any existing webhook event unions in this file or related files.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add this to the main webhook union types below :)


export type RoleWebhookEvent = Webhook<'role.created' | 'role.updated' | 'role.deleted', RoleJSON>;

export type PermissionWebhookEvent = Webhook<
Expand Down Expand Up @@ -98,6 +104,7 @@ export type WebhookEvent =
| OrganizationDomainWebhookEvent
| OrganizationMembershipWebhookEvent
| OrganizationInvitationWebhookEvent
| OrganizationInvitationAcceptedWebhookEvent
| RoleWebhookEvent
| PermissionWebhookEvent
| WaitlistEntryWebhookEvent
Expand Down
Loading