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
  • Get started
    • Overview
    • Onboarding
    • Get started
    • Launch Insights
    • LaunchDarkly architecture
    • LaunchDarkly vocabulary
  • AgentControl
    • AgentControl
    • Manage AgentControl
  • Feature flags
    • Create flags
    • Target with flags
    • Flag templates
    • Manage flags
    • Code references
    • Contexts
      • An introduction to contexts
      • The Contexts list
      • Context kinds
      • Context attributes
      • Multi-contexts
      • Anonymous contexts
    • Segments
  • Releases
    • Releasing features with LaunchDarkly
    • Release policies
    • Percentage rollouts
    • Progressive rollouts
    • Guarded rollouts
    • Feature monitoring
    • Release pipelines
    • Engineering insights
    • Release management tools
    • Applications and app versions
    • Change history
    • Restoring previous flag versions
  • Observability
    • Observability
    • Session replay
    • Error monitoring
    • Logs
    • Traces
    • Observability metrics
    • Product analytics events
    • LLM observability
    • Alerts
    • Dashboards
    • Service map
    • Vega for auto-remediation
    • Observability MCP server
    • Search specification
    • Observability settings
    • Observability integrations
  • Experimentation
    • Experimentation
    • Experiment metric types
    • Experiment configuration
    • Managing experiments
    • Analyzing experiments
    • Multi-armed bandits
    • Holdouts
  • Metrics and events
    • Metrics in LaunchDarkly
    • Creating metrics
    • Metric groups
    • Events
    • Autogenerated metrics
  • Warehouse native
    • Warehouse native metrics
    • Setting up external warehouses
    • Creating experiments using warehouse native metrics
  • Infrastructure
    • Connect apps and services to LaunchDarkly
    • LaunchDarkly in China and Pakistan
    • LaunchDarkly in the European Union (EU)
    • LaunchDarkly in federal environments
    • Public IP list
  • Your account
    • Projects
    • Views
    • Environments
    • Tags
    • Teams
    • Members
    • Roles
    • Account security
    • Feature previews
    • Billing and usage
    • Changelog
Sign inTry it free
LogoLogo
On this page
  • Overview
  • About contexts
  • Example context: Anna at Global Health Services
  • Context kinds
  • Related content
Feature flags

Contexts

Was this page helpful?
Previous

An introduction to contexts

Next
Built with

Overview

This category has documentation topics about LaunchDarkly contexts.

Most, but not all, LaunchDarkly SDKs support contexts. Some older SDKs rely on legacy user objects. To learn which SDKs are available to use with contexts, read SDKs.

About contexts

LaunchDarkly contexts are data objects that represent users, devices, organizations, and other entities. Feature flags use these contexts during evaluation to determine which variation to use, based on your flag targeting rules. Each context contains attributes that describe what you know about that context, such as their name, location, device type, or organization they are associated with.

You can manage how contexts interact with your app by targeting flag variations to specific contexts, based on their context attributes. When a flag is evaluated, LaunchDarkly uses the provided context to determine which variation of the flag to serve. This is known as the evaluation context. You can be as specific as targeting a flag to a single end user, or as broad as targeting your entire customer base. You can even use anonymous contexts and private attributes to control what data to include or exclude in the information you collect about your end users.

Only the context attributes you provide are available for targeting

The SDK only evaluates flags based on the context you provide in the evaluation call. You must provide all applicable attributes for each evaluation in the SDK for your targeting rules to apply correctly. To learn more, read Evaluating flags.

Example context: Anna at Global Health Services

As an example, let’s assume Anna is one of your end users. She is a doctor who works for a hospital chain called Global Health Services. Anna has two mobile devices, an Android phone and an iPad tablet. Anna uses your application on both devices as part of her work.

Given this information, you may know the following things about Anna:

  • her name, email, and job function (“doctor”),
  • her organization’s name (“Global Health Services”),
  • her device’s type (“iPad”)

Here is an example of what the data structure for Anna’s context object might look like. Each SDK sends context data to LaunchDarkly in a slightly different format, but the core structure includes a kind, a key, and one or more attributes:

Example user context
1{
2 "kind": "user",
3 "key": "example-user-key",
4 "name": "Anna",
5 "email": "anna@globalhealthexample.com",
6 "organization": "Global Health Services",
7 "jobFunction": "doctor",
8 "device": "iPad"
9}

Context kinds

Each context has one kind with a unique set of corresponding attributes that you can use for flag targeting and other features.

The most common context kind is user. Contexts of the user kind often represent individual people and include attributes such as “name,” “email address,” or “location.” However, you can create other context kinds like organization or device. Contexts of an organization kind might include attributes like “name” or “address”, and the context of a “device” kind might include attributes like “type” or “operating system.”

To learn more, read Context kinds.

Related content

Here are the topics in this category:

  • An introduction to contexts
  • The Contexts list
  • Context kinds
  • Context attributes
  • Multi-contexts
  • Anonymous contexts