Skip to content

Conversation

@stacurry
Copy link
Contributor

Description

Adds support for invitation.accepted and invitation.revoked events

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@linear
Copy link

linear bot commented Aug 19, 2025

@stacurry stacurry marked this pull request as ready for review August 19, 2025 22:01
@stacurry stacurry requested a review from a team as a code owner August 19, 2025 22:01
@stacurry stacurry requested a review from gcarvelli August 19, 2025 22:01
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds support for two new invitation-related webhook events: invitation.accepted and invitation.revoked. The changes extend the existing event handling system in the WorkOS Node.js SDK to properly handle the complete invitation lifecycle.

The implementation follows the established patterns in the codebase:

  1. Interface definitions: New TypeScript interfaces are added to event.interface.ts for both events, including both regular Event and EventResponse variants (InvitationAcceptedEvent, InvitationRevokedEvent, InvitationAcceptedEventResponse, InvitationRevokedEventResponse)

  2. Event serialization: The event serializer is updated to handle these new event types by extending the existing switch case that already handles invitation.created events

  3. Type safety: The new interfaces are properly added to the Event and EventResponse union types, ensuring TypeScript can correctly discriminate between different event types

Both new events reuse the existing deserializeInvitationEvent function since they share the same data structure as the invitation.created event. This makes sense because all invitation events contain the same invitation object with fields like state, acceptedAt, and revokedAt - the event type indicates what triggered the webhook, while the invitation's state field reflects the current status.

This change enables applications using the WorkOS SDK to listen for and respond to all stages of the invitation process, not just creation. The implementation maintains consistency with other event types in the SDK and follows the established webhook event patterns.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects simple, well-structured changes following established patterns with proper type safety
  • No files require special attention

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@stacurry stacurry merged commit 17486fb into main Aug 20, 2025
5 checks passed
@stacurry stacurry deleted the auth-5069-invite-events branch August 20, 2025 14:53
@stacurry stacurry mentioned this pull request Aug 20, 2025
stacurry added a commit that referenced this pull request Aug 20, 2025
## Description

version bump that includes:
- #1340
- #1341
- #1343

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants