-
Notifications
You must be signed in to change notification settings - Fork 25
Add API Keys support (create, list, delete) #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds full API key management to the SDK based on PR workos#508 with review feedback addressed: - Organizations: create_api_key and list_api_keys with pagination - ApiKeys: delete_api_key - Removed organization_id from list filters (it's a URL path param, not a query param) per reviewer feedback - Used functools.partial for list_method to properly support auto-pagination without sending organization_id as query param Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile OverviewGreptile SummaryThis PR adds comprehensive API key management functionality to the WorkOS Python SDK, including create, list, and delete operations. The implementation follows the established SDK patterns with both sync and async client support. Key Changes:
Notable Implementation Details:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Organizations
participant HTTP Client
participant WorkOS API
Note over Client,WorkOS API: Create API Key Flow
Client->>Organizations: create_api_key(org_id, name, permissions)
Organizations->>HTTP Client: POST /organizations/{org_id}/api_keys
HTTP Client->>WorkOS API: POST request with name & permissions
WorkOS API-->>HTTP Client: 201 Created with ApiKeyWithValue
HTTP Client-->>Organizations: response
Organizations-->>Client: ApiKeyWithValue (includes value field)
Note over Client,WorkOS API: List API Keys Flow
Client->>Organizations: list_api_keys(org_id, limit, before, after, order)
Organizations->>HTTP Client: GET /organizations/{org_id}/api_keys
HTTP Client->>WorkOS API: GET request with pagination params
WorkOS API-->>HTTP Client: 200 OK with list page
HTTP Client-->>Organizations: response
Organizations-->>Client: WorkOSListResource with partial(list_api_keys, org_id)
Note over Client,WorkOS API: Auto-Pagination Flow
Client->>Organizations: iterate over WorkOSListResource
Organizations->>Organizations: partial(list_api_keys, org_id) called with after cursor
Organizations->>HTTP Client: GET /organizations/{org_id}/api_keys?after=cursor
HTTP Client->>WorkOS API: GET request with after param
WorkOS API-->>HTTP Client: Next page
HTTP Client-->>Organizations: response
Organizations-->>Client: Next batch of API keys
Note over Client,WorkOS API: Delete API Key Flow
Client->>ApiKeys: delete_api_key(api_key_id)
ApiKeys->>HTTP Client: DELETE /api_keys/{api_key_id}
HTTP Client->>WorkOS API: DELETE request
WorkOS API-->>HTTP Client: 204 No Content
HTTP Client-->>ApiKeys: empty response
ApiKeys-->>Client: None
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 files reviewed, no comments
This addresses the issues in #508
Adds full API key management to the SDK based on PR #508 with review feedback addressed:
Description
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.