---
entity: contexts
namespace: ~
tag: Contexts
description: >
  Secret contexts that provide environment variables to jobs at runtime.
---

# Contexts

Secret contexts that provide environment variables to jobs at runtime.

Conventions: /docs/api/v3/conventions.md

## GET /api/v3/contexts

Lists the contexts owned by an organization.

### Description

The org_id filter is required. The optional name filter matches case-insensitively on any part of the context name and is applied upstream, so it also narrows what pagination walks.

include=restrictions embeds each context's group restrictions, with the group names, under the references key "context-restrictions" — the same shape the single-context read documents. That is what a caller rendering a list of contexts and who may use them needs, in one request.

Project and expression restrictions are not embedded here. They are addressable only one context at a time, so including them across a page would cost a lookup per context. Read those from the context-restrictions endpoint, or from the single-context read, which embeds every type.

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| filter[name] | string | no |  |
| filter[org_id] | uuid | yes |  |
| include | string | no |  |
| page[cursor] | string | no |  |
| page[limit] | int | no |  |

### Response 200

```json
{
  "data": [{
    "id": "uuid",
    "attributes": {
      "name": "string",
      "created_at": "datetime"
    }
  }],
  "page": {
    "next": "string?",
    "prev": "string?"
  }
}
```

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Include accepts "restrictions" only. |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |

## POST /api/v3/contexts

Creates a context owned by an organization.

### Request Body

```json
{
  "data": {
    "attributes": {
      "name": "string"
    },
    "references": {
      "org": {
        "id": "uuid",
        "rel": "string?",
        "attributes": "string?"
      }
    }
  }
}
```

### Response 201

```json
{
  "data": {
    "id": "uuid",
    "attributes": {
      "name": "string",
      "created_at": "datetime"
    },
    "references": {
      "org?": {
        "id": "uuid"
      },
      "context-restrictions?": [{
        "id": "uuid"
      }]
    }
  }
}
```

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Bad Request                |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |

## GET /api/v3/contexts/:id

Returns a single context by id.

### Description

The response carries the context itself. What restricts it is reported by the context-restrictions endpoint, and is embedded here under the references key "context-restrictions" only when the caller passes include=restrictions — every restriction type, each with the name of the project or group it points at.

### Path Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| id | uuid | yes | The id. |

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| include | string | no |  |

### Response 200

```json
{
  "data": {
    "id": "uuid",
    "attributes": {
      "name": "string",
      "created_at": "datetime"
    },
    "references": {
      "org?": {
        "id": "uuid"
      },
      "context-restrictions?": [{
        "id": "uuid"
      }]
    }
  }
}
```

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Include accepts "restrictions" only. |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |
| 404  | Entity not found           | The requested contexts does not exist. |

## DELETE /api/v3/contexts/:id

Deletes a context by id.

### Path Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| id | uuid | yes | The id. |

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Bad Request                |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |
| 404  | Entity not found           | The requested contexts does not exist. |

## GET /api/v3/contexts/:id/env-vars

Lists the environment variables of a context.

### Description

Values are never returned; each item carries truncated_value, the last four characters of the secret, so a caller can tell which value is in a slot. Items have no id — environment variables are addressed by name.

### Path Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| id | uuid | yes | The id. |

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| page[cursor] | string | no |  |
| page[limit] | int | no |  |

### Response 200

```json
{
  "data": [{
    "id": "uuid",
    "attributes": {
      "name": "string",
      "truncated_value": "string?",
      "created_at": "datetime",
      "updated_at": "datetime"
    },
    "references": {
      "context": {
        "id": "uuid"
      }
    }
  }],
  "page": {
    "next": "string?",
    "prev": "string?"
  }
}
```

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Bad Request                |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |
| 404  | Entity not found           | The requested contexts does not exist. |

## DELETE /api/v3/contexts/:id/env-vars

Deletes an environment variable from a context by name.

### Path Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| id | uuid | yes | The id. |

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| filter[name] | string | yes |  |

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Bad Request                |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |
| 404  | Entity not found           | The requested contexts does not exist. |

## POST /api/v3/contexts/:id/env-vars/set

Creates or updates an environment variable in a context.

### Description

Always responds 200 with the stored variable, whether or not it already existed. The returned item carries no id — environment variables are addressed by name — and no truncated_value.

### Path Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| id | uuid | yes | The id. |

### Request Body

```json
{
  "name": "string",
  "value": "string"
}
```

### Response 200

```json
{
  "data": {
    "attributes": {
      "name": "string",
      "created_at": "datetime",
      "updated_at": "datetime"
    },
    "references": {
      "context": {
        "id": "uuid"
      }
    }
  }
}
```

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Bad Request                |                                          |
| 401  | Invalid or missing token   | Provide a valid Authorization header.    |
| 403  | Insufficient permissions   | You do not have access to this resource. |
| 429  | Rate limit exceeded        | Too many requests. See Retry-After header. |
| 500  | Internal server error      | An unexpected error occurred.            |
| 404  | Entity not found           | The requested contexts does not exist. |

