---
entity: context-restrictions
namespace: ~
tag: Context Restrictions
description: >
  Restrictions that limit which projects, groups, or expressions may use a context.
---

# Context Restrictions

Restrictions that limit which projects, groups, or expressions may use a context.

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

## GET /api/v3/context-restrictions

Lists every restriction applied to a context.

### Description

The context_id filter is required. A context that does not exist, or that the caller is not entitled to see, returns 404.

All three restriction types are listed together: project, expression and group. A project restriction carries a project reference and a group restriction carries a group reference, each with the subject's name where it can be resolved. An expression restriction has no subject reference — its match_pattern is the expression itself.

created_at is absent on restrictions for which no creation timestamp is recorded.

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| filter[context_id] | uuid | yes |  |

### Response 200

```json
{
  "data": [{
    "id": "uuid",
    "attributes": {
      "restriction_type": "string",
      "match_pattern": "string",
      "name": "string?",
      "created_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.            |

## POST /api/v3/context-restrictions

Creates a restriction for the context referenced in the request body.

### Description

restriction_type is "project", "expression" or "group". match_pattern is the project id, the expression, or the id of the group permitted to use the context respectively. To permit every member of the owning org, use a group restriction whose match_pattern is the org id.

The created item carries the same subject reference the restriction list returns, with the subject id only; the list endpoint resolves subject names.

### Request Body

```json
{
  "data": {
    "attributes": {
      "restriction_type": "string",
      "match_pattern": "string"
    },
    "references": {
      "context": {
        "id": "uuid",
        "rel": "string?",
        "attributes": "string?"
      }
    }
  }
}
```

### Response 201

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

### Errors

| Code | Condition                  | Detail                                   |
|------|----------------------------|------------------------------------------|
| 400  | Invalid restriction type.  |                                          |
| 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.            |

## DELETE /api/v3/context-restrictions/:id

Deletes a context restriction by id.

### Description

The context_id filter is required: restriction ids are only unique within a context, so the context must be named to identify the restriction and to authorise the delete.

Accepts the id of any restriction the list endpoint returns, of any type. For a group restriction that id is the group's id.

### Path Parameters

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

### Query Parameters

| Name | Type | Required | Description        |
|------|------|----------|--------------------|
| filter[context_id] | uuid | 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 context-restrictions does not exist. |

