Add support for feature flags management API#1420
Merged
stanleyphu merged 6 commits intomainfrom Dec 22, 2025
Merged
Conversation
Contributor
Greptile OverviewGreptile SummaryAdded comprehensive feature flags management API support to the WorkOS SDK. This PR introduces a new Key changes:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant WorkOS
participant FeatureFlags
participant HttpClient
participant API as WorkOS API
Note over Client,API: List Feature Flags
Client->>WorkOS: featureFlags.listFeatureFlags(options)
WorkOS->>FeatureFlags: listFeatureFlags(options)
FeatureFlags->>HttpClient: fetchAndDeserialize('/feature-flags')
HttpClient->>API: GET /feature-flags
API-->>HttpClient: List response with feature flags
HttpClient-->>FeatureFlags: Deserialized list
FeatureFlags-->>WorkOS: AutoPaginatable<FeatureFlag>
WorkOS-->>Client: Feature flags list
Note over Client,API: Get Feature Flag
Client->>WorkOS: featureFlags.getFeatureFlag(slug)
WorkOS->>FeatureFlags: getFeatureFlag(slug)
FeatureFlags->>HttpClient: workos.get(`/feature-flags/${slug}`)
HttpClient->>API: GET /feature-flags/:slug
API-->>HttpClient: Feature flag response
HttpClient-->>FeatureFlags: FeatureFlagResponse
FeatureFlags->>FeatureFlags: deserializeFeatureFlag()
FeatureFlags-->>WorkOS: FeatureFlag
WorkOS-->>Client: Feature flag
Note over Client,API: Enable/Disable Feature Flag
Client->>WorkOS: featureFlags.enableFeatureFlag(slug)
WorkOS->>FeatureFlags: enableFeatureFlag(slug)
FeatureFlags->>HttpClient: workos.put(`/feature-flags/${slug}/enable`)
HttpClient->>API: PUT /feature-flags/:slug/enable
API-->>HttpClient: Updated feature flag
HttpClient-->>FeatureFlags: FeatureFlagResponse
FeatureFlags->>FeatureFlags: deserializeFeatureFlag()
FeatureFlags-->>WorkOS: FeatureFlag
WorkOS-->>Client: Updated feature flag
Note over Client,API: Add/Remove Flag Target
Client->>WorkOS: featureFlags.addFlagTarget(slug, targetId)
WorkOS->>FeatureFlags: addFlagTarget(slug, targetId)
FeatureFlags->>HttpClient: workos.post(`/feature-flags/${slug}/targets/${targetId}`)
HttpClient->>API: POST /feature-flags/:slug/targets/:targetId
API-->>HttpClient: 204 No Content
HttpClient-->>FeatureFlags: void
FeatureFlags-->>WorkOS: void
WorkOS-->>Client: Success
|
d45ee70 to
147c2bc
Compare
This matches our API which always returns description for flags. When there is no description, we return an empty string.
147c2bc to
c4b37e6
Compare
nicknisi
approved these changes
Dec 22, 2025
nholden
approved these changes
Dec 22, 2025
src/feature-flags/feature-flags.ts
Outdated
Comment on lines
+61
to
+67
| async addFlagTarget(slug: string, targetId: string): Promise<void> { | ||
| await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {}); | ||
| } | ||
|
|
||
| async removeFlagTarget(slug: string, targetId: string): Promise<void> { | ||
| await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`); | ||
| } |
Member
There was a problem hiding this comment.
Did you consider making slug and targetId named arguments instead of positional arguments? The order of those arguments aren't particularly obvious, so I'm wondering if addFlagTarget({ slug: 'my-feature', targetId: 'user_foobar' }) might be more foolproof.
Contributor
Author
There was a problem hiding this comment.
I agree - I think named arguments makes more sense here. Updated the PR to do this
Merged
cmatheson
added a commit
that referenced
this pull request
Dec 24, 2025
## Description Includes: - #1417 - #1420 ## 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. <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` -->
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
listFeatureFlags(GET /feature-flags)getFeatureFlag(GET /feature-flags/:slug)enableFeatureFlag(PUT /feature-flags/:slug/enable)disableFeatureFlag(PUT /feature-flags/:slug/disable)addFlagTarget(POST /feature-flags/:slug/targets/:targetId)removeFlagTarget(DELETE /feature-flags/:slug/targets/:targetId)FeatureFlaginterface to addtags,enabledanddefaultValuefieldsFeatureFlag.descriptionto be a required field to match the API responseDocumentation
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.