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.

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

401

Invalid access token

403

Forbidden

429

Rate limited

get/api/v2/flags/{projectKey}/{featureFlagKey}/triggers/{environmentKey}
Request samples
Response samples
application/json
{
  • "items": [
    ],
  • "_links": {
    }
}

Create flag trigger

Create a new flag trigger.

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

Optional comment describing the trigger

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

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": 1,
  • "_creationDate": 0,
  • "_maintainerId": "12ab3c45de678910abc12345",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "generic-trigger",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 3,
  • "triggerURL": "string",
  • "_links": {
    }
}

Get flag trigger by ID

Get a flag trigger by ID.

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
Response samples
application/json
{
  • "_id": "string",
  • "_version": 1,
  • "_creationDate": 0,
  • "_maintainerId": "12ab3c45de678910abc12345",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "generic-trigger",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 3,
  • "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.

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

Optional comment describing the update

Array of objects (Instruction)

The instructions to perform when updating. This should be an array with objects that look like {"kind": "trigger_action"}.

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": "optional comment",
  • "instructions": [
    ]
}
Response samples
application/json
{
  • "_id": "string",
  • "_version": 1,
  • "_creationDate": 0,
  • "_maintainerId": "12ab3c45de678910abc12345",
  • "_maintainer": {
    },
  • "enabled": true,
  • "_integrationKey": "generic-trigger",
  • "instructions": [
    ],
  • "_lastTriggeredAt": 0,
  • "_recentTriggerBodies": [
    ],
  • "_triggerCount": 3,
  • "triggerURL": "string",
  • "_links": {
    }
}

Delete flag trigger

Delete a flag trigger by ID.

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
Response samples
application/json
{
  • "code": "invalid_request",
  • "message": "Invalid request body"
}