Synced segments capability
Overview
This topic explains how to use the synced segments integration framework capability.
About synced segments
In LaunchDarkly, segments are lists of contexts that are used to manage flag targeting behavior in bulk. As a partner, you can use the synced segments integration framework capability to create and synchronize resources contained in external services, such as Amplitude cohorts or Segment Audiences, with LaunchDarkly segments. To learn more about segments, read Segments.
The syncedSegment capability consists of a request parser. The properties of the parser describe the information about the segment to create or update.
Many of the parser properties are required, for example, the properties that specify the name and ID of the cohort you are updating.
Then, you have three options for how to send cohort information:
- Use a boolean property to indicate whether a member should be added or removed
- Use separate named arrays, one for members being added and one for members being removed
- Use a single
actionproperty to indicate whether the set of members should be added or removed
The combination of the the request parser’s memberArrayPath, addMemberArrayPath, removeMemberArrayPath, and memberArrayParser properties describe which option you are using and where the integration framework can expect to find the cohort information.
Request parser properties
The following properties specify the requestParser:
The following properties specify the embedded memberArrayParser:
Examples
The following sections contain examples of different types of request bodies and the manifest definitions of synced segment capabilities that would successfully parse them.
Boolean property
In the request body, use a boolean property to indicate whether a member is added or removed:
Separate named arrays
In the request body, use separate named arrays containing lists of members to add and remove. In the manifest, the memberArrayParser describes how to parse the addMemberArrayPath and removeMemberArrayPath arrays:
Single property
In the request body, use a single action property for the entire batch to indicate whether the batch should be added or removed:
Response codes and custom responses
By default, LaunchDarkly returns one of the following response codes:
204, success400, parsing problem403, unauthorized409, conflict429, rate limited, read Rate limiting for details on theX-Ratelimit-Resetheader500, internal error
If you require a custom response, you can specify that with the jsonResponseBody in the syncedSegments object in your integration manifest. The jsonResponseBody supports Handlebars templating directly in the manifest.
Here is an example manifest excerpt that specifies a jsonResponseBody:
Testing
After you have an initial implementation of your synced segments capability, you can test it using LaunchDarkly’s integration validation server. To learn more, read Validating an integration.