This topic explains how to use the synced segments integration framework capability.
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:
action property to indicate whether the set of members should be added or removedThe combination of 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.
The following properties specify the requestParser:
The following properties specify the embedded memberArrayParser:
The following sections contain examples of different types of request bodies and the manifest definitions of synced segment capabilities that would successfully parse them.
In the request body, use a boolean property to indicate whether a member is added or removed:
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:
In the request body, use a single action property for the entire batch to indicate whether the batch should be added or removed:
By default, LaunchDarkly returns one of the following response codes:
204, success400, parsing problem403, unauthorized409, conflict429, rate limited, read Rate limiting for details on the X-Ratelimit-Reset header500, internal errorIf 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:
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.