Launch Darkly icon

Launch Darkly

Launch Darkly API

Actions2

Overview

The Patch Segment operation for the Segment resource in this custom n8n node allows you to update a user segment in LaunchDarkly using semantic patch instructions. This is useful for programmatically managing which users are included or excluded from specific segments, or for updating segment metadata such as its name.

Common scenarios:

  • Adding or removing users from a LaunchDarkly segment based on workflow logic.
  • Automating updates to segment membership as part of CI/CD or user management processes.
  • Renaming segments via automation.

Practical example:
Automatically add a list of new users to a "beta-testers" segment after they sign up, or remove users who have unsubscribed.


Properties

Name Type Meaning
Authentication options Selects the authentication method (Access Token) for connecting to LaunchDarkly.
Project Key Name or ID options The project within LaunchDarkly where the segment resides. Can be selected from a list or specified by ID/expression.
Environment Key Name or ID options The environment within the project. Can be selected from a list or specified by ID/expression.
Segment Key Name or ID options The specific segment to patch. Can be selected from a list or specified by ID/expression.
Instruction Kind options The type of patch instruction to apply. Options include: addIncludedUsers, addExcludedUsers, removeIncludedUsers, removeExcludedUsers, updateName.
Values json A JSON array containing the values relevant to the chosen instruction kind (e.g., user keys to add/remove, or new name if updating the segment's name).

Output

The output will be the response from the LaunchDarkly API after applying the patch. The structure depends on the API's response for the PATCH operation on segments. Typically, it will include details about the updated segment, such as:

{
  "success": true,
  "projectKey": "...",
  "environmentKey": "...",
  "segmentKey": "...",
  // ...other fields returned by LaunchDarkly
}

If an error occurs and "Continue On Fail" is enabled, the output will contain:

{
  "error": "Error message"
}

Note: No binary data is produced by this operation.


Dependencies

  • External Service: Requires access to the LaunchDarkly API.
  • API Key: You must provide a valid LaunchDarkly Access Token via n8n credentials (launchDarklyApi).
  • n8n Configuration: Ensure the credential is set up and selected in the node.

Troubleshooting

Common issues:

  • Invalid Credentials: If the Access Token is missing or incorrect, you'll receive an authentication error.
  • Malformed JSON in "Values": If the "Values" property is not valid JSON, the node will throw a parsing error.
  • Missing Required Fields: If any required property (Project, Environment, Segment, Kind, Values) is missing, the node will fail.
  • API Errors: If the LaunchDarkly API returns an error (e.g., invalid segment key, insufficient permissions), the error message will be passed through.

Error messages and resolutions:

  • "Unexpected token ... in JSON at position ...": Check that the "Values" field contains valid JSON.
  • "401 Unauthorized": Verify your Access Token and permissions.
  • "404 Not Found": Ensure the provided project, environment, or segment keys are correct and exist in LaunchDarkly.

Links and References

Discussion