GitLab · Arazzo Workflow

GitLab Ensure a Branch Exists

Version 1.0.0

Check whether a branch exists and create it from a ref only when missing.

1 workflow 1 source API 1 provider
View Spec View on GitHub CodePlatformSoftware DevelopmentSource ControlArazzoWorkflows

Provider

gitlab

Workflows

ensure-branch-exists
Create a branch only when it does not already exist.
Reads a single branch by name; when it is found the flow ends with the existing branch, and when it is not found the flow creates the branch from the supplied ref.
2 steps inputs: branch, privateToken, projectId, ref outputs: branchName
1
getBranch
Look up the branch by name. A 200 means it already exists; a 404 means it must be created.
2
createBranch
Create the missing branch from the supplied ref.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: GitLab Ensure a Branch Exists
  summary: Check whether a branch exists and create it from a ref only when missing.
  description: >-
    An idempotent branch provisioning flow. The workflow probes the project for
    a named branch and branches on the result: when the branch already exists it
    returns the existing branch details, and when it is missing it creates the
    branch from the supplied ref. Every step spells out its request inline so the
    flow can be read and executed without opening the underlying OpenAPI
    description.
  version: 1.0.0
  x-realizes-capability-ids:
  - BC-4200.40
  x-capability-derivation:
    method: 'deterministic join: sourceDescriptions -> per-tag OpenAPI -> tag/capability edge. No classification at this step.'
    min_confidence: 0.7
    sources:
    - capability_id: BC-4200.40
      capability_name: Software Construction Management
      spec: gitlab-projects-api-openapi.yml
      confidence: 0.8
    model: Turbo EA Capabilities by Vincent Verdet — Turbo EA, https://github.com/vincentmakes/turbo-ea-capabilities, CC BY 4.0
sourceDescriptions:
- name: projectsApi
  url: ../openapi/gitlab-projects-api-openapi.yml
  type: openapi
workflows:
- workflowId: ensure-branch-exists
  summary: Create a branch only when it does not already exist.
  description: >-
    Reads a single branch by name; when it is found the flow ends with the
    existing branch, and when it is not found the flow creates the branch from
    the supplied ref.
  inputs:
    type: object
    required:
    - privateToken
    - projectId
    - branch
    - ref
    properties:
      privateToken:
        type: string
        description: GitLab Private-Token used to authenticate the API calls.
      projectId:
        type: string
        description: The ID or URL-encoded path of the project.
      branch:
        type: string
        description: The branch name to ensure exists.
      ref:
        type: string
        description: The ref (branch name or commit sha) to create the branch from.
  steps:
  - stepId: getBranch
    description: >-
      Look up the branch by name. A 200 means it already exists; a 404 means it
      must be created.
    operationId: getApiV4ProjectsIdRepositoryBranchesBranch
    parameters:
    - name: Private-Token
      in: header
      value: $inputs.privateToken
    - name: id
      in: path
      value: $inputs.projectId
    - name: branch
      in: path
      value: $inputs.branch
    successCriteria:
    - condition: $statusCode == 200 || $statusCode == 404
    outputs:
      existingBranchName: $response.body#/name
    onSuccess:
    - name: alreadyExists
      type: end
      criteria:
      - condition: $statusCode == 200
    - name: needsCreate
      type: goto
      stepId: createBranch
      criteria:
      - condition: $statusCode == 404
  - stepId: createBranch
    description: Create the missing branch from the supplied ref.
    operationId: postApiV4ProjectsIdRepositoryBranches
    parameters:
    - name: Private-Token
      in: header
      value: $inputs.privateToken
    - name: id
      in: path
      value: $inputs.projectId
    - name: branch
      in: query
      value: $inputs.branch
    - name: ref
      in: query
      value: $inputs.ref
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      createdBranchName: $response.body#/name
      createdBranchUrl: $response.body#/web_url
  outputs:
    branchName: $steps.createBranch.outputs.createdBranchName

Work with this as data

Every workflow 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 arazzo workflows

4 MCP tools reach this
  • find_arazzoBrowse and filter every workflow in the catalog.
  • 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 workflow
curl "https://apis.io/api/v1/arazzo/gitlab-ensure-branch-exists-workflow"
All arazzo workflows
curl "https://apis.io/api/v1/arazzo?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.