# Delete Branch

## API Name

API Name: Branch – Delete

***

## Overview

This API deletes an existing branch within a given project.

MBSE Core uses this API to:

* Clean up temporary branches
* Remove synchronization branches
* Manage branch lifecycle

Connector responsibility:

* Call the end system API to delete the specified branch.
* Ensure deletion is scoped to the given project.
* Return appropriate HTTP status based on outcome.

***

### API URI

```bash
DELETE: /mbse/api/1.0/branches/{branchId}
    ?projectId={projectId}
```

***

### Path Parameters

| Name     | Mandatory | Type   | Description                     |
| -------- | --------- | ------ | ------------------------------- |
| branchId | True      | String | ID of the branch to be deleted. |

***

### URI Parameters

| Name      | Mandatory | Type   | Description                                   |
| --------- | --------- | ------ | --------------------------------------------- |
| projectId | True      | String | ID of the project in which the branch exists. |

***

### Behavior Rules

1. Branch deletion must be scoped to the provided `projectId`.
2. Connector must call the end system API to delete the branch.
3. If deletion is successful:
   * Return HTTP `204 No Content`.
4. If branch does not exist:
   * Return HTTP `404 Not Found`.
5. If branch cannot be deleted due to system constraints (e.g., default branch or protected branch):
   * Return HTTP `409 Conflict` or appropriate error code.
6. Connector must not silently ignore failures.

***

### Response

This API does not return a response body.

#### Successful Deletion

HTTP Status: `204 No Content`

***

### Error Handling

| HTTP Status | Description                                                               |
| ----------- | ------------------------------------------------------------------------- |
| 400         | Invalid request parameters.                                               |
| 404         | Branch not found in the specified project.                                |
| 409         | Branch cannot be deleted (protected/default branch or system constraint). |
| 500         | Internal server error during branch deletion.                             |

***

### Example Use Case

#### Delete Branch

```bash
DELETE /mbse/api/1.0/branches/branch_20260214123045?
projectId=123
```

***

### Implementation Guidelines

* Ensure the branch belongs to the specified project before attempting deletion.
* Do not allow accidental deletion of protected or default branches unless explicitly supported.
* Validate branch existence before deletion if required by end system.
* Return deterministic and meaningful error codes.

***

### Design Rationale

This API provides controlled branch lifecycle management.

By enforcing:

* Project scoping
* Explicit error handling
* No response body on success

The API maintains predictable and safe branch deletion behavior across heterogeneous MBSE systems.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://opstech.gitbook.io/opstech-docs/7.223/mbse-connector-sdk-index/mbse-sdk-connector-apis/branch-apis/delete-branch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
