---
title: "merge branches"
method: POST
path: "/branch/{workspace_id}/merge"
tags: ["Branch"]
---

# merge branches

`POST /branch/{workspace_id}/merge`

Used to merge a branch into another

## Path parameters

- `workspace_id` string, required

## Query parameters

- `from` string
- `to` string

## Request body

- BranchMergeRequest — A request to merge a branch into another branch
  - `diff_match` string — A hash of the sorted list of [<target_branch_entity_id>, <source_branch_entity_id>] pairs for the entities being merged (all branched entities, or just entity_ids when that is set). This is sorted in ascending order by the second entity ID in the pair.
  - `to` string — The name of the branch to merge into. Defaults to master.
  - `from` string — The name of the branch to merge from
  - `entity_ids` string[] — Optional. Invariant IDs of specific branched entities to merge. When present and non-empty, only these entities are merged into the target branch and removed from the source branch, which stays open. When absent or empty, the entire branch is merged and the source branch is marked merged (the default behavior).

## Response `200`

The merged branch

- Branch — A test branch
  - `id` string — Unique ID for this branch
  - `branch_type` 'feature' | 'snapshot' — The type of branch
  - `name` string — The name of the branch. Must be unique within workspace.
  - `status` 'merged' | 'open' | 'snapshot' — The current status of the branch
  - `application_id` string — The ID of the application associated with this branch
  - `environment_id` string — Optional id of environment this branch is associated with, if any
  - `source_control` SourceControl
    - `revision` string — the primary source revision associated with this object
    - `revisions` string[] — all source revision ids associated with this object
    - `commit_username` string — the username of the user who committed the revision associated with this object
    - `branch_name` string — the branch associated with this object
    - `branches` SourceControlBranch[] — Related branches
      - `name` string, required — repository unique branch name
      - `html_url` string, required — HTML page url to view branch tree
    - `pull_request` SourceControlPullRequest — the pull request associated with this object
      - `id` string — vendor unique pull request identifier (immutable)
      - `number` integer — the number associated with the pull request (repository unique)
      - `title` string — the title of the pull request
      - `html_url` string — HTML page url to view pull request object
    - `pull_requests` SourceControlPullRequest[] — Related pull requests
      - `id` string — vendor unique pull request identifier (immutable)
      - `number` integer — the number associated with the pull request (repository unique)
      - `title` string — the title of the pull request
      - `html_url` string — HTML page url to view pull request object
    - `authors` SourceControlAuthor[] — Related authors. Should be at least one
      - `id` string, required — vendor unique author id (invariant)
      - `user_name` string, required — author username name (mutable)
      - `name` string — author full name (mutable)
      - `email` string — author email
      - `html_url` string, required — HTML page url to view author
      - `avatar_url` string, required — author avatar image URL
      - `user_type` string — repository name unique within owner scope
    - `repository_url` string — the url of the repository associated with this object
    - `repository_name` string — the name of the repository associated with this object
    - `repository` SourceControlRepository — the SCM repository associated with this object
      - `id` string, required — vendor unique repository id (immutable)
      - `name` string, required — repository name unique within owner scope
      - `full_name` string — vendor unique name to identify this repo across all vendor's repos
      - `owner_name` string, required — repository name unique within owner scope
      - `owner` SourceControlRepositoryOwner — the SCM repository associated with this object
        - `id` string, required — vendor unique repository id (immutable)
        - `name` string, required — repository name unique within owner scope
        - `owner_type` string, required — repository name unique within owner scope
        - `html_url` string, required — HTML page url to view branch tree
        - `avatar_url` string — owner avatar image URL
      - `html_url` string, required — HTML page url to view branch tree
      - `is_public` boolean — true if repository publicly visible
      - `checkout_url` string — SCM remote checkout path
  - `entities` BranchedEntity[] — List of branched entities and the initial version they were branched off of
    - `id` string, required — The unversioned id
    - `type` 'test' | 'flow', required — The type of the branched entitiy
    - `versions` integer[], required — The list of version ids saved to branch
    - `branched_from` integer — DEPRECATED - The version id branched from
  - `journeys` VersionedTestId[] — (deprecated use entities instead) List of branched journeys and the initial version they were branched off of
    - `journey_id` string — The unversioned test id
    - `version` integer — The test version
  - `flows` VersionedFlowId[] — (deprecated use entities instead) List of branched flows and the initial version they were branched off of
    - `flow_id` string — The unversioned flow id
    - `version` integer — The flow version
  - `branched_from` string — The branch this branch was created from
  - `merge_info` BranchMergeInfo — Information about a merged branch
    - `merged_time` integer — Time at which the branch was merged
    - `merged_by_id` string — The ID of the user who merged this branch
    - `merged_to` string — The branch this was merged into
    - `entities` MergedEntity[] — List of merged entities and the versions merged
      - `id` string, required — The unversioned id
      - `type` 'test' | 'flow', required — The type of the merged entity
      - `source_version` integer, required — The entity version on the source branch prior to the merge
      - `target_version` integer — The entity version on the target branch prior to the merge, if applicable
      - `version` integer, required — The merged entity version on the target branch after the merge
  - `workspace_id` string — Workspace this branch exists in
  - `created_time` integer — Time at which the deployment was created
  - `created_by_id` string — The ID of the user who created this deployment

## Other responses

- `400` — Invalid or missing parameter
- `401` — User not authenticated
- `403` — User not authorized
- `404` — Unknown error
- `409` — Unknown error
- `default` — Unknown error

---

[API](https://skmtc.net/mabl/apis/mabl-api.md) · [All operations](https://skmtc.net/mabl/apis/mabl-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mabl/mabl-api/revisions/d0fc0114da66/schema)
