---
title: "Delete a branch"
method: DELETE
path: "/repositories/{workspace}/{repo_slug}/refs/branches/{name}"
tags: ["Refs"]
---

# Delete a branch

`DELETE /repositories/{workspace}/{repo_slug}/refs/branches/{name}`

## Request

- Base URL: `https://api.bitbucket.org/2.0`
- URL: `https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches/{name}`
- Auth: one of:
  - OAuth 2
    - Authorization code: `https://bitbucket.org/site/oauth2/authorize`
    - Token URL: `https://bitbucket.org/site/oauth2/access_token` scopes: `repository:write`
  - HTTP basic
  - API key in header `Authorization`

Delete a branch in the specified repository.

The main branch is not allowed to be deleted and will return a 400
response.

The branch name should not include any prefixes (e.g.
refs/heads).

## Response `204`

Indicates that the specified branch was successfully deleted.

## Other responses

- `403`: If the repository is private and the authenticated user does not have access to it.
- `404`: The specified repository or branch does not exist.

---

[API](https://skmtc.dev/atlassian/apis/bitbucket-api.md) - [All operations](https://skmtc.dev/atlassian/apis/bitbucket-api/llms.txt) - [OpenAPI document](https://skmtc.dev/atlassian/apis/bitbucket-api/revisions/6ae783fa75da?raw)
