Skip to content

Conversation

@stanleyphu
Copy link
Contributor

Description

Adds support for recently added api key events: api_key.created and api_key.deleted

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.

@stanleyphu stanleyphu requested a review from a team as a code owner January 7, 2026 19:47
@stanleyphu stanleyphu requested a review from nholden January 7, 2026 19:47
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 7, 2026

Greptile Summary

This PR adds support for two new API key events: api_key.created and api_key.deleted. The implementation follows the established pattern used for other events in the codebase.

Key Changes

  • added ApiKeyCreatedEvent, ApiKeyDeletedEvent interfaces and their response types (ApiKeyCreatedEventResponse, ApiKeyDeletedEventResponse) in event.interface.ts
  • integrated new event types into the Event and EventResponse union types
  • added deserialization cases in event.serializer.ts to handle the new events using deserializeApiKey
  • imported necessary types (ApiKey, SerializedApiKey) and deserializer function

The changes are consistent with the pattern established by the recent PR #1433 for invitation events and align with all other event types in the codebase. The implementation correctly handles the conversion between snake_case API responses (SerializedApiKey) and camelCase SDK types (ApiKey).

Confidence Score: 5/5

  • This PR is safe to merge with no issues
  • The implementation is simple, follows established patterns consistently, has proper TypeScript typing, and only adds new event support without modifying existing functionality
  • No files require special attention

Important Files Changed

Filename Overview
src/common/interfaces/event.interface.ts added ApiKeyCreatedEvent, ApiKeyDeletedEvent interfaces and their response types, correctly integrated into Event and EventResponse unions
src/common/serializers/event.serializer.ts added deserialization cases for api_key.created and api_key.deleted events using deserializeApiKey, following existing patterns

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant Webhook as Webhook Handler
    participant Deserializer as Event Deserializer
    participant SDK as SDK Client

    API->>Webhook: POST webhook event<br/>(api_key.created/deleted)
    Note over Webhook: EventResponse<br/>(snake_case)
    Webhook->>Deserializer: deserializeEvent(eventResponse)
    Deserializer->>Deserializer: Extract eventBase<br/>(id, createdAt)
    Deserializer->>Deserializer: Match event type<br/>(api_key.created/deleted)
    Deserializer->>Deserializer: deserializeApiKey(event.data)
    Note over Deserializer: Converts SerializedApiKey<br/>to ApiKey (camelCase)
    Deserializer->>SDK: Return Event object
    Note over SDK: ApiKeyCreatedEvent/<br/>ApiKeyDeletedEvent
Loading

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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@stanleyphu stanleyphu merged commit 8962829 into main Jan 7, 2026
7 checks passed
@stanleyphu stanleyphu deleted the feat/add-api-key-events-support branch January 7, 2026 22:17
@stanleyphu stanleyphu mentioned this pull request Jan 7, 2026
stanleyphu added a commit that referenced this pull request Jan 7, 2026
## Description

Includes:
- #1437
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.

4 participants