---
title: "Execute an operation on a Branch"
method: POST
path: "/spaces/{spaceId}/branches/{branchId}"
tags: ["Manage Branches"]
---

# Execute an operation on a Branch

`POST /spaces/{spaceId}/branches/{branchId}`

Execute an operation on the specified branch. Supported operation types are:

- Merge

## Path parameters

- `spaceId` string, required
- `branchId` string, required

## Request body

- MergeBranchOperation — This operation performs a merge of the branch into another specified branch. Merging a branch into another one means to add all changes of this branch into the specified target branch as a new single commit. During a merge operation conflicts may occur. That will be indicated within the branch response with `state = IN_CONFLICT`. In such a case the conflicts can be solved by the client using the `conflictSolvingBranch` that points to `!<originalBranchId>`. The `merges` property of the branch response depicts all merges that have been executed and/or attempted. The most recent merge attempt is the one with the highest version number. There may be only one merge attempt that is in progress at any time. All other / older entries in the `merges` map depict merge operations that have been executed successfully in the past. Sample: If a merge operation was started on branch `myBranch` and ends up in `state = IN_CONFLICT` the resulting branch response could look like follows: ```json { "id": "myBranch", "baseRef": "main:11", "state": "IN_CONFLICT", "merges": { "27": "main:42" "15": "main:14" } "conflictSolvingBranch": "!myBranch" } ``` Here `"myBranch"` is the ID of the branch that was attempted to be merged into branch `"main"`. It was attempted to merge version `27` of `myBranch` as new commit (with version `42`) into the branch `"main"`. Conflicts occurred during that operation, that is why `state = "IN_CONFLICT"` and the ID of a `"conflictSolvingBranch"` with ID `"!myBranch"` was provided. That conflict solving branch can be used like any other branch to solve the conflicts by writing to it. All conflicting features in there are marked as such having set `conflicting = true` in their XYZ namespace.
  - `type` string, required — The type is: `Merge`
  - `targetBranchId` string — The ID of the branch into which to merge this branch.

## Response `200`

A branch response.

- Branch — A branch is like a separate space, which is based on a specific version of the space or on a specific version of some other branch of the space. Reading & writing features to a branch does not have an effect on the main branch or any other branch of the space. A branch can be created by pointing to a base ref. A base ref consists of the base branch (e.g, "main") and the base version of that base branch. New write transactions to the created branch will continue to increase the version counter starting from the base version. Versions in that branch are independent from the versions of the base branch.
  - `id` string — The branch ID. It must be unique per space.
  - `baseRef` string — The reference onto which the branch has been created. A reference describes a target branch and a version within that target branch. References have the following syntax: `[<branchName (optional, default: main)>:][<version (optional, default: HEAD)>]` The "main"-branch is the space itself as it has been created in the first place. Defining the branch as part of the reference only becomes necessary if further branches have been created for the space, which should be addressed by the ref. Samples: - `main:42` points to version 42 of the "main"-branch - `myBranch:37` Points to version 37 of the branch with ID "myBranch" - `42` points to version 42 of the "main"-branch - `myBranch:HEAD` points to the latest version of the branch with ID "myBranch" - `HEAD` points to the latest version of the "main"-branch - `myBranch` points to the latest version of the branch with ID "myBranch"

## Other responses

- `400` — Malformed or Bad Request.
- `401` — Unauthorized to perform the request.
- `403` — Forbidden request. Insufficient rights to perform the request.
- `404` — Not found.

---

[API](https://skmtc.net/here/apis/here-xyz-hub.md) · [All operations](https://skmtc.net/here/apis/here-xyz-hub/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/here/here-xyz-hub/revisions/1c6c6a2bcac9/schema)
