For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
      • PUTCreate or update context kind
      • DELDelete context instances
      • POSTEvaluate flags for context instance
      • GETGet context attribute names
      • GETGet context attribute values
      • GETGet context instances
      • GETGet context kinds
      • GETGet contexts
      • POSTSearch for context instances
      • POSTSearch for contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewContexts

Evaluate flags for context instance

POST
/api/v2/projects/:projectKey/environments/:environmentKey/flags/evaluate
POST
/api/v2/projects/:projectKey/environments/:environmentKey/flags/evaluate
$curl -X POST https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/flags/evaluate \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "key": "user-key-123abc",
> "kind": "user",
> "otherAttribute": "other attribute value"
>}'
1{
2 "items": [
3 {
4 "name": "SortOrder",
5 "key": "sort.order",
6 "_value": null,
7 "_links": {
8 "self": {
9 "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate",
10 "type": "application/json"
11 },
12 "site": {
13 "href": "/my-project/my-environment/features/sort.order/targeting",
14 "type": "text/html"
15 }
16 },
17 "reason": {
18 "kind": "FALLTHROUGH"
19 }
20 },
21 {
22 "name": "AlternatePage",
23 "key": "alternate.page",
24 "_value": null,
25 "_links": {
26 "self": {
27 "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate",
28 "type": "application/json"
29 },
30 "site": {
31 "href": "/my-project/my-environment/features/alternate.page/targeting",
32 "type": "text/html"
33 }
34 },
35 "reason": {
36 "kind": "RULE_MATCH",
37 "ruleIndex": 1,
38 "ruleID": "b2530cdf-14c6-4e16-b660-00239e08f19b"
39 }
40 }
41 ],
42 "_links": {
43 "self": {
44 "href": "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate",
45 "type": "application/json"
46 }
47 },
48 "totalCount": 2
49}
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](https://launchdarkly.com/docs/guides/api/comparing-sdk-rest-api). ### Filtering LaunchDarkly supports the `filter` query param for filtering, with the following fields: - `query` filters for a string that matches against the flags' keys and names. It is not case sensitive. For example: `filter=query equals dark-mode`. - `tags` filters 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`.
Was this page helpful?
Previous

Get context attribute names

Next
Built with

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:

  • query filters for a string that matches against the flags’ keys and names. It is not case sensitive. For example: filter=query equals dark-mode.
  • tags filters 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.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key

Query parameters

limitlongOptional

The number of feature flags to return. Defaults to -1, which returns all flags

offsetlongOptional

Where 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.

sortstringOptionalformat: "string"

A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order

filterstringOptionalformat: "string"

A comma-separated list of filters. Each filter is of the form field operator value. Supported fields are explained above.

Request

This endpoint expects a map from strings to any.

Response

Flag evaluation collection response
itemslist of objects
Details on the flag evaluations for this context instance
_linksmap from strings to objects
The location and content type of related resources
totalCountinteger
The number of flags

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error