How to delete every closed milestone

Since we’re a small team, we set the milestone with the number of the week. ex: week - 12.

But then, when started a new year, we cannot create those milestone anymore because they already exists and are closed.

I would like to delete every closed milestone and tried to use the giltab API for this purpose.

I’ve created the follwing script :

requesting every closed milestone working

  curl -s -H "$private_token" \
  -X GET \

remove_milestone() {
  curl -H "$private_token" \

making a loop and deleting it


# Importes
source ./includes/


  for milestone_id in $(jq -c '.[] | .id'<<< "$issues"); do

  milestone_id= echo ${milestone_id%/r}

  # If not null
    if [ ! "$milestone_id" == "null/r" ];
     remove_milestone $milestone_id


I had to use the ! "$milestone_id" == "null/r" cause I realize I did get null like this.
It is looking a bit stang but it did send the request. I’ll then had this response
curl: (3) URL using bad/illegal format or missing URL

Does somebody see an error?

Is it correct that the groupname is also the enterprisename? I’d expect that the groupname is different, and that the $1 var doesn’t contain the correct groupname.

Edit: sorry I read that wrong, but I can’t see how you’ve put the group_name into the script, but you’d expect that to be the same as during the getting, so if you have a list of milestone_id’s, you’d expect that part to work

created a testgroup and milestone and could remove the milestone with a DELETE query to api/v4/groups/testgroup/milestones/milestone_id (I did use the group_name and not the group ID). I did add a Content-Type application/json header, I can’t see whether you included that.

Not sure where the /r is needed for.

When I pipe json replies through jq, I usually do it when creating a list of ID’s (directly after the curl request or in a separate processing step, not storing the raw json and use an inline processing, but that might be more a personal preference.

Sorry for the late response

I can’t see how you’ve put the group_name into the script,

Yes, I get the correct milestones, this part is working as expected

but that might be more a personal preference.

No, that is a lake of knowledge and I do not know how to loop direct after the curl request but I’ll search, maybe you have a tips for that '^^

Not sure where the /r is needed for.

I had to add this, maybe because I do the loop in an ugly way

Content-Type application/json header

Did you add it for the get request ? It may be the reason why I had to work with the string instead of the json. If this is for the DELETE request, I do not understand the use of it, is it required ?

Thx for your help