GitLab API

GitlabTool

Actions1095

Projects → postApiV4ProjectsIdProtectedBranches

AI-generated

Summary

Create a protected branch for a specified GitLab project by sending its ID or URL-encoded path along with the branch protection details.

Inputs

  • id (required) — The ID or URL-encoded path of the project where the protected branch will be created.
  • postApiV4ProjectsIdProtectedBranches (required) — The request body containing the protected branch details as defined by the GitLab API schema.
  • baseUrl — The base URL of the GitLab instance (defaults to https://gitlab.com).
  • skipAuthentication — Whether to skip authentication for this request (default is false).

Output shape

a JSON object representing the newly created protected branch returned by the GitLab API

Requires authentication unless 'Skip Authentication' is enabled. The output conforms to the GitLab API response for creating protected branches.

Examples

Example 1: Create a new protected branch named 'release' in project with ID 'gitlab-org/gitlab'.

Set 'id' parameter to 'gitlab-org/gitlab', provide the required branch protection fields in the request body, leave 'baseUrl' as default, and ensure authentication is enabled.

Links

Discussion