Segments
Get expiring user targets for segment
For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Contexts are now available
After you have upgraded your LaunchDarkly SDK to use contexts instead of users, you should use Get expiring targets for segment instead of this endpoint. To learn more, read Contexts.
Get a list of a segment’s user targets that are scheduled for removal.
GET
/
api
/
v2
/
segments
/
{projectKey}
/
{segmentKey}
/
expiring-user-targets
/
{environmentKey}
Get expiring user targets for segment
curl --request GET \
--url https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey} \
--header 'Authorization: <api-key>'import requests
url = "https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}', 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/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"items": [
{
"_id": "12ab3c45de678910fgh12345",
"_version": 1,
"expirationDate": "1658192820000",
"userKey": "example-user-key",
"_resourceId": {
"kind": "<string>",
"projectKey": "<string>",
"environmentKey": "<string>",
"flagKey": "<string>",
"key": "<string>"
},
"targetType": "included",
"variationId": "ce67d625-a8b9-4fb5-a344-ab909d9d4f4d"
}
],
"_links": {}
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The project key
The environment key
The segment key
⌘I
Get expiring user targets for segment
curl --request GET \
--url https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey} \
--header 'Authorization: <api-key>'import requests
url = "https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}', 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/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"items": [
{
"_id": "12ab3c45de678910fgh12345",
"_version": 1,
"expirationDate": "1658192820000",
"userKey": "example-user-key",
"_resourceId": {
"kind": "<string>",
"projectKey": "<string>",
"environmentKey": "<string>",
"flagKey": "<string>",
"key": "<string>"
},
"targetType": "included",
"variationId": "ce67d625-a8b9-4fb5-a344-ab909d9d4f4d"
}
],
"_links": {}
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}