Filtered SDK payloads

Filtered SDK payloads are in beta

Filtered SDK payloads are in beta, and are available only to certain customers on an Enterprise plan. To request access, contact Support.

This topic explains how to use filtered SDK payloads to reduce the size of the flag and segment data that LaunchDarkly delivers to an SDK.

When an SDK initializes, LaunchDarkly delivers a payload containing the resource data for its environment. In environments with many flags and segments, this payload can be large, which increases SDK initialization time and memory use. Filtered SDK payloads let you deliver only the resources an application actually needs by associating one or more views with an SDK or mobile key.

About SDK payloads

An SDK payload is the set of flag and segment data that LaunchDarkly delivers to an SDK when it initializes and when resource data changes. By default, an SDK receives the full payload for its environment.

Filters for SDK payloads

A filter is an association between one or more views and a specific SDK or mobile key. When an application connects with a filtered SDK or mobile key, LaunchDarkly delivers only the resources contained in the associated views, rather than the full environment payload.

Because filters are built on views, the resources in a filtered payload change as you link and unlink resources from the associated views. You can add up to ten views to filter by per key.

Prerequisites

To add filters to SDK payloads, you must meet the following prerequisites:

  • You must have at least one view in your project.
  • You must have a non-default SDK or mobile key for your environment.
    • You cannot apply filters to default SDK or mobile keys. Default keys are the automatically generated keys attached to each environment, and any existing applications that use the default key could break if you apply filtering unintentionally.
    • You cannot promote an SDK or mobile key that has filtering enabled to the default SDK or mobile key.
  • You must have a LaunchDarkly role of Owner or Admin, or a custom role that allows the updateSdkKeyPayload action. To learn more, read SDK key actions.
  • If you use the Relay Proxy, it must be version 9.0 or higher, and it cannot use automatic configuration.

Create a new key with a filter

To create a new SDK or mobile key with a filter:

  1. Click the gear icon in the left sidebar to open Organization settings.
  2. Under the “Security” section, click SDK keys. The SDK keys page opens.
  3. Use the Choose project and environment menus to search for and select your project and environment.
  4. Click New SDK key or New mobile key. A key creation dialog opens.
  5. Enter a Name and optionally update the Key or Description.
  6. Click Custom payload.
  7. Click Add views.
  8. Select the views to filter the payload by.
  9. Click Generate key.

Any application that connects with this SDK or mobile key now receives a payload containing only the resources in the associated views.

To learn more, read SDK credentials and Creating views.

You can also use the REST API: Create SDK key

Add a filter to an existing key

To add a filter to an existing SDK or mobile key:

  1. Click the gear icon in the left sidebar to open Organization settings.
  2. Under the “Security” section, click SDK keys. The SDK keys page opens.
  3. Use the Choose project and environment menus to search for and select your project and environment.
  4. Find the key you want to add a filter to, and click its three-dot overflow menu.
  5. Select Edit.
  6. Click Custom payload.
  7. Click Add views.
  8. Select the views to filter the payload by.
  9. Click Save.

Any application that connects with this SDK or mobile key now receives a payload containing only the resources in the associated views.

You can also use the REST API: Update SDK key