Skip to content

Conversation

@brandfocus
Copy link

Description

Adds full API key management support to the SDK:

Organizations module:

  • create_api_key(organization_id, name, permissions) - Create an API key for an organization
  • list_api_keys(organization_id, ...) - List API keys with pagination support

API Keys module:

  • delete_api_key(api_key_id) - Delete an API key

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.

@brandfocus brandfocus requested a review from a team as a code owner January 11, 2026 01:33
@brandfocus brandfocus requested a review from faroceann January 11, 2026 01:33
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 11, 2026

Greptile Overview

Greptile Summary

Implements complete API key management functionality for the WorkOS Python SDK, adding creation and listing methods to the Organizations module and a deletion method to the ApiKeys module. All new methods follow established SDK patterns with both synchronous and asynchronous implementations, proper type definitions, and comprehensive test coverage including auto-pagination tests.

Confidence Score: 5/5

  • Safe to merge with confidence—implementation follows all SDK patterns correctly
  • The implementation is clean, consistent, and follows all established patterns in the codebase. Both sync and async variants are properly implemented, type definitions use Pydantic models correctly, pagination support includes organization_id in filter params for auto-pagination, comprehensive tests cover all code paths including edge cases, and no security concerns were identified.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
workos/organizations.py 4/5 Adds create_api_key and list_api_keys methods to Organizations module for both sync and async clients; follows existing patterns consistently
workos/api_keys.py 5/5 Adds delete_api_key method to ApiKeys module for both sync and async clients; implementation is clean and follows SDK patterns
tests/test_organizations.py 4/5 Adds comprehensive tests for create_api_key and list_api_keys including edge cases and auto-pagination; thorough test coverage

Sequence Diagram

sequenceDiagram
    participant Client
    participant Organizations
    participant ApiKeys
    participant HTTPClient
    participant WorkOSAPI

    Note over Client,WorkOSAPI: Create API Key Flow
    Client->>Organizations: create_api_key(org_id, name, permissions)
    Organizations->>HTTPClient: POST /organizations/{org_id}/api_keys
    HTTPClient->>WorkOSAPI: HTTP Request
    WorkOSAPI-->>HTTPClient: ApiKeyWithValue (includes full value)
    HTTPClient-->>Organizations: Response
    Organizations-->>Client: ApiKeyWithValue

    Note over Client,WorkOSAPI: List API Keys Flow
    Client->>Organizations: list_api_keys(org_id, limit, before, after, order)
    Organizations->>HTTPClient: GET /organizations/{org_id}/api_keys
    HTTPClient->>WorkOSAPI: HTTP Request with pagination params
    WorkOSAPI-->>HTTPClient: List response with ApiKey objects
    HTTPClient-->>Organizations: Response
    Organizations-->>Client: WorkOSListResource (supports auto-pagination)

    Note over Client,WorkOSAPI: Delete API Key Flow
    Client->>ApiKeys: delete_api_key(api_key_id)
    ApiKeys->>HTTPClient: DELETE /api_keys/{api_key_id}
    HTTPClient->>WorkOSAPI: HTTP Request
    WorkOSAPI-->>HTTPClient: 204 No Content
    HTTPClient-->>ApiKeys: Response
    ApiKeys-->>Client: None
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.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant