For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
      • PUTCreate or update context kind
      • DELDelete context instances
      • POSTEvaluate flags for context instance
      • GETGet context attribute names
      • GETGet context attribute values
      • GETGet context instances
      • GETGet context kinds
      • GETGet contexts
      • POSTSearch for context instances
      • POSTSearch for contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewContexts

Search for context instances

POST
/api/v2/projects/:projectKey/environments/:environmentKey/context-instances/search
POST
/api/v2/projects/:projectKey/environments/:environmentKey/context-instances/search
$curl -X POST https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/context-instances/search \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{}'
1{
2 "_environmentId": "57be1db38b75bf0772d11384",
3 "items": [
4 {
5 "id": "b3JnOmxhdW5jaGRhcmtseQ",
6 "context": null,
7 "lastSeen": "2022-04-15T15:00:57.526470334Z",
8 "applicationId": "GoSDK/1.2",
9 "anonymousKinds": [
10 "device",
11 "privateKind"
12 ],
13 "_links": {
14 "parent": {
15 "href": "/api/v2/projects/my-project/environments/my-environment",
16 "type": "application/json"
17 },
18 "self": {
19 "href": "/api/v2/projects/my-project/environments/my-env/context-instances/organization:launch-darkly:user:henry?filter=applicationId:\"GoSDK/1.2\"",
20 "type": "application/json"
21 },
22 "site": {
23 "href": "/my-project/my-environment/context-instances/organization:launch-darkly:user:henry",
24 "type": "text/html"
25 }
26 },
27 "_access": {
28 "denied": [
29 {
30 "action": "string",
31 "reason": {
32 "effect": "allow",
33 "resources": [
34 "proj/*:env/*;qa_*:/flag/*"
35 ],
36 "notResources": [
37 "string"
38 ],
39 "actions": [
40 "*"
41 ],
42 "notActions": [
43 "string"
44 ],
45 "role_name": "string"
46 }
47 }
48 ],
49 "allowed": [
50 {
51 "action": "string",
52 "reason": {
53 "effect": "allow",
54 "resources": [
55 "proj/*:env/*;qa_*:/flag/*"
56 ],
57 "notResources": [
58 "string"
59 ],
60 "actions": [
61 "*"
62 ],
63 "notActions": [
64 "string"
65 ],
66 "role_name": "string"
67 }
68 }
69 ]
70 }
71 }
72 ],
73 "_links": {
74 "next": {
75 "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",
76 "type": "application/json"
77 },
78 "self": {
79 "href": "/api/v2/projects/my-proj/environments/my-env/context-instances/organization:launch-darkly:user:henry-jacobs?limit=2",
80 "type": "application/json"
81 }
82 },
83 "totalCount": 100,
84 "continuationToken": "QAGFKH1313KUGI2351"
85}
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](https://launchdarkly.com/docs/api/contexts#filtering-contexts-and-context-instances). To learn more about context instances, read [Context instances](https://launchdarkly.com/docs/home/observability/multi-contexts#context-instances).
Was this page helpful?
Previous

Search for contexts

Next
Built with

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.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key

Query parameters

limitlongOptional

Specifies the maximum number of items in the collection to return (max: 50, default: 20)

continuationTokenstringOptionalformat: "string"

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.

sortstringOptionalformat: "string"

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.

filterstringOptionalformat: "string"
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](https://launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts-and-context-instances).
includeTotalCountbooleanOptional
Specifies whether to include or omit the total count of matching context instances. Defaults to true.

Request

This endpoint expects an object.
filterstringOptional
A collection of context instance filters
sortstringOptional

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.

limitintegerOptional

Specifies the maximum number of items in the collection to return (max: 50, default: 20)

continuationTokenstringOptional

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.

Response

Context instances collection response
_environmentIdstring
The environment ID
itemslist of objects

A collection of context instances. Can include multiple versions of context instances that have the same id, but different applicationIds.

_linksmap from strings to objects
The location and content type of related resources
totalCountinteger
The number of unique context instances
continuationTokenstring

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.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error

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.