# Add repo protection rule

Endpoint: POST /code/api/v1/repos/{repo_identifier}/rules
Version: 1.0
Security: x-api-key

## Query parameters:

  - `accountIdentifier` (string, required)
    Account Identifier for the Entity.

  - `orgIdentifier` (string)
    Organization Identifier for the Entity.

  - `projectIdentifier` (string)
    Project Identifier for the Entity.

## Path parameters:

  - `repo_identifier` (string, required)

## Request fields (application/json):

  - `definition` (object)

  - `description` (string)

  - `identifier` (string)

  - `pattern` (object,null)

  - `pattern.default` (boolean)

  - `pattern.exclude` (array)

  - `pattern.include` (array)

  - `repo_target` (object,null)

  - `repo_target.exclude` (object)

  - `repo_target.exclude.ids` (array)

  - `repo_target.exclude.patterns` (array)

  - `repo_target.include` (object)

  - `state` (string,null)
    Enum: "active", "disabled", "monitor"

  - `type` (string)
    Enum: "branch", "tag", "push"

  - `uid` (string)

## Response 201 fields (application/json):

  - `created` (integer)

  - `created_by` (object,null)

  - `created_by.created` (integer)

  - `created_by.display_name` (string)

  - `created_by.email` (string)

  - `created_by.id` (integer)

  - `created_by.type` (string)
    Enum: "service", "serviceaccount", "user"

  - `created_by.uid` (string)

  - `created_by.updated` (integer)

  - `definition` (object)

  - `description` (string)

  - `identifier` (string)

  - `pattern` (object,null)

  - `repo_target` (object,null)

  - `repositories` (object,null)

  - `scope` (integer)

  - `state` (string,null)
    Enum: "active", "disabled", "monitor"

  - `type` (string)
    Enum: "branch", "tag", "push"

  - `updated` (integer)

  - `user_groups` (object,null)

  - `users` (object,null)

## Response 401 fields (application/json):

  - `message` (string)

  - `values` (object)


