DELETE request for stash tag


I am using python requests library to work with stash REST API. With POST request I have no problem to create a new tag on specified commit:



import requests

url = '{}/rest/api/1.0/projects/{}/repos/{}/tags'.format(url, project_name, repo_name)

data = {'force': 'false',
        'message': 'Test tag',
	'name': '1.0',
	'startPoint': 'ffffff',
	'type': 'LIGHTWEIGHT'}

headers = {'Content-Type': 'application/json',
           'X-Atlassian-Token': 'no-check'}

r =, data=data, header=headers)

this gives response 200 and tag 1.0 is created at commit 'ffffff'


<stash base url>/rest/api/1.0/projects/<project>/repos/<repo>/tags

However if I try to follow and make DELETE request:


url = '{}/rest/api/1.0/projects/{}/repos/{}/tags/{}'.format(url, project_name, repo_name, tag)  # where tag is '1.0'

r = requests.delete(url)

I get 404 (not existing) response, and not surprisingly I can't go to url:



<stash base url>/rest/api/1.0/projects/<project>/repos/<repo>/tags/1.0

Even though tag I created is visible in json at:

<stash base url>/rest/api/1.0/projects/<project>/repos/<repo>/tags

So the question is really - what is the correct syntax to access and delete a single tag?

Best Regards,




1 answer

1 accepted

1 vote
Accepted answer
Jeff Thomas Atlassian Team May 02, 2017

Hi Majus,

Looking at the REST documentation you linked, it looks like the endpoint you should be hitting is /rest/git/1.0, not /rest/api/1.0:

url = '{}/rest/git/1.0/projects/{}/repos/{}/tags/{}'.format(url, project_name, repo_name, tag)  # where tag is '1.0'

Can you try updating the URL and see if that resolves the issue?


Hi Jeff,

Thank you for answer. This is correct and it was my mistake to use api instead of git in url. However, this change did not resolve problem fully.

I added a new tag using '/rest/git/1.0/projects/{projectKey}/repos/{repositorySlug}/tags' (with correct git instead of api) as a target url, using the same method as described in original question. Subsequently I removed the tag using request.delete() with git instead of api (also as above). It looked allright (201 response for post and 204 for delete), the tag disappeared from stash rest (and could not be fetched using git from CLI).

But surprisingly the tag was still visible in the GUI


even though it did not exist in git at all! After this, I could overwrite this tag in GUI by making another post request, resulting in new tag and changed tag in GUI.

To the contrary, if I tried to overwrite this tag, before actually deleting it with a request, I got 409 (Confict) response, as could be expected. I got the same behaviour with python requests and curl, i.e. the tag could be successfully deleted from git, but it would remain visible in gui.

This is very baffling for me.

Moreover, only way I have found to delete this hanging tag, was to actually make new tag for the same commit using git CLI:

git tag -a TEST_LATEST_SUCCESSFUL fca6f1
git push --tags

and then explicitly delete it:

git push origin --delete TEST_LATEST_SUCCESSFUL

after that the tag dissappeared from GUI.

Can you try to reproduce this behaviour and tell me, if this issue happens only with me, or is it general Bitbucket problem?

Kind regards,

Majus Misiak

Jeff Thomas Atlassian Team May 04, 2017

Hi Majus,

I'm not able to reproduce what you're seeing at the moment. When I delete a tag via the REST API and refresh the commits page in the UI, the tag no longer appears. Which version are you running? 

I did my testing on Bitbucket Server 4.14.4.

Hi Jeff,

We are using Bitbucket v4.5.2 (1ec1147), so this might be issue related to older version. I will try to reproduce this error with latest Bitbucket version and if it reoccurs I will update this question.

Regardless of that, I accept your first answer as correct.

Thank you for help :)

Majus Misiak


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

656 views 5 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you