# Count Jira work items matching a JQL query with the REST API

URL: https://goingstellar.ro/reference/atlassian-rest-api/approximate-count/

The enhanced JQL search no longer reports how many work items match. POST /rest/api/3/search/approximate-count takes the same jql and returns {"count": n}. The number is an estimate, and the query has to be bounded.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| POST | `/rest/api/3/search/approximate-count` | Returns an estimated number of matching work items. |
| POST | `/rest/api/3/search/jql` | Searches without returning a total. |

## Examples

### POST /rest/api/3/search/approximate-count

Counts the work items of one project.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = WEB"
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/approximate-count'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/search/approximate-count',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'jql': 'project = WEB'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "count": 34
}
```

Response headers:

```
X-Ratelimit-Limit: 300
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /rest/api/3/search/jql

A normal search page for contrast. It holds no total, only a token and a flag.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = WEB AND summary ~ \"REST API reference test\" ORDER BY created ASC",
  "fields": [
    "summary",
    "status"
  ],
  "maxResults": 1
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/search/jql',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'jql': 'project = WEB AND summary ~ "REST API reference test" ORDER BY created ASC',
          'fields': ['summary', 'status'],
          'maxResults': 1},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "issues": [
  {
   "key": "WEB-55"
  }
 ],
 "nextPageToken": "CkhjcmVhdGVkJmNyZWF0ZWQmT1JERVJfQVNDI0xvbmcmTVRjNU5UazNNek0xTlRZNU9BPT0lU3RyaW5nJlYwVkMlSW50Jk5UVT0QARiRle_CojQiSnByb2plY3QgPSBXRUIgQU5EIHN1bW1hcnkgfiAiUkVTVCBBUEkgcmVmZXJlbmNlIHRlc3QiIE9SREVSIEJZIGNyZWF0ZWQgQVNDKgJbXQ==",
 "isLast": false
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### POST /rest/api/3/search/jql

The bounded-query rule shown on the search endpoint. The spec states the count endpoint needs bounded JQL as well.

```bash
curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "order by created DESC",
  "maxResults": 1,
  "fields": [
    "summary"
  ]
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/search/jql',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'jql': 'order by created DESC', 'maxResults': 1, 'fields': ['summary']},
)
print(r.status_code, r.text)
```

Response: HTTP 400

```
{
 "errorMessages": [
  "Unbounded JQL queries are not allowed here. Please add a search restriction to your query."
 ],
 "errors": {}
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- A count request with jql set to project = WEB answered 200 with {"count": 34}.
- The search response from /search/jql has no total key, so a count means a separate call.
- The spec describes the result as an estimate and warns that recent updates might not be visible yet.

## Pitfalls

- Do not use the count to size a loop or to stop paging. Page until isLast is true.
- An estimate right after creating or deleting work items can lag. Do not assert exact equality in tests.
- The count is the number of matching work items for the caller, limited to what the caller may browse.

## Questions and answers

### Is the count exact?

No. The spec calls it an estimate and says recent updates might not be visible.

## Related

- [Search with JQL](https://goingstellar.ro/reference/atlassian-rest-api/search-jql/)
- [Parse and validate JQL](https://goingstellar.ro/reference/atlassian-rest-api/jql-parse/)
- [nextPageToken in Jira search](https://goingstellar.ro/reference/atlassian-rest-api/pagination-nextpagetoken/)
- [The removed /search endpoint](https://goingstellar.ro/reference/atlassian-rest-api/removed-search-endpoint/)

## Sources

- [The Jira Cloud platform REST API v3 (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/)
- [Count issues using JQL (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-approximate-count-post)

