---
title: "Evaluate flags for context instance"
method: POST
path: "/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate"
tags: ["Contexts"]
---

# Evaluate flags for context instance

`POST /api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate`

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

## Path parameters

- `projectKey` string, string, required — The project key
- `environmentKey` string, string, required — The environment key

## Query parameters

- `limit` integer — The number of feature flags to return. Defaults to -1, which returns all flags
- `offset` integer — 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`.
- `sort` string, string — A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order
- `filter` string, string — A comma-separated list of filters. Each filter is of the form `field operator value`. Supported fields are explained above.

## Request body

- ContextInstance

## Response `200`

Flag evaluation collection response

- ContextInstanceEvaluations
  - `items` ContextInstanceEvaluation[], required — Details on the flag evaluations for this context instance
    - `name` string, required — Name of the flag.
    - `key` string, required — Key of the flag.
    - `_value` string, required — The value of the flag variation that the context receives. If there is no defined default rule, this is null.
    - `reason` ContextInstanceEvaluationReason
      - `kind` string, required — Describes the general reason that LaunchDarkly selected this variation.
      - `ruleIndex` integer — The positional index of the matching rule if the kind is 'RULE_MATCH'. The index is 0-based.
      - `ruleID` string — The unique identifier of the matching rule if the kind is 'RULE_MATCH'.
      - `prerequisiteKey` string — The key of the flag that failed if the kind is 'PREREQUISITE_FAILED'.
      - `inExperiment` boolean — Indicates whether the context was evaluated as part of an experiment.
      - `errorKind` string — The specific error type if the kind is 'ERROR'.
    - `_links` object, required — The location and content type of related resources
  - `totalCount` integer — The number of flags
  - `_links` object, required — The location and content type of related resources

## Other responses

- `400` — Invalid request
- `401` — Invalid access token
- `403` — Forbidden
- `404` — Invalid resource identifier
- `429` — Rate limited

---

[API](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/revisions/69c5c9aafe78/schema)
