Search for context instances
For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Search for context instances.
You can use either the query parameters or the request body parameters. If both are provided, there is an error.
To learn more about the filter syntax, read Filtering contexts and context instances. To learn more about context instances, read Context instances.
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": "{\"filter\": \"kindKeys:{\"contains\": [\"user:Henry\"]},\"sort\": \"-ts\",\"limit\": 50}",
"sort": "-ts",
"limit": 10,
"continuationToken": "QAGFKH1313KUGI2351"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search"
payload = {
"filter": "{\"filter\": \"kindKeys:{\"contains\": [\"user:Henry\"]},\"sort\": \"-ts\",\"limit\": 50}",
"sort": "-ts",
"limit": 10,
"continuationToken": "QAGFKH1313KUGI2351"
}
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({
filter: '{"filter": "kindKeys:{"contains": ["user:Henry"]},"sort": "-ts","limit": 50}',
sort: '-ts',
limit: 10,
continuationToken: 'QAGFKH1313KUGI2351'
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search', 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}/context-instances/search",
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([
'filter' => '{"filter": "kindKeys:{"contains": ["user:Henry"]},"sort": "-ts","limit": 50}',
'sort' => '-ts',
'limit' => 10,
'continuationToken' => 'QAGFKH1313KUGI2351'
]),
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}/context-instances/search"
payload := strings.NewReader("{\n \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\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}/context-instances/search")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search")
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 \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\n}"
response = http.request(request)
puts response.read_body{
"_environmentId": "57be1db38b75bf0772d11384",
"items": [
{
"id": "b3JnOmxhdW5jaGRhcmtseQ",
"context": "{\"kind\": \"user\", \"key\": \"context-key-123abc\", \"name\": \"Sandy Smith\", \"email\": \"sandy@example.com\"}",
"lastSeen": "2022-04-15T15:00:57.526470334Z",
"applicationId": "GoSDK/1.2",
"anonymousKinds": [
"device",
"privateKind"
],
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?filter=applicationId:\"GoSDK/1.2\"",
"type": "application/json"
},
"site": {
"href": "/my-project/my-environment/context-instances/organization:launch-darkly:user:henry",
"type": "text/html"
}
},
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
}
}
],
"_links": {
"next": {
"href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?limit=2&continuationToken=2022-04-15T15:00:57.526470334Z",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-proj/environments/my-env/context-instances/organization:launch-darkly:user:henry-jacobs?limit=2",
"type": "application/json"
}
},
"totalCount": 100,
"continuationToken": "QAGFKH1313KUGI2351"
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The project key
The environment key
Query Parameters
Specifies the maximum number of items in the collection to return (max: 50, default: 20)
Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the next link we provide instead.
Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying ts for this value, or descending order by specifying -ts.
A comma-separated list of context filters. This endpoint only accepts an applicationId filter. To learn more about the filter syntax, read Filtering contexts and context instances.
Specifies whether to include or omit the total count of matching context instances. Defaults to true.
Body
A collection of context instance filters
"{\"filter\": \"kindKeys:{\"contains\": [\"user:Henry\"]},\"sort\": \"-ts\",\"limit\": 50}"
Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying ts for this value, or descending order by specifying -ts.
"-ts"
Specifies the maximum number of items in the collection to return (max: 50, default: 20)
10
Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the next link instead, because this value is an obfuscated string.
"QAGFKH1313KUGI2351"
Response
Context instances collection response
The environment ID
"57be1db38b75bf0772d11384"
A collection of context instances. Can include multiple versions of context instances that have the same id, but different applicationIds.
Show child attributes
Show child attributes
The location and content type of related resources
Show child attributes
Show child attributes
{
"next": {
"href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?limit=2&continuationToken=2022-04-15T15:00:57.526470334Z",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-proj/environments/my-env/context-instances/organization:launch-darkly:user:henry-jacobs?limit=2",
"type": "application/json"
}
}
The number of unique context instances
100
An obfuscated string that references the last context instance on the previous page of results. You can use this for pagination, however, we recommend using the next link instead.
"QAGFKH1313KUGI2351"
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": "{\"filter\": \"kindKeys:{\"contains\": [\"user:Henry\"]},\"sort\": \"-ts\",\"limit\": 50}",
"sort": "-ts",
"limit": 10,
"continuationToken": "QAGFKH1313KUGI2351"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search"
payload = {
"filter": "{\"filter\": \"kindKeys:{\"contains\": [\"user:Henry\"]},\"sort\": \"-ts\",\"limit\": 50}",
"sort": "-ts",
"limit": 10,
"continuationToken": "QAGFKH1313KUGI2351"
}
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({
filter: '{"filter": "kindKeys:{"contains": ["user:Henry"]},"sort": "-ts","limit": 50}',
sort: '-ts',
limit: 10,
continuationToken: 'QAGFKH1313KUGI2351'
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search', 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}/context-instances/search",
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([
'filter' => '{"filter": "kindKeys:{"contains": ["user:Henry"]},"sort": "-ts","limit": 50}',
'sort' => '-ts',
'limit' => 10,
'continuationToken' => 'QAGFKH1313KUGI2351'
]),
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}/context-instances/search"
payload := strings.NewReader("{\n \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\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}/context-instances/search")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search")
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 \"filter\": \"{\\\"filter\\\": \\\"kindKeys:{\\\"contains\\\": [\\\"user:Henry\\\"]},\\\"sort\\\": \\\"-ts\\\",\\\"limit\\\": 50}\",\n \"sort\": \"-ts\",\n \"limit\": 10,\n \"continuationToken\": \"QAGFKH1313KUGI2351\"\n}"
response = http.request(request)
puts response.read_body{
"_environmentId": "57be1db38b75bf0772d11384",
"items": [
{
"id": "b3JnOmxhdW5jaGRhcmtseQ",
"context": "{\"kind\": \"user\", \"key\": \"context-key-123abc\", \"name\": \"Sandy Smith\", \"email\": \"sandy@example.com\"}",
"lastSeen": "2022-04-15T15:00:57.526470334Z",
"applicationId": "GoSDK/1.2",
"anonymousKinds": [
"device",
"privateKind"
],
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?filter=applicationId:\"GoSDK/1.2\"",
"type": "application/json"
},
"site": {
"href": "/my-project/my-environment/context-instances/organization:launch-darkly:user:henry",
"type": "text/html"
}
},
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
}
}
],
"_links": {
"next": {
"href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?limit=2&continuationToken=2022-04-15T15:00:57.526470334Z",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-proj/environments/my-env/context-instances/organization:launch-darkly:user:henry-jacobs?limit=2",
"type": "application/json"
}
},
"totalCount": 100,
"continuationToken": "QAGFKH1313KUGI2351"
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}