Skip to main content
Contexts are people, services, machines, or other resources that encounter feature flags in your product. Contexts are identified by their kind, which describes the type of resources encountering flags, and by their key. Each unique combination of one or more contexts that have encountered a feature flag in your product is called a context instance. When you use the LaunchDarkly SDK to evaluate a flag, you provide a context to that call. LaunchDarkly records the key and attributes of each context. You can view these in the LaunchDarkly user interface from the Contexts list, or use the Context APIs. To learn more, read Contexts. LaunchDarkly provides APIs for you to:
  • retrieve contexts and context attribute names and values
  • search for contexts
  • fetch context kinds
  • create and update context kinds
To learn more about context kinds, read Context kinds. Contexts are always scoped within a project and an environment. Each environment has its own set of context records. Context records reflect the contexts that LaunchDarkly has received within the last 30 days. Some of the endpoints in the contexts API accept an application ID. The application ID is returned as the applicationId field of each element in the items array of the Get contexts response. By default, the application ID is set to the SDK you are using. In the LaunchDarkly UI, the application ID and application version appear on the context details page in the “From source” field. You can change the application ID as part of your SDK configuration. To learn more, read Application metadata configuration.

Filtering contexts

When you search for contexts, you can filter the results using fields and operators with the filter parameter. Specify filter either as a query parameter or as a request body parameter. The filter parameter supports the following operators: after, anyOf, before, contains, equals, exists, notEquals, startsWith. You can also combine filters in the following ways:
  • Use a comma (,) as an AND operator
  • Use a vertical bar (|) as an OR operator
  • Use parentheses () to group filters
For example:
  • myField notEquals 0, myField notEquals 1 returns contexts where myField is not 0 and is not 1
  • myFirstField equals "device",(mySecondField equals "iPhone"|mySecondField equals "iPad") returns contexts where myFirstField is equal to “device” and mySecondField is equal to either “iPhone” or “iPad”

Supported fields and operators

You can only filter some fields using certain operators. When you search for contexts, the filter parameter supports the following fields and operators: