---
title: "Create a container repository protection rule"
method: POST
path: "/api/v4/projects/{id}/registry/protection/repository/rules"
tags: ["projects"]
---

# Create a container repository protection rule

`POST /api/v4/projects/{id}/registry/protection/repository/rules`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/projects/{id}/registry/protection/repository/rules`
- Auth: none declared

Creates a container repository protection rule for a specified project to control who can push or delete container images.

## Path parameters

- `id` string, required

## Request body

- PostApiV4ProjectsIdRegistryProtectionRepositoryRules: Create a container repository protection rule
  - `repository_path_pattern` string, required: Container repository path pattern protected by the protection rule. For example `flight/flight-*`. Wildcard character `*` allowed.
  - `minimum_access_level_for_push` 'maintainer' | 'owner' | 'admin': Minimum GitLab access level to allow to push container images to the container registry. For example maintainer, owner or admin.
  - `minimum_access_level_for_delete` 'maintainer' | 'owner' | 'admin': Minimum GitLab access level to allow to delete container images in the container registry. For example maintainer, owner or admin.

## Response `201`

Create a container repository protection rule

- APIEntitiesProjectsContainerRegistryProtectionRule: API_Entities_Projects_ContainerRegistry_Protection_Rule model
  - `id` integer, required
  - `project_id` integer, required
  - `repository_path_pattern` string, required
  - `minimum_access_level_for_push` string, required
  - `minimum_access_level_for_delete` string, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `422`: Unprocessable Entity

---

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