Contentful integration
Overview
This topic explains how to use the integration between LaunchDarkly and Contentful. The integration connects LaunchDarkly feature flagging with Contentful’s content management platform so that content editors and developers can manage experiments and flag-based content directly inside Contentful.
You can use the integration to:
- Create new LaunchDarkly feature flags from Contentful
- Map Contentful entries to specific flag variations
- Search and select existing flags from your LaunchDarkly project
- Coordinate feature and content launches
- Preview and manage variation content in Contentful
This integration lets you map Contentful entries to LaunchDarkly variation values so you can control which content displays to each audience. Editors create and map flags in Contentful, while developers evaluate flags using LaunchDarkly SDKs and render the mapped content at runtime.
How the integration works
The Contentful app adds a custom Entry Editor and Sidebar extension. These extensions let you:
- Create feature flags in LaunchDarkly using the API token you configure
- Store flag metadata and variation mappings on Contentful entries
- Retrieve LaunchDarkly projects, environments, and flag from Contentful
- Map variation values to Contentful entries so your application can resolve content at runtime
The integration writes only the data required to map flags to entries. All flag targeting rules and environments remain managed in LaunchDarkly.
Prerequisites
To use the integration, you must have:
- A Contentful account with permission to install apps and update content types
- A LaunchDarkly account with access to API tokens, projects, and environments
- A LaunchDarkly API access token that includes the
createFlagandviewProjectactions, which allow the integration to create and read feature flags.
You can create or manage API access tokens on the Authorization page. To learn more, read API access tokens.
Example API token policy
Use this JSON policy to create a custom role for the Contentful integration. It grants only the permissions required to create and view flags and projects:
Configure the Contentful integration
Install and configure the integration to connect Contentful to your LaunchDarkly project and environment.
Install the integration
To install the LaunchDarkly app in Contentful:
- In Contentful, navigate to Apps > Marketplace.
- Search for “LaunchDarkly + Contentful.”
- Select the app and click Install.
- In the configuration screen, enter your LaunchDarkly API access token. The integration retrieves your available projects and environments.
- Select the project and environment you want to use.
- Click Create LaunchDarkly Feature Flag to generate the content type used for flag entries.
- Click Save configuration.
Contentful encrypts your API key and uses it only during requests.
Enable the integration in the Entry Editor
The configuration screen includes an option that automatically applies “Entry Editor” settings. After configuration, confirm the following:
- LaunchDarkly is set as the “Entry Editor” for the
LaunchDarkly Feature Flagcontent type. - The default Contentful editor is removed.
You can also add the Sidebar to other content types that you plan to use for variation content. The Sidebar shows which entries are linked to LaunchDarkly flags.
To add the Sidebar:
- In Contentful, navigate to Content model for content types that you may use for LaunchDarkly feature flags or experiments.
- Select the content type you use for variation content.
- Under “Sidebar,” click Add app and select LaunchDarkly.
- Click Save.
Do not add the sidebar to the LaunchDarkly feature flag content model. The sidebar exists to display content entries that may be linked to a LaunchDarkly feature flag, not to modify the feature flag model itself.
Use the Contentful Entry Editor
The Entry Editor provides two workflows for connecting Contentful entries to LaunchDarkly feature flags:
Create a new feature flag
To create a new feature flag inside Contentful:
- Create an entry using the
LaunchDarkly Feature Flagcontent type. - In the LaunchDarkly section, click Create New Flag.
- Enter a flag name and verify the autogenerated key.
- Add a description if needed.
- Choose boolean, string, number, or JSON for your Variation type.
- Define at least two variations with unique names and values.
- Click Create flag in LaunchDarkly.
- Click Start content mapping to begin mapping entries to flag variations.
After you create the flag, a confirmation card appears with links to view the flag in LaunchDarkly or continue mapping content.
Map content to an existing flag
To map Contentful entries to an existing LaunchDarkly flag:
- In the LaunchDarkly section, click Map content to existing flag.
- Search for the flag by name or key.
- Click the flag to load its variations.
- For each variation, click Select content to choose a Contentful entry.
- Use Preview to review the content for each variation.
- Click Save mapping.
The mapping order matches the variation order defined in LaunchDarkly.
Stored fields on entries
The integration stores the following fields on each LaunchDarkly feature flag entry:
The meta field exists so applications can perform stable lookups even if the variation order changes. Boolean flags resolve to true or false as the first two variations.
Implementation examples
These examples show how to evaluate feature flags and retrieve mapped content in an application.
Resolve mapped content using contentMapping
This example shows how an application identifies the active variation and selects the Contentful entry associated with that variation. The integration depends on the variation order defined in LaunchDarkly.
Resolve mapped content using the meta field
This example shows how an application uses the meta field to look up the entry identifier for the active variation. The variation values become the keys for retrieving mapped content.
Permissions and security
The integration maintains strict access controls and data handling practices. It:
- Uses your configured LaunchDarkly API key to create and read feature flags
- Stores only the flag name, key, description, variations, and mapped entry references in Contentful
- Encrypts and securely handles API keys
- Uses HTTPS for all communication
- Validates requests before processing
The integration does not allow editing of existing flags or variations. All targeting rules must be managed in LaunchDarkly.
Troubleshooting
If you encounter issues with the LaunchDarkly Contentful integration, try these common solutions.
The LaunchDarkly panel does not appear
If the LaunchDarkly section does not appear in the Entry Editor:
- Confirm that LaunchDarkly is added to the Entry Editor.
- Refresh the Contentful app after updating the content model.
Flags do not appear in the search list
If flags are missing when mapping content:
- Verify that the API key has access to the selected project and environment.
- Confirm that the flag exists and is active.
- Ensure that the key includes
createFlagandviewProjectactions.
Mapped content does not appear correctly
If mapped content does not appear as expected:
- Confirm that the LaunchDarkly variation order matches the Contentful mapping order index.
- Ensure that variation names and values are unique.
- Verify that mapped entries are published.
API key errors
If the integration cannot connect or displays an invalid API key message:
- Re-enter your LaunchDarkly API key.
- Confirm required permissions.
- Verify that the key is active.
Next steps
- Learn more about feature flags
- Read about experimentation
- Explore other LaunchDarkly integrations