# Jira labels field: set, add and remove through the API

URL: https://goingstellar.ro/reference/jira-fields/labels-field/

labels is an array of strings with the operations add, set and remove. Replacing the whole list uses fields.labels, and adding or removing single labels uses the update section. Labels cannot contain spaces.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| PUT | `/rest/api/3/issue/{issueIdOrKey}` | Sets fields.labels or changes it with update.labels add and remove. |
| GET | `/rest/api/3/issue/{issueIdOrKey}` | Returns labels as an array of strings. |
| GET | `/rest/api/3/issue/{issueIdOrKey}/editmeta` | Lists the operations add, set and remove for labels. |

## Examples

### PUT /rest/api/3/issue/{issueIdOrKey}

Replaces the labels of a work item with two values.

```bash
curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "labels": [
      "api",
      "fields"
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'labels'},
    json={'fields': {'labels': ['api', 'fields']}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "key": "ZZREF-6",
 "fields": {
  "labels": [
   "api",
   "fields"
  ]
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /rest/api/3/issue/{issueIdOrKey}/editmeta

The edit metadata lists the three operations and a string array schema.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "fields": {
  "labels": {
   "required": false,
   "schema": {
    "type": "array",
    "items": "string",
    "system": "labels"
   },
   "name": "Labels",
   "operations": [
    "add",
    "set",
    "remove"
   ]
  }
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### PUT /rest/api/3/issue/{issueIdOrKey}

Adds one label and removes another with the update section. This call targets the labels custom field, which lists the same operations as the system field.

```bash
curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "update": {
    "customfield_10177": [
      {
        "add": "gamma"
      },
      {
        "remove": "alpha"
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10177'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10177',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10177'},
    json={'update': {'customfield_10177': [{'add': 'gamma'}, {'remove': 'alpha'}]}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10177": [
   "beta",
   "gamma"
  ]
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### PUT /rest/api/3/issue/{issueIdOrKey}

Sends a label that contains a space.

```bash
curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "labels": [
      "has space"
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'labels'},
    json={'fields': {'labels': ['has space']}},
)
print(r.status_code, r.text)
```

Response: HTTP 400

```
{
 "errorMessages": [],
 "errors": {
  "labels": "The label 'has space' can't contain spaces."
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### PUT /rest/api/3/issue/{issueIdOrKey}

Replaces the labels with an empty array.

```bash
curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "labels": []
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'labels'},
    json={'fields': {'labels': []}},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "key": "ZZREF-11",
 "fields": {
  "labels": []
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /rest/api/3/issue/{issueIdOrKey}

Reads labels back with other system fields.

```bash
curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=priority,duedate,labels,components,fixVersions,environment,timetracking,reporter,status,resolution,issuetype,project,created,updated' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'fields': 'priority,duedate,labels,components,fixVersions,environment,timetracking,reporter,status,resolution,issuetype,project,created,updated'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "key": "ZZREF-6",
 "fields": {
  "labels": [
   "api",
   "fields"
  ]
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- fields.labels with ["api", "fields"] answered 200 and the same array came back (sys-labels).
- The edit metadata for labels reports the operations add, set and remove (editmeta-zz).
- On the labels custom field, update with add gamma and remove alpha turned [alpha, beta] into [beta, gamma] (set-labels, set-update-labels-cf).
- A label with a space answered 400 with The label 'has space' can't contain spaces (sys-labels-space).
- An empty array answered 200 and the field read back as [] (sys-labels-empty).

## Pitfalls

- fields.labels is the set operation and writes the array you send. Use update add and remove when other tools also write labels and one label must change.
- Split a phrase into separate labels or join it with a hyphen before sending, since spaces are refused.
- The update add and remove run used the custom labels field. Confirm it on the system field before relying on it.

## Questions and answers

### How do I add a label without losing the existing ones?

Send update.labels with an add entry. The edit metadata lists add as an operation, and the labels custom field accepted it in the run.

## Related

- [Labels (custom)](https://goingstellar.ro/reference/jira-fields/labels-custom-field/)
- [components](https://goingstellar.ro/reference/jira-fields/components-field/)
- [fixVersions](https://goingstellar.ro/reference/jira-fields/fixversions-field/)
- [Which fields can be set: editmeta and createmeta](https://goingstellar.ro/reference/jira-fields/editmeta-createmeta-fields/)
- [Reading field values: names, schema, v2 and v3](https://goingstellar.ro/reference/jira-fields/reading-field-values/)

## Sources

- [Issues (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/)
- [Edit issue (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put)
- [Get edit issue metadata (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-editmeta-get)

