---
title: "Create context restriction"
method: POST
path: "/context/{context_id}/restrictions"
tags: ["Context"]
---

# Create context restriction

`POST /context/{context_id}/restrictions`

## Request

- Base URL: `https://circleci.com/api/v2`
- URL: `https://circleci.com/api/v2/context/{context_id}/restrictions`
- Auth: one of:
  - API key in header `Circle-Token`
  - HTTP bearer
  - HTTP basic
  - API key in query parameter `circle-token`

Creates project or expression restriction on a context.

## Request body

- object
  - `restriction_type` 'project' | 'expression' | 'group': Type of the restriction.
  - `restriction_value` string: Value used to evaluate the restriction. If the `restriction_type` is `project`, this will be the project UUID. If the `restriction_type` is `expression`, this will be the expression rule.

## Response `201`

Successful response.

- RestrictionCreated
  - `id` string, uuid: UUID of the project restriction
  - `project_id` string, uuid: Deprecated - For "project" restrictions read the project ID from "restriction_value" instead. UUID of the project used in a project restriction.
  - `name` string: Contains a human-readable reference for the restriction. For "project" restrictions this is the name of the project. May be null.
  - `restriction_type` 'project' | 'expression' | 'group': Type of the restriction
  - `restriction_value` string: Value used to evaluate the restriction

## Other responses

- `400`: Bad request.
- `401`: Credentials provided are invalid.
- `404`: Entity not found.
- `409`: Request conflict.
- `429`: API rate limits exceeded.
- `500`: Internal server error.

---

[API](https://skmtc.dev/circleci/apis/circleci-api.md) - [All operations](https://skmtc.dev/circleci/apis/circleci-api/llms.txt) - [OpenAPI document](https://skmtc.dev/circleci/apis/circleci-api/revisions/b9c0e0c24058?raw)
