---
title: "POST /repositories/{repository}/branch_protection"
method: POST
path: "/repositories/{repository}/branch_protection"
tags: ["internal"]
deprecated: true
---

# POST /repositories/{repository}/branch_protection

`POST /repositories/{repository}/branch_protection`

## Request

- Base URL: `/api/v1` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/repositories/{repository}/branch_protection`
- Auth: one of:
  - HTTP bearer
  - HTTP basic
  - API key in cookie `internal_auth_session`

> **Deprecated.**

## Request body

- BranchProtectionRule
  - `pattern` string, required: fnmatch pattern for the branch name, supporting * and ? wildcards

## Response `204`

branch protection rule created successfully

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `404`: Resource Not Found
- `429`: too many requests
- `default`: Internal Server Error

## Changes

- **2025-11-24** `add5a8870f32`: 1 info
  - added the non-success response with the status `400`
- **2025-07-29** `27799ffec9a5`: 2 info
  - added the non-success response with the status `429`
  - removed the non-success response with the status `420`
- **2024-09-17** `3b10653a8013`: 3 info
  - added the non-success response with the status `420`
  - removed the non-success response with the status `400`
  - removed the non-success response with the status `429`

[Operation history](https://skmtc.dev/treeverse/apis/lakefs-api/changes/repositories/:repository/branch_protection/post.md)

---

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