Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

JQL on Jira custom fields: cf[id], names and operators

JQL reaches a custom field in three spellings: cf[10162], the quoted field name, and customfield_10171. POST /rest/api/3/search/jql evaluates it and pages with nextPageToken. The operators come from the field's searcher, and a name that does not exist is not an error.

Endpoints

MethodPathWhat it does
POST/rest/api/3/search/jqlRuns a JQL query with fields, maxResults and nextPageToken paging.
GET/rest/api/3/fieldShows clauseNames, the spellings JQL accepts for each field.

Examples

POST /rest/api/3/search/jql

Finds work items by the number form cf[10162] with the contains operator on a single-line text field.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND cf[10162] ~ \"Checkout\"",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND cf[10162] ~ "Checkout"',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-6",
   "fields": {
    "summary": "Fields reference test issue"
   }
  }
 ],
 "isLast": true
}

Response headers

X-Ratelimit-Limit: 200
X-Ratelimit-Remaining: 199

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

The same query with the quoted field name instead of the number. The same work item comes back.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref text\" ~ \"Checkout\"",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref text" ~ "Checkout"',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-6",
   "fields": {
    "summary": "Fields reference test issue"
   }
  }
 ],
 "isLast": true
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

The cascadeOption function with a parent and a child. It matched no work items; the last cascading write in the project had stored only the parent, Europe.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref cascading\" in cascadeOption(Europe, Romania)",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref cascading" in cascadeOption(Europe, Romania)',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [],
 "isLast": true
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

The same function after a work item was given both Europe and Romania. It finds that work item.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref cascading\" in cascadeOption(Europe, Romania)",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref cascading" in cascadeOption(Europe, Romania)',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-11"
  }
 ],
 "isLast": true
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

The one-argument form with only the parent. It finds the same work item.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref cascading\" in cascadeOption(Europe)",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref cascading" in cascadeOption(Europe)',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-11"
  }
 ],
 "isLast": true
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

Compares the custom labels field with a value, the form used for the other types. It matched no work items in that run.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref labels\" = beta",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref labels" = beta',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [],
 "isLast": true
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

Quotes a field name that does not exist. Jira answers 200 with an empty list, not a 400.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref nosuch\" = x",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

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 = ZZREF AND "zz-ref nosuch" = x', 'fields': ['summary'], 'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [],
 "isLast": true
}

Sent to Atlassian Cloud on .

How it behaves

  • The field list gives each custom field three clauseNames. For the select list field they are 'zz-ref select[Dropdown]', 'zz-ref select' and 'cf[10164]'; a field also accepts customfield_10171 style ids.
  • Text and paragraph fields answered to ~, option fields to = with the option text or its id and to in (Frontend, Docs) for checkboxes, number and date fields to comparisons, URL to = with the exact string, user to = currentUser(), group to = with the group name, version to = with the version name, project to = with the key, and is EMPTY worked as well. Each of those matched the expected work item.
  • cascadeOption(Europe, Romania) matched only after both levels were stored, and cascadeOption(Europe) matched that work item too.
  • = beta on the custom labels field matched nothing, unlike the other types.
  • An unknown field name answers 200 with issues [] and isLast true. A query that matches more than maxResults answers with nextPageToken and isLast false.

Where the documentation differs

  • POST /rest/api/3/search/jql

    Sent to Atlassian Cloud, . The documentation: The OpenAPI response list says 400 is 'Returned if the search request is invalid'.

    What happened: A JQL query that names a field that does not exist still gave 200 with an empty issues array and no message.

Pitfalls

  • A mistyped field name looks like a query with no matches. Check the name against clauseNames before trusting an empty result.
  • Names need not be unique, and a renamed field no longer answers to its old name; cf[id] is the stable form.
  • A labels clause matched nothing in the run, so test a labels query against a value you can see before building on it.
  • Recent edits might not show up at once; the spec describes reconcileIssues for read-after-write consistency.

Questions and answers

Should I use the field name or cf[id] in JQL?

Both worked in the runs. cf[id] does not change on rename and does not clash with another field of the same name.

Can I search a custom field that is not searchable?

A field created without a searcher is not searchable, per the spec. Check searcherKey in the field search.

Sources

  1. Issue search (Jira REST API v3)
  2. Issue fields (Jira REST API v3)

Markdown version · All Jira fields pages