Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Jira update operations: add, remove and set
The update object lets an edit touch part of a multi-value field: labels accept add, remove and set, and comments accept add, edit and remove. Which operations a field supports is listed per field in editmeta. A field cannot appear in both fields and update in one request.
Endpoints
| Method | Path | What it does |
|---|---|---|
PUT | /rest/api/3/issue/{issueIdOrKey} | Edits a work item; update carries per-field operations. |
GET | /rest/api/3/issue/{issueIdOrKey}/editmeta | Lists the operations each editable field supports. |
Examples
PUT /rest/api/3/issue/{issueIdOrKey}
Replace the whole label list through fields. Labels become alpha and beta.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"labels": [
"alpha",
"beta"
]
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=summary,labels'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=summary,labels',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'summary,labels'},
json={'fields': {'labels': ['alpha', 'beta']}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id": "10766",
"self": "https://your-domain.atlassian.net/rest/api/3/issue/10766",
"key": "WEB-55",
"fields": {
"labels": [
"alpha",
"beta"
]
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Add gamma and remove alpha in one call with update. The existing beta label is untouched.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"update": {
"labels": [
{
"add": "gamma"
},
{
"remove": "alpha"
}
]
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=labels'Python (requests)
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={'update': {'labels': [{'add': 'gamma'}, {'remove': 'alpha'}]}},
)
print(r.status_code, r.text)Response: HTTP 200
{
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id": "10766",
"self": "https://your-domain.atlassian.net/rest/api/3/issue/10766",
"key": "WEB-55",
"fields": {
"labels": [
"beta",
"gamma"
]
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Putting labels in both fields and update is refused.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"labels": [
"x"
]
},
"update": {
"labels": [
{
"add": "y"
}
]
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fields': {'labels': ['x']}, 'update': {'labels': [{'add': 'y'}]}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [
"Field 'labels' cannot appear in both 'fields' and 'update'"
],
"errors": {}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
An id that is not an editable field is refused under errors.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_99999": "x"
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fields': {'customfield_99999': 'x'}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_99999": "Field 'customfield_99999' cannot be set. It is not on the appropriate screen, or unknown."
}
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
The operations array of each field tells you which update verbs are valid. Labels allow add, set and remove; comment allows add, edit and remove.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'Python (requests)
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": {
"summary": {
"operations": [
"set"
]
},
"labels": {
"name": "Labels",
"operations": [
"add",
"set",
"remove"
]
},
"comment": {
"name": "Comment",
"operations": [
"add",
"edit",
"remove"
]
},
"issuelinks": {
"name": "Linked Issues",
"operations": [
"add",
"copy"
]
}
}
}Sent to Atlassian Cloud on .
How it behaves
- update.labels with [{"add": "gamma"}, {"remove": "alpha"}] changed alpha, beta into beta, gamma; labels not named were left alone.
- fields.labels with a full array replaced the whole list, which is the set behaviour.
- Sending the same field in fields and update gave 400 with the message "Field 'labels' cannot appear in both 'fields' and 'update'".
- editmeta reports summary as set only, labels as add, set and remove, comment as add, edit and remove, and issuelinks as add and copy.
Pitfalls
- Use set (or fields) only when you mean to replace the list. A labels array in fields drops every label you left out.
- Each entry in an update array is one operation. Put add and remove in the same array, not as two keys of one object.
- Operations are per field. Asking for remove on summary fails because editmeta lists only set for it.
- Several concurrent edits of the same work item can conflict; the spec lists 409 for a conflicting update.
Questions and answers
How do I add one label without losing the others?
Use update with an add operation: {"update": {"labels": [{"add": "gamma"}]}}. The run above shows the pattern with a matching remove.
Where do I see which operations a field supports?
In the editmeta response, under each field's operations array.