Create an adaptive trigger
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceKind": "flag",
"task": {
"instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
]
},
"resourceKey": "resourceKey",
"name": "name",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
}
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers"
payload = {
"resourceKind": "flag",
"task": { "instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
] },
"resourceKey": "resourceKey",
"name": "name",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceKind: 'flag',
task: {
instructions: [
{
variationId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
kind: 'updateFallthroughVariationOrRollout',
ruleId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
},
{
variationId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
kind: 'updateFallthroughVariationOrRollout',
ruleId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
}
]
},
resourceKey: 'resourceKey',
name: 'name',
triggerSource: {alertId: 0, type: 'observabilityAlert'}
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resourceKind' => 'flag',
'task' => [
'instructions' => [
[
'variationId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
'kind' => 'updateFallthroughVariationOrRollout',
'ruleId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
],
[
'variationId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
'kind' => 'updateFallthroughVariationOrRollout',
'ruleId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
]
]
],
'resourceKey' => 'resourceKey',
'name' => 'name',
'triggerSource' => [
'alertId' => 0,
'type' => 'observabilityAlert'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers"
payload := strings.NewReader("{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}"
response = http.request(request)
puts response.read_body{
"resourceKind": "flag",
"createdAt": 6,
"task": {
"instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
]
},
"resourceKey": "resourceKey",
"name": "name",
"id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
},
"enabled": true,
"updatedAt": 1
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}Create an adaptive trigger
Create a new adaptive trigger for a resource.
POST
/
api
/
v2
/
projects
/
{projectKey}
/
environments
/
{environmentKey}
/
adaptive-triggers
Create an adaptive trigger
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"resourceKind": "flag",
"task": {
"instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
]
},
"resourceKey": "resourceKey",
"name": "name",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
}
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers"
payload = {
"resourceKind": "flag",
"task": { "instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
] },
"resourceKey": "resourceKey",
"name": "name",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resourceKind: 'flag',
task: {
instructions: [
{
variationId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
kind: 'updateFallthroughVariationOrRollout',
ruleId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
},
{
variationId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
kind: 'updateFallthroughVariationOrRollout',
ruleId: '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
}
]
},
resourceKey: 'resourceKey',
name: 'name',
triggerSource: {alertId: 0, type: 'observabilityAlert'}
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resourceKind' => 'flag',
'task' => [
'instructions' => [
[
'variationId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
'kind' => 'updateFallthroughVariationOrRollout',
'ruleId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
],
[
'variationId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
'kind' => 'updateFallthroughVariationOrRollout',
'ruleId' => '046b6c7f-0b8a-43b9-b35d-6489e6daee91'
]
]
],
'resourceKey' => 'resourceKey',
'name' => 'name',
'triggerSource' => [
'alertId' => 0,
'type' => 'observabilityAlert'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers"
payload := strings.NewReader("{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/adaptive-triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceKind\": \"flag\",\n \"task\": {\n \"instructions\": [\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n },\n {\n \"variationId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"kind\": \"updateFallthroughVariationOrRollout\",\n \"ruleId\": \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\"\n }\n ]\n },\n \"resourceKey\": \"resourceKey\",\n \"name\": \"name\",\n \"triggerSource\": {\n \"alertId\": 0,\n \"type\": \"observabilityAlert\"\n }\n}"
response = http.request(request)
puts response.read_body{
"resourceKind": "flag",
"createdAt": 6,
"task": {
"instructions": [
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
},
{
"variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"kind": "updateFallthroughVariationOrRollout",
"ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91"
}
]
},
"resourceKey": "resourceKey",
"name": "name",
"id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"triggerSource": {
"alertId": 0,
"type": "observabilityAlert"
},
"enabled": true,
"updatedAt": 1
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}{
"code": "code",
"message": "message"
}Authorizations
Body
application/json
Available options:
flag, ai-config Show child attributes
Show child attributes
Example:
{ "alertId": 0, "type": "observabilityAlert" }
Show child attributes
Show child attributes
Example:
{ "instructions": [ { "variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "kind": "updateFallthroughVariationOrRollout", "ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91" }, { "variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "kind": "updateFallthroughVariationOrRollout", "ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } ] }
Response
Adaptive Trigger created
Available options:
flag, ai-config Show child attributes
Show child attributes
Example:
{ "alertId": 0, "type": "observabilityAlert" }
Show child attributes
Show child attributes
Example:
{ "instructions": [ { "variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "kind": "updateFallthroughVariationOrRollout", "ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91" }, { "variationId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "kind": "updateFallthroughVariationOrRollout", "ruleId": "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } ] }