Evaluate flags for context instance
Evaluate flags for a context instance, for example, to determine the expected flag variation. Do not use this API instead of an SDK. The LaunchDarkly SDKs are specialized for the tasks of evaluating feature flags in your application at scale and generating analytics events based on those evaluations. This API is not designed for that use case. Any evaluations you perform with this API will not be reflected in features such as flag statuses and flag insights. Context instances evaluated by this API will not appear in the Contexts list. To learn more, read Comparing LaunchDarkly's SDKs and REST API.
Filtering
LaunchDarkly supports the filter query param for filtering, with the following fields:
queryfilters for a string that matches against the flags' keys and names. It is not case sensitive. For example:filter=query equals dark-mode.tagsfilters the list to flags that have all of the tags in the list. For example:filter=tags contains ["beta","q1"].
You can also apply multiple filters at once. For example, setting filter=query equals dark-mode, tags contains ["beta","q1"] matches flags which match the key or name dark-mode and are tagged beta and q1.
Authorization
ApiKey read, writeIn: header
Scope: read, write
Path Parameters
The project key
stringThe environment key
stringQuery Parameters
The number of feature flags to return. Defaults to -1, which returns all flags
int64Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query limit.
int64A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order
stringA comma-separated list of filters. Each filter is of the form field operator value. Supported fields are explained above.
stringRequest Body
application/json
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v2/projects/string/environments/string/flags/evaluate" \ -H "Content-Type: application/json" \ -d '{ "key": "user-key-123abc", "kind": "user", "otherAttribute": "other attribute value" }'{ "items": [ { "_links": { "self": { "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate", "type": "application/json" }, "site": { "href": "/my-project/my-environment/features/sort.order/targeting", "type": "text/html" } }, "_value": true, "key": "sort.order", "name": "SortOrder", "reason": { "kind": "FALLTHROUGH" } }, { "_links": { "self": { "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate", "type": "application/json" }, "site": { "href": "/my-project/my-environment/features/alternate.page/targeting", "type": "text/html" } }, "_value": false, "key": "alternate.page", "name": "AlternatePage", "reason": { "kind": "RULE_MATCH", "ruleID": "b2530cdf-14c6-4e16-b660-00239e08f19b", "ruleIndex": 1 } } ], "totalCount": 2, "_links": { "self": { "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate", "type": "application/json" } }}Get contexts GET
Get contexts based on kind and key.
List environments GET
Return a list of environments for the specified project. By default, this returns the first 20 environments. Page through this list with the `limit` parameter and by following the `first`, `prev`, `next`, and `last` links in the `_links` field that returns. If those links do not appear, the pages they refer to don't exist. For example, the `first` and `prev` links will be missing from the response on the first page, because there is no previous page and you cannot return to the first page when you are already on the first page. ### Filtering environments LaunchDarkly supports the following fields for filters: - `query` is a string that matches against the environments' names and keys. It is not case sensitive. - `tags` is a `+`-separated list of environment tags. It filters the list of environments that have all of the tags in the list. - `critical` is a boolean filter. `critical:true` returns only environments marked as critical, and `critical:false` returns only non-critical environments. For example, the filter `filter=query:abc,tags:tag-1+tag-2` matches environments with the string `abc` in their name or key and also are tagged with `tag-1` and `tag-2`. The filter is not case-sensitive. The documented values for `filter` query parameters are prior to URL encoding. For example, the `+` in `filter=tags:tag-1+tag-2` must be encoded to `%2B`. ### Sorting environments LaunchDarkly supports the following fields for sorting: - `createdOn` sorts by the creation date of the environment. - `critical` sorts by whether the environments are marked as critical. - `name` sorts by environment name. For example, `sort=name` sorts the response by environment name in ascending order.