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
        • Viewing context kinds
        • Creating and editing context kinds
        • Archiving 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 context kinds
  • Example context: Anna at Global Health Services
  • Create new context kinds
  • Grouping context kinds together into multi-contexts
  • Built-in context kinds
  • Context keys
Feature flagsContexts

Context kinds

Was this page helpful?
Previous

Viewing context kinds

Next
Built with

Overview

This topic explains what context kinds are and how to use them. Context kinds let you group context attributes together conceptually. When you create individual targets or add targeting rules for a flag or a segment, the available context attributes are organized by context kind.

To learn how to create and manage context kinds, read Creating and editing context kinds and Archiving context kinds.

About context kinds

Contexts are people, services, machines, or other resources that encounter feature flags in your product.

Each context has one or more context kinds that you can use to categorize context instances for targeting and Experimentation.

The most common context kind is user. User contexts often include context attributes like name, email address, location, and so on. However, you can create other context kinds like organization or device. An organization context kind might include attributes like “name” or “address,” and a device context kind might include attributes like “type” or “operating system.”

Example context: Anna at Global Health Services

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

We can describe the information about Anna using three different context kinds:

  • her name, email, and job function (“doctor”) are part of a “user” context,
  • her organization’s name (“Global Health Services”) and address are part of an “organization” context,
  • her device’s type, operating system, and device ID are part of a “device” context.

Here is an example of what the data structure for a user, an organization, and a device context object might look like, though each SDK sends context data to LaunchDarkly in a slightly different format:

Example organization and device contexts
1// a user context
2{
3 "kind": "user",
4 "key": "example-user-key",
5 "name": "Anna",
6 "email": "anna@globalhealthexample.com",
7 "jobFunction": "doctor"
8}
9
10// an organization context
11{
12 "kind": "organization",
13 "key": "example-organization-key",
14 "name": "Global Health Services",
15 "address": {
16 "street": "123 Main Street",
17 "city": "Springfield"
18 }
19}
20
21// a device context
22{
23 "kind": "device",
24 "key": "example-device-key",
25 "type": "iPad",
26 "operating_system": "iPadOS 15",
27 "deviceId": 12345
28}

Create new context kinds

When you create a new context kind, you provide only a name, key, and description. When your SDKs send a context object of that kind to LaunchDarkly, any attributes the SDK sends are automatically stored with the context.

You do not need to define any context attributes associated with a context kind when you create it. Instead, your SDK will send context attributes to LaunchDarkly along with the context object. To learn more, read Context attributes.

Context kinds are specific to LaunchDarkly projects. After you create them in a project, they are available in any of the environments within that project.

To learn how to create context kinds, read Creating and editing context kinds.

Grouping context kinds together into multi-contexts

You can combine multiple contexts of different kinds together into a multi-context. Multi-contexts allow you to evaluate different, but related, contexts together.

For example, using multi-contexts a flag could target all doctors (a user context kind) using iPads (a device context kind) in Springfield (an organization context kind). To learn how, read Multi-contexts.

Built-in context kinds

The only built-in default context kind is user. This is the context kind targeting rules use by default and, if you use Experimentation, the default randomization unit for experiments.

Automatic environment attributes enable additional built-in context kinds

If you enable automatic environment attributes in a mobile SDK, the built-in context kinds ld_device and ld_application also become available after your SDK begins sending this information to LaunchDarkly. To learn how to enable automatic environment attributes, read Automatic environment attributes.

Context keys

Each context has a key. Each combination of kind and key must be unique across all your contexts. Other context attributes can be strings, booleans, numbers, arrays, or JSON objects. When you evaluate a feature flag within your application, the flag’s targeting rules use information from one or more kinds of contexts. When you build your targeting rules, the attributes are automatically organized by context kind. To learn more, read Target with flags.

When you use the LaunchDarkly SDK to evaluate a flag, you provide an evaluation context to that call.

Configure your SDK: Context configuration, Evaluating flags

After different contexts encounter your application, you can view them on the Contexts list. To learn more, read The Contexts list.