---
title: "Get contexts"
method: GET
path: "/api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{kind}/{key}"
tags: ["Contexts"]
---

# Get contexts

`GET /api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{kind}/{key}`

Get contexts based on kind and key.

## Path parameters

- `projectKey` string, string, required — The project key
- `environmentKey` string, string, required — The environment key
- `kind` string, string, required — The context kind
- `key` string, string, required — The context key

## Query parameters

- `limit` integer — Specifies the maximum number of items in the collection to return (max: 50, default: 20)
- `continuationToken` string, string — Limits results to contexts with sort values after the value specified. You can use this for pagination, however, we recommend using the `next` link we provide instead.
- `sort` string, 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`.
- `filter` string, 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).
- `includeTotalCount` boolean — Specifies whether to include or omit the total count of matching contexts. Defaults to true.

## Response `200`

Contexts collection response

- Contexts
  - `_links` object — The location and content type of related resources
  - `totalCount` integer — The number of contexts
  - `_environmentId` string, required — The environment ID where the context was evaluated
  - `continuationToken` string — 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 <code>next</code> link instead.
  - `items` ContextRecord[], required — A collection of contexts. Can include multiple versions of contexts that have the same <code>kind</code> and <code>key</code>, but different <code>applicationId</code>s.
    - `lastSeen` string, date-time — Timestamp of the last time an evaluation occurred for this context
    - `applicationId` string — An identifier representing the application where the LaunchDarkly SDK is running
    - `context` string, required — The context, including its kind and attributes
    - `_links` object — The location and content type of related resources
    - `_access` Access
      - `denied` AccessDenied[], required
        - `action` string, required
        - `reason` AccessDeniedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string
      - `allowed` AccessAllowedRep[], required
        - `action` string, required
        - `reason` AccessAllowedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string
    - `associatedContexts` integer — The total number of associated contexts. Associated contexts are contexts that have appeared in the same context instance, that is, they were part of the same flag evaluation.

## Other responses

- `400` — Invalid request
- `401` — Invalid access token
- `403` — Forbidden
- `429` — Rate limited

---

[API](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/revisions/69c5c9aafe78/schema)
