GitLab API icon

GitLab API

Gitlab

Actions1062

Branches → postApiV4ProjectsIdRepositoryBranches

AI-generated

Summary

Create a new branch in a GitLab project repository using its project ID or URL-encoded path and branch details specified in the request body.

Inputs

  • id (required) — The ID or URL-encoded path of the GitLab project to create the branch in.
  • postApiV4ProjectsIdRepositoryBranches (required) — The request body containing the details for the new branch, following the schema defined in the GitLab API for creating repository branches.
  • baseUrl — The base URL of the GitLab instance; defaults to https://gitlab.com.
  • skipAuthentication — Optionally skip authentication for this request; defaults to false (authentication required).

Output shape

a single JSON object representing the newly created branch as returned by the GitLab API.

Ensures authentication using the configured GitLab API credentials unless skipped. Uses the POST method at the path /api/v4/projects/{id}/repository/branches. Requires valid project ID/path and request body per GitLab specification. No pagination applies since it creates a single resource.

Examples

Example 1: Creating a new branch 'feature-x' from 'main' in project with ID 123

Specify 'id' as '123' and in 'postApiV4ProjectsIdRepositoryBranches' provide JSON with 'branch' and 'ref' properties, e.g., {"branch": "feature-x", "ref": "main"}.

Links

Discussion