Add API Keys support (create, list, delete)#544
Merged
gjtorikian merged 2 commits intoworkos:mainfrom Feb 12, 2026
Merged
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>
Contributor
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
|
Closed
gjtorikian
approved these changes
Feb 12, 2026
Merged
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.
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.