GitLab CI/CD branches API

Operations about branches

Operations 8

GET /api/v4/projects/{id}/repository/branches #
POST /api/v4/projects/{id}/repository/branches #
HEAD /api/v4/projects/{id}/repository/branches/{branch} #
GET /api/v4/projects/{id}/repository/branches/{branch} #
DELETE /api/v4/projects/{id}/repository/branches/{branch} #
PUT /api/v4/projects/{id}/repository/branches/{branch}/protect #
PUT /api/v4/projects/{id}/repository/branches/{branch}/unprotect #
DELETE /api/v4/projects/{id}/repository/merged_branches #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/gitlab-ci-branches-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

gitlab-ci-branches-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: GitLab access_requests Branches API
  version: v4
  description: Operations related to access requests
servers:
- url: https://gitlab.com
tags:
- name: branches
  description: Operations about branches
paths:
  /api/v4/projects/{id}/repository/branches:
    get:
      description: Get a project repository branches
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: query
        name: page
        description: Current page number
        required: false
        example: 1
        schema:
          type: integer
          format: int32
          default: 1
      - in: query
        name: per_page
        description: Number of items per page
        required: false
        example: 20
        schema:
          type: integer
          format: int32
          default: 20
      - in: query
        name: search
        description: Return list of branches matching the search criteria
        required: false
        schema:
          type: string
      - in: query
        name: regex
        description: Return list of branches matching the regex
        required: false
        schema:
          type: string
      - in: query
        name: sort
        description: Return list of branches sorted by the given field
        required: false
        schema:
          type: string
          enum:
          - name_asc
          - updated_asc
          - updated_desc
      - in: query
        name: page_token
        description: Name of branch to start the pagination from
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Get a project repository branches
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/API_Entities_Branch'
        '404':
          description: 404 Project Not Found
      tags:
      - branches
      operationId: getApiV4ProjectsIdRepositoryBranches
    post:
      description: Create branch
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      responses:
        '201':
          description: Create branch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/API_Entities_Branch'
        '400':
          description: Failed to create branch
      tags:
      - branches
      operationId: postApiV4ProjectsIdRepositoryBranches
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postApiV4ProjectsIdRepositoryBranches'
        required: true
  /api/v4/projects/{id}/repository/branches/{branch}:
    head:
      description: Check if a branch exists
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: path
        name: branch
        description: The name of the branch
        required: true
        schema:
          type: string
      responses:
        '204':
          description: No Content
        '404':
          description: Not Found
      tags:
      - branches
      operationId: headApiV4ProjectsIdRepositoryBranchesBranch
    get:
      description: Get a single repository branch
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: path
        name: branch
        required: true
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: Get a single repository branch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/API_Entities_Branch'
        '404':
          description: Branch Not Found
      tags:
      - branches
      operationId: getApiV4ProjectsIdRepositoryBranchesBranch
    delete:
      description: Delete a branch
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: path
        name: branch
        description: The name of the branch
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Delete a branch
        '404':
          description: Branch Not Found
      tags:
      - branches
      operationId: deleteApiV4ProjectsIdRepositoryBranchesBranch
  /api/v4/projects/{id}/repository/branches/{branch}/protect:
    put:
      description: Protect a single branch
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: path
        name: branch
        description: The name of the branch
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Protect a single branch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/API_Entities_Branch'
        '404':
          description: 404 Branch Not Found
      tags:
      - branches
      operationId: putApiV4ProjectsIdRepositoryBranchesBranchProtect
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/putApiV4ProjectsIdRepositoryBranchesBranchProtect'
        required: true
  /api/v4/projects/{id}/repository/branches/{branch}/unprotect:
    put:
      description: Unprotect a single branch
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      - in: path
        name: branch
        description: The name of the branch
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Unprotect a single branch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/API_Entities_Branch'
        '404':
          description: 404 Project Not Found
      tags:
      - branches
      operationId: putApiV4ProjectsIdRepositoryBranchesBranchUnprotect
  /api/v4/projects/{id}/repository/merged_branches:
    delete:
      description: Delete all merged branches
      parameters:
      - in: path
        name: id
        description: The ID or URL-encoded path of the project
        required: true
        schema:
          type: string
      responses:
        '202':
          description: 202 Accepted
        '404':
          description: 404 Project Not Found
      tags:
      - branches
      operationId: deleteApiV4ProjectsIdRepositoryMergedBranches
components:
  schemas:
    postApiV4ProjectsIdRepositoryBranches:
      type: object
      properties:
        branch:
          type: string
          description: The name of the branch
        ref:
          type: string
          description: Create branch from commit sha or existing branch
      required:
      - branch
      - ref
      description: Create branch
    putApiV4ProjectsIdRepositoryBranchesBranchProtect:
      type: object
      properties:
        developers_can_push:
          type: boolean
          description: Flag if developers can push to that branch
        developers_can_merge:
          type: boolean
          description: Flag if developers can merge to that branch
      description: Protect a single branch
    API_Entities_Commit:
      type: object
      properties:
        id:
          type: string
          example: 2695effb5807a22ff3d138d593fd856244e155e7
        short_id:
          type: string
          example: 2695effb
        created_at:
          type: string
          format: date-time
          example: '2017-07-26T11:08:53.000+02:00'
        parent_ids:
          type: array
          items:
            type: string
          example:
          - 2a4b78934375d7f53875269ffd4f45fd83a84ebe
        title:
          type: string
          example: Initial commit
        message:
          type: string
          example: Initial commit
        author_name:
          type: string
          example: John Smith
        author_email:
          type: string
          example: john@example.com
        authored_date:
          type: string
          format: date-time
          example: '2012-05-28T04:42:42-07:00'
        committer_name:
          type: string
          example: Jack Smith
        committer_email:
          type: string
          example: jack@example.com
        committed_date:
          type: string
          format: date-time
          example: '2012-05-28T04:42:42-07:00'
        trailers:
          type: object
          example:
            Merged-By: Jane Doe janedoe@gitlab.com
        extended_trailers:
          type: object
          example:
            Signed-off-by:
            - John Doe <johndoe@gitlab.com>
            - Jane Doe <janedoe@gitlab.com>
        web_url:
          type: string
          example: https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746
      required:
      - id
      - short_id
      - created_at
      - parent_ids
      - title
      - message
      - author_name
      - author_email
      - authored_date
      - committer_name
      - committer_email
      - committed_date
      - trailers
      - extended_trailers
      - web_url
      description: API_Entities_Commit model
    API_Entities_Branch:
      type: object
      properties:
        name:
          type: string
          example: master
        commit:
          $ref: '#/components/schemas/API_Entities_Commit'
        merged:
          type: boolean
          example: true
        protected:
          type: boolean
          example: true
        developers_can_push:
          type: boolean
          example: true
        developers_can_merge:
          type: boolean
          example: true
        can_push:
          type: boolean
          example: true
        default:
          type: boolean
          example: true
        web_url:
          type: string
          example: https://gitlab.example.com/Commit921/the-dude/-/tree/master
      required:
      - name
      - commit
      - merged
      - protected
      - developers_can_push
      - developers_can_merge
      - can_push
      - default
      - web_url
      description: API_Entities_Branch model
  securitySchemes:
    access_token_header:
      type: apiKey
      name: PRIVATE-TOKEN
      in: header
    access_token_query:
      type: apiKey
      name: private_token
      in: query