Skip to content

Rename api_key.deleted event type to api_key.revoked#1476

Merged
stanleyphu merged 1 commit intoworkos:mainfrom
smorimoto:fix/rename-api-key-deleted-to-revoked
Feb 11, 2026
Merged

Rename api_key.deleted event type to api_key.revoked#1476
stanleyphu merged 1 commit intoworkos:mainfrom
smorimoto:fix/rename-api-key-deleted-to-revoked

Conversation

@smorimoto
Copy link
Contributor

@smorimoto smorimoto commented Feb 11, 2026

Description

The SDK currently defines the API key event type as api_key.deleted, but the actual WorkOS API expects api_key.revoked. This mismatch causes a 400 error when passing api_key.deleted to listEvents():

GenericServerException: Invalid name parameter, received: 'api_key.deleted'. You must pass in valid event names

The WorkOS Events documentation lists this event as "API key revoked event" with the type api_key.revoked.

Changes

src/common/interfaces/event.interface.ts

  • ApiKeyDeletedEventApiKeyRevokedEvent
  • ApiKeyDeletedEventResponseApiKeyRevokedEventResponse
  • Event literal 'api_key.deleted''api_key.revoked'
  • Updated Event and EventResponse union types

src/common/serializers/event.serializer.ts

  • Deserialisation case 'api_key.deleted''api_key.revoked'

This is consistent with other revocable resources in the SDK that already use revoked (e.g. invitation.revoked, session.revoked).

Closes #1475

Documentation

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

  • Yes

The Events documentation already lists the correct event name api_key.revoked. No documentation changes are required.

The SDK currently defines the API key event type as 'api_key.deleted',
but the actual WorkOS API expects 'api_key.revoked'. This mismatch
causes a 400 error when passing 'api_key.deleted' to listEvents():

  GenericServerException: Invalid name parameter, received:
  'api_key.deleted'. You must pass in valid event names

The WorkOS Events documentation
(https://workos.com/docs/events) lists this event as "API key revoked
event" with the type 'api_key.revoked'.

This commit renames in two files:

  - src/common/interfaces/event.interface.ts
    - ApiKeyDeletedEvent -> ApiKeyRevokedEvent
    - ApiKeyDeletedEventResponse -> ApiKeyRevokedEventResponse
    - Event literal 'api_key.deleted' -> 'api_key.revoked'
    - Updated Event and EventResponse union types

  - src/common/serializers/event.serializer.ts
    - Deserialisation case 'api_key.deleted' -> 'api_key.revoked'

This is consistent with other revocable resources in the SDK that
already use 'revoked' (e.g. invitation.revoked, session.revoked).

Closes workos#1475
@smorimoto smorimoto requested a review from a team as a code owner February 11, 2026 17:40
@smorimoto smorimoto requested a review from awolfden February 11, 2026 17:40
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

This PR aligns the SDK’s API key event typing and deserialization logic with the WorkOS API by renaming the event from api_key.deleted to api_key.revoked. It updates the corresponding TypeScript interfaces (ApiKey*Event/ApiKey*EventResponse) and the Event/EventResponse unions, and adjusts deserializeEvent() to map api_key.revoked events into the internal Event shape.

Net effect: callers using EventName/listEvents() will now supply the event name accepted by the API, preventing the 400 error caused by the previous api_key.deleted literal.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are limited to event-name literals, interface renames, and a single deserialization switch case. Repository search shows no remaining references to the removed api_key.deleted literal, so compilation should guide downstream updates. No behavioral changes outside event name alignment.
  • No files require special attention

Important Files Changed

Filename Overview
src/common/interfaces/event.interface.ts Renames the API key event from api_key.deleted to api_key.revoked and updates related interface/type unions; no remaining references to the old event name found in repo.
src/common/serializers/event.serializer.ts Updates event deserialization switch to handle api_key.revoked instead of api_key.deleted; switch remains exhaustive over current EventResponse union.

Sequence Diagram

sequenceDiagram
  autonumber
  participant U as SDK user
  participant E as Events API (listEvents)
  participant S as deserializeEvent()

  U->>E: listEvents({ name: 'api_key.revoked' })
  E-->>U: EventResponse[] (event: 'api_key.revoked')
  U->>S: deserializeEvent(EventResponse)
  S-->>U: Event (event: 'api_key.revoked', data: ApiKey)

  Note over U,E: Previously, SDK types encouraged 'api_key.deleted' which the API rejects (400).
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

Copy link
Contributor

@stanleyphu stanleyphu left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @smorimoto! I'll get this merged and get a new release out.

@stanleyphu stanleyphu merged commit bbabf18 into workos:main Feb 11, 2026
7 checks passed
@stanleyphu stanleyphu mentioned this pull request Feb 11, 2026
stanleyphu added a commit that referenced this pull request Feb 11, 2026
## Description

This releases includes:

- #1476 

## 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.
@smorimoto smorimoto deleted the fix/rename-api-key-deleted-to-revoked branch February 11, 2026 19:05
@smorimoto
Copy link
Contributor Author

Thanks!

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.

api_key.deleted event type should be api_key.revoked

2 participants