How to delete labels from Jira tickets using Python API

I’m working with the Jira Python library and I can successfully add labels to tickets like this:

ticket.fields.labels.append("NEWTAGNAME")

However, I’m struggling to find a way to delete existing labels. I’ve spent hours searching through documentation and online resources but can’t figure out the correct syntax. I attempted to use a similar approach that works for removing components, but it fails for labels:

# This approach fails:
ticket.update(update={"labels": [{"remove": {"name": "OLDTAGNAME"}}],},)

# This works fine for components:
ticket.update(update={"components": [{"remove": {"name": "OLDCOMPONENTNAME"}}],},)

I need to programmatically remove labels from hundreds of tickets, so doing it manually isn’t really an option. The web interface bulk editor isn’t working properly for me either.

Here’s a simplified version of what I’m trying to accomplish:

#!/usr/bin/env python3

import os
from jira import JIRA

API_TOKEN_VAR = 'JIRA_TOKEN'
SERVER_URL = 'https://company.atlassian.net'
SEARCH_QUERY = 'labels in (DEPRECATEDTAG) and labels not in (NEWTAG)'

def process_tickets():
    token = os.environ[API_TOKEN_VAR]
    jira_client = JIRA(SERVER_URL, token_auth=token)
    tickets = jira_client.search_issues(SEARCH_QUERY)
    
    counter = 1
    for ticket in tickets:
        print(f'Processing {counter} - {ticket.key}')
        print(f'Current labels: {ticket.fields.labels}')
        
        # This works - adding new label
        ticket.fields.labels.append('NEWTAG')
        
        # This doesn't work - removing old label
        # ticket.update(update={"labels": [{"remove": {"name": "DEPRECATEDTAG"}}],},)
        
        # Apply changes
        ticket.update(fields={"labels": ticket.fields.labels})
        counter += 1

if __name__ == '__main__':
    process_tickets()

What’s the correct way to remove labels from Jira issues using the Python API?

try removing the label before updating:

labels_list = [label for label in ticket.fields.labels if label != 'DEPRECATEDTAG']
ticket.update(fields={"labels": labels_list})

this way, you filter out the unwanted label then update the whole list. its way better than those update ops.

Your syntax should work, but labels are handled differently than components. You don’t need the {“name”: …} wrapper - labels are just strings in update operations.

Try this: ticket.update(update={“labels”: [{“remove”: “DEPRECATEDTAG”}]})

Components use objects with name properties, but labels don’t. If that doesn’t work, you can manipulate the labels list directly:

current_labels = [str(label) for label in ticket.fields.labels]
if ‘DEPRECATEDTAG’ in current_labels:
current_labels.remove(‘DEPRECATEDTAG’)
ticket.update(fields={“labels”: current_labels})

I’ve used this second method for bulk label operations. The key is converting label objects to strings first since Jira sometimes returns objects instead of plain strings.

This is a super common Jira issue. I’ve dealt with it tons of times and found the best approach is just working with labels as a complete set instead of trying to use update operations. Here’s what always works for me:

# Get current labels and convert to strings
current_labels = [str(label) for label in ticket.fields.labels]

# Remove the deprecated label
if 'DEPRECATEDTAG' in current_labels:
    current_labels.remove('DEPRECATEDTAG')

# Add new label if not already present
if 'NEWTAG' not in current_labels:
    current_labels.append('NEWTAG')

# Update the ticket with the modified label list
ticket.update(fields={"labels": current_labels})

This skips all the headaches with Jira’s update operations and gives you complete control. I’ve processed thousands of tickets this way with zero issues. Just treat labels like a simple string list instead of wrestling with the complex update syntax that other fields use.