Contexts are now available
After you have upgraded your LaunchDarkly SDK to use contexts instead of users, you should use Contexts instead of the user settings API. To learn more, read Contexts.
LaunchDarkly's user settings API provides a picture of all feature flags and their current values for a specific user. This gives you instant visibility into how a particular user experiences your site or application. To learn more, read View and manage contexts.
You can also use the user settings API to assign a user to a specific variation for any feature flag.
Get the current flag settings for a given user.
The _value
is the flag variation that the user receives. The setting
indicates whether you've explicitly targeted a user to receive a particular variation. For example, if you have turned off a feature flag for a user, this setting will be false
. The example response indicates that the user Abbie_Braun
has the sort.order
flag enabled and the alternate.page
flag disabled, and that the user has not been explicitly targeted to receive a particular variation.
User flag settings collection response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "items": {
- "alternate.page": {
- "_links": {
- "self": {
- "href": "/api/v2/users/lacuna/production/Abbie_Braun/flags/alternate.page",
- "type": "application/json"
}
}, - "_value": false,
- "setting": null
}, - "sort.order": {
- "_links": {
- "self": {
- "href": "/api/v2/users/lacuna/production/Abbie_Braun/flags/sort.order",
- "type": "application/json"
}
}, - "_value": true,
- "setting": null
}
}, - "_links": {
- "self": {
- "href": "/api/v2/users/lacuna/production/Abbie_Braun/flags",
- "type": "application/json"
}
}
}
Get a single flag setting for a user by flag key.
The _value
is the flag variation that the user receives. The setting
indicates whether you've explicitly targeted a user to receive a particular variation. For example, if you have turned off a feature flag for a user, this setting will be false
. The example response indicates that the user Abbie_Braun
has the sort.order
flag enabled.
User flag settings response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "_links": {
- "sort.order": {
- "href": "/api/v2/users/lacuna/production/Abbie_Braun/flags/sort.order",
- "type": "application/json"
}
}, - "_value": "true",
- "setting": "null",
- "reason": {
- "kind": "OFF",
- "ruleIndex": 3,
- "ruleID": "1234567890",
- "prerequisiteKey": "someotherflagkey",
- "inExperiment": true,
- "errorKind": "USER_NOT_SPECIFIED"
}
}
Enable or disable a feature flag for a user based on their key.
Omitting the setting
attribute from the request body, or including a setting
of null
, erases the current setting for a user.
If you previously patched the flag, and the patch included the user's data, LaunchDarkly continues to use that data. If LaunchDarkly has never encountered the user's key before, it calculates the flag values based on the user key alone.
Action succeeded
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "setting": "existing_variation_value_to_use",
- "comment": "make sure this context experiences a specific variation"
}
{- "code": "invalid_request",
- "message": "Invalid request body"
}
Get a list of flags for which the given user is scheduled for removal.
Expiring user target response
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "items": [
- {
- "_id": "12ab3c45de678910fgh12345",
- "_version": 1,
- "expirationDate": 0,
- "userKey": "example-user-key",
- "targetType": "included",
- "variationId": "ce67d625-a8b9-4fb5-a344-ab909d9d4f4d",
- "_resourceId": {
- "kind": "string",
- "projectKey": "string",
- "environmentKey": "string",
- "flagKey": "string",
- "key": "string"
}
}
], - "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}
}
Schedule the specified user for removal from individual targeting on one or more flags. The user must already be individually targeted for each flag.
You can add, update, or remove a scheduled removal date. You can only schedule a user for removal on a single variation per flag.
Updating an expiring target uses the semantic patch format. To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch
to your Content-Type
header. To learn more, read Updates using semantic patch.
Semantic patch requests support the following kind
instructions for updating expiring user targets.
Adds a date and time that LaunchDarkly will remove the user from the flag's individual targeting.
flagKey
: The flag keyvariationId
: ID of a variation on the flagvalue
: The time, in Unix milliseconds, when LaunchDarkly should remove the user from individual targeting for this flag.Updates the date and time that LaunchDarkly will remove the user from the flag's individual targeting.
flagKey
: The flag keyvariationId
: ID of a variation on the flagvalue
: The time, in Unix milliseconds, when LaunchDarkly should remove the user from individual targeting for this flag.version
: The version of the expiring user target to update. If included, update will fail if version doesn't match current version of the expiring user target.Removes the scheduled removal of the user from the flag's individual targeting. The user will remain part of the flag's individual targeting until explicitly removed, or until another removal is scheduled.
flagKey
: The flag keyvariationId
: ID of a variation on the flagExpiring user target response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "comment": "optional comment",
- "instructions": [
- {
- "kind": "addExpireUserTargetDate",
- "flagKey": "sample-flag-key",
- "variationId": "ce12d345-a1b2-4fb5-a123-ab123d4d5f5d",
- "value": 1653469200000,
- "version": 1
}
]
}
{- "items": [
- {
- "_id": "12ab3c45de678910fgh12345",
- "_version": 1,
- "expirationDate": 0,
- "userKey": "example-user-key",
- "targetType": "included",
- "variationId": "ce67d625-a8b9-4fb5-a344-ab909d9d4f4d",
- "_resourceId": {
- "kind": "string",
- "projectKey": "string",
- "environmentKey": "string",
- "flagKey": "string",
- "key": "string"
}
}
], - "_links": {
- "property1": {
- "href": "string",
- "type": "string"
}, - "property2": {
- "href": "string",
- "type": "string"
}
}, - "totalInstructions": 1,
- "successfulInstructions": 1,
- "failedInstructions": 0,
- "errors": [
- {
- "instructionIndex": 1,
- "message": "example error message"
}
]
}