Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Jira work item watchers with the REST API

GET lists the watchers and the count. POST adds a watcher and expects the accountId as a bare JSON string, not an object; DELETE removes one and needs accountId in the query string. Both writes answer 204.

Endpoints

MethodPathWhat it does
GET/rest/api/3/issue/{issueIdOrKey}/watchersReturns the watchers of a work item.
POST/rest/api/3/issue/{issueIdOrKey}/watchersAdds a user as a watcher; no user adds the caller.
DELETE/rest/api/3/issue/{issueIdOrKey}/watchersRemoves a watcher identified by accountId.

Examples

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

Read the watcher list. isWatching tells the caller's own state and watchCount the size.

curl

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

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "self": "https://your-domain.atlassian.net/rest/api/3/issue/WEB-55/watchers",
 "isWatching": true,
 "watchCount": 1,
 "watchers": [
  {
   "accountId": "<accountId>",
   "displayName": "<display name>",
   "active": true
  }
 ]
}

Response headers

X-Ratelimit-Limit: 350
X-Ratelimit-Remaining: 348

Sent to Atlassian Cloud on .

POST /rest/api/3/issue/{issueIdOrKey}/watchers

Add a watcher with the accountId as a JSON string body.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '<accountId>' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/watchers'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/watchers',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json', 'Content-Type': 'application/json'},
    data='<accountId>',
)
print(r.status_code, r.text)

Response: HTTP 204

No response body.

Sent to Atlassian Cloud on .

DELETE /rest/api/3/issue/{issueIdOrKey}/watchers

Remove a watcher with accountId in the query string.

curl

curl -X DELETE \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/watchers?accountId=<accountId>'

Python (requests)

import os
import requests

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

Response: HTTP 204

No response body.

Sent to Atlassian Cloud on .

How it behaves

  • GET answers an object with self, isWatching, watchCount and a watchers array of user objects.
  • The add request body was the account id as a bare JSON string and answered 204.
  • Removing needs accountId as a query parameter and answered 204; the spec says 400 when it is missing.
  • The work item read also carries a watches summary (watchCount, isWatching) without the user list.

Pitfalls

  • Do not wrap the account id in an object for POST. The documented body is the string itself.
  • Seeing other users on the list needs the View voters and watchers permission; without it only your own entry is visible.
  • Watching can be switched off for the site. The spec states these operations need Allow users to watch issues to be on.
  • Adding someone else as a watcher needs Manage watcher list permission.

Questions and answers

How do I watch a work item as myself?

POST with your own accountId as the body, or send no user to add the caller, as the spec describes.

Why is the delete a query parameter?

The spec defines accountId as a query parameter on DELETE and marks it required.

Sources

  1. The Jira Cloud platform REST API v3 (Atlassian Developer)
  2. Get issue watchers (Jira REST API v3)
  3. Add watcher (Jira REST API v3)
  4. Delete watcher (Jira REST API v3)

Markdown version · All REST API pages