Flag triggers

Flag triggers is an Enterprise feature

Flag triggers is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

Flag triggers let you initiate flag changes remotely using a unique webhook URL. For example, you can integrate triggers with your existing tools to enable or disable flags when you hit specific operational health thresholds or receive certain alerts. To learn more, read Flag triggers.

With the flag triggers API, you can create, delete, and manage triggers.

List flag triggers

Get a list of all flag triggers.

SecurityApiKey
Request
path Parameters
projectKey
required
string <string>

The project key

environmentKey
required
string <string>

The environment key

featureFlagKey
required
string <string>

The feature flag key

Responses
200

Flag trigger collection response JSON

401

Invalid access token

403

Forbidden

429

Rate limited

get/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}
Request samples
curl -i -X GET \
  'https://app.launchdarkly.com/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}' \
  -H 'Authorization: YOUR_API_KEY_HERE'
Response samples
application/json
{
  • "items": [
    ],
  • "_links": {
    }
}

Create flag trigger

Create a new flag trigger.

SecurityApiKey
Request
path Parameters
projectKey
required
string <string>

The project key

environmentKey
required
string <string>

The environment key

featureFlagKey
required
string <string>

The feature flag key

Request Body schema: application/json
comment
string
Array of objects (Instruction)

The action to perform when triggering. This should be an array with a single object that looks like {"kind": "flag_action"}. Supported flag actions are "turnFlagOn" and "turnFlagOff".

integrationKey
required
string

The unique identifier of the integration for your trigger. Use "generic-trigger" for integrations not explicitly supported.

Responses
201

Successful flag trigger response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

429

Rate limited

post/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}
Request samples
application/json
{
  • "comment": "example comment",
  • "instructions": [
    ],
  • "integrationKey": "generic-trigger"
}
Response samples
application/json
{
  • "_id": "string",
  • "_version": 0,
  • "_creationDate": 0,
  • "_maintainerId": "string",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "string",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 0,
  • "triggerURL": "string",
  • "_links": {
    }
}

Get flag trigger by ID

Get a flag trigger by ID.

SecurityApiKey
Request
path Parameters
projectKey
required
string <string>

The project key

featureFlagKey
required
string <string>

The feature flag key

environmentKey
required
string <string>

The environment key

id
required
string <string>

The flag trigger ID

Responses
200

Flag trigger response

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

429

Rate limited

get/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}/{id}
Request samples
curl -i -X GET \
  'https://app.launchdarkly.com/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}/{id}' \
  -H 'Authorization: YOUR_API_KEY_HERE'
Response samples
application/json
{
  • "_id": "string",
  • "_version": 0,
  • "_creationDate": 0,
  • "_maintainerId": "string",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "string",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 0,
  • "triggerURL": "string",
  • "_links": {
    }
}

Update flag trigger

Update a flag trigger. Updating a flag trigger uses the semantic patch format.

To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch to your Content-Type header. To learn more, read Updates using semantic patch.

Instructions

Semantic patch requests support the following kind instructions for updating flag triggers.

replaceTriggerActionInstructions

Removes the existing trigger action and replaces it with the new instructions.

Parameters
  • value: An array of the new kinds of actions to perform when triggering. Supported flag actions are turnFlagOn and turnFlagOff.

For example, to replace the trigger action instructions, use this request body:

{
  "comment": "optional comment",
  "instructions": [
    {
      "kind": "replaceTriggerActionInstructions",
      "value": [ {"kind": "turnFlagOff"} ]
    }
  ]
}

cycleTriggerUrl

Generates a new URL for this trigger. You must update any clients using the trigger to use this new URL.

disableTrigger

Disables the trigger. This saves the trigger configuration, but the trigger stops running. To re-enable, use enableTrigger.

enableTrigger

Enables the trigger. If you previously disabled the trigger, it begins running again.

SecurityApiKey
Request
path Parameters
projectKey
required
string <string>

The project key

environmentKey
required
string <string>

The environment key

featureFlagKey
required
string <string>

The feature flag key

id
required
string <string>

The flag trigger ID

Request Body schema: application/json
comment
string
Array of objects (Instruction)

The instructions to perform when updating.

Responses
200

Flag trigger response

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

409

Status conflict

429

Rate limited

patch/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}/{id}
Request samples
application/json
{
  • "comment": "string",
  • "instructions": [
    ]
}
Response samples
application/json
{
  • "_id": "string",
  • "_version": 0,
  • "_creationDate": 0,
  • "_maintainerId": "string",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "string",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 0,
  • "triggerURL": "string",
  • "_links": {
    }
}

Delete flag trigger

Delete a flag trigger by ID.

SecurityApiKey
Request
path Parameters
projectKey
required
string <string>

The project key

environmentKey
required
string <string>

The environment key

featureFlagKey
required
string <string>

The feature flag key

id
required
string <string>

The flag trigger ID

Responses
204

Action succeeded

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

429

Rate limited

delete/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}/{id}
Request samples
curl -i -X DELETE \
  'https://app.launchdarkly.com/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}/{id}' \
  -H 'Authorization: YOUR_API_KEY_HERE'
Response samples
application/json
{
  • "code": "invalid_request",
  • "message": "invalid request body"
}