Merged
Conversation
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Added new apiKeys.validateApiKey method to the SDK that exposes WorkOS's API key validation endpoint. The implementation follows established patterns in the codebase.
- New
ApiKeysclass withvalidateApiKeymethod that sends POST requests to/api_keys/validations - Proper serialization/deserialization for snake_case API responses to camelCase SDK format
- Handles both valid API key responses and null (invalid) responses correctly
- Comprehensive test coverage for valid and invalid key scenarios
- No security issues detected - API key values are only sent in the request payload, not logged
- Consistent with existing SDK patterns for error handling and type definitions
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- Clean implementation following established SDK patterns with comprehensive test coverage and no security concerns
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/api-keys/api-keys.ts | 5/5 | New ApiKeys class with validateApiKey method for API key validation endpoint |
| src/api-keys/api-keys.spec.ts | 5/5 | Comprehensive tests for valid and invalid API key scenarios |
| src/api-keys/interfaces/validate-api-key.interface.ts | 5/5 | Request and response interfaces for API key validation, handles null responses correctly |
| src/workos.ts | 5/5 | Added apiKeys instance to main WorkOS class |
Sequence Diagram
sequenceDiagram
participant App as Developer Application
participant SDK as WorkOS SDK
participant API as WorkOS API
App->>SDK: workos.apiKeys.validateApiKey({ value })
SDK->>SDK: Serialize request payload
SDK->>API: POST /api_keys/validations
Note over SDK,API: Payload: { value: "sk_..." }
API->>API: Validate API key
alt Valid API Key
API-->>SDK: { api_key: { id, owner, permissions, ... } }
SDK->>SDK: Deserialize response
SDK-->>App: { apiKey: ApiKey }
else Invalid API Key
API-->>SDK: { api_key: null }
SDK->>SDK: Deserialize response
SDK-->>App: { apiKey: null }
end
8 files reviewed, no comments
nicknisi
approved these changes
Oct 28, 2025
Merged
nholden
added a commit
that referenced
this pull request
Oct 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We're introducing API keys to help developers provide secure authentication to their APIs. This PR exposes the validate API key endpoint, which is currently under development and looks like this:
Here's what a call to this new method might look like in a developer's application:
Documentation
This will require a docs change, which will come in a future PR.