No results for ""
EXPAND ALL
  • Home
  • API docs

Creating and editing context kinds

Read time: 2 minutes
Last edited: Oct 16, 2024

Overview

This topic explains how to create and edit context kinds.

Create context kinds

Creating context kinds is an Admin-only feature

You can only create new context kinds in the LaunchDarkly user interface (UI) if you're a LaunchDarkly Owner or Admin, or have a custom role that allows the createContextKind action. To learn more, read About member roles and Context kind actions.

You can create context kinds in the LaunchDarkly UI, or automatically when you evaluate a context using a LaunchDarkly SDK.

To create a context kind in the LaunchDarkly UI:

  1. Navigate to the Contexts list.
  2. Click the gear icon on the right. The context kinds list appears.
  3. Click Add kind.
  4. The "New context kind" dialog appears.
  5. Enter a Name for the context kind. This appears in the context kind list, and as a filter option in the Contexts list.
  6. Enter a Key for the context kind. You cannot change this later. It appears in the Contexts list and on the context details page in the "Attributes" section.
  7. (Optional) Enter a Description for the context kind.
  8. (Optional) Check the Available for experiments checkbox if you want to be able to use this context kind as a randomization unit in experiments. To learn more, read Randomization units.
  • Select an industry-standard randomization unit to map the context kind to.
  • (Optional) Check the "Set as the default for experiments" checkbox if you want new experiments to default to this context kind as the randomization unit.
Context kinds available for experiments must use valid randomization units

Using invalid randomization units will result in invalid experiment results. To learn more, read Randomization units. If you're unsure of which randomization unit to use, start a Support ticket to get help determining valid context kind selections.

  1. Click Create kind.

To create a context kind automatically, create a context object in your LaunchDarkly SDK. When you evaluate a flag for the context, LaunchDarkly automatically creates a new context kind for that context's kind, if one of the same name does not already exist.

Try it in your SDK: Evaluating flags

You can also use the REST API: Create or update context kind

Edit context kinds

You can edit existing context kinds from the context kinds list by clicking on the pencil icon next to the contest kind you want to edit.

You can edit the name and description of the context kind, but you cannot edit the key.

If you use Experimentation, you can also edit whether the context kind is available for experiments, the standard randomization unit the context kind maps to, and whether the context kind should be the default for experiments. To learn more, read Randomization units.