Jira Cloud fields and work types
List Jira work types via API: issuetype and project filter
GET /rest/api/3/issuetype returns all work types visible to the caller as a bare array, and GET /rest/api/3/issuetype/project with a projectId returns only those of one project. The API path and field names still say issuetype and issue; the UI calls the same objects work types.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/issuetype | Lists all work types the caller can see. |
GET | /rest/api/3/issuetype/project | Lists the work types of one project, with an optional hierarchy level. |
Examples
GET /rest/api/3/issuetype
Lists all work types on the site, cut to the first eight. Sub-task and Subtask are separate entries, and entries with scope belong to one project.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issuetype'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issuetype',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
[
{
"id": "10118",
"name": "Sub-task",
"subtask": true,
"hierarchyLevel": -1
},
{
"id": "10002",
"name": "Subtask",
"subtask": true,
"hierarchyLevel": -1,
"scope": {
"type": "PROJECT",
"project": {
"id": "10000"
}
}
},
{
"id": "10080",
"name": "Subtask",
"subtask": true,
"hierarchyLevel": -1,
"scope": {
"type": "PROJECT",
"project": {
"id": "10066"
}
}
},
{
"id": "10042",
"name": "Subtask",
"subtask": true,
"hierarchyLevel": -1,
"scope": {
"type": "PROJECT",
"project": {
"id": "10033"
}
}
},
{
"id": "10006",
"name": "Request",
"subtask": false,
"hierarchyLevel": 0,
"scope": {
"type": "PROJECT",
"project": {
"id": "10000"
}
}
},
{
"id": "10007",
"name": "Bug",
"subtask": false,
"hierarchyLevel": 0,
"scope": {
"type": "PROJECT",
"project": {
"id": "10000"
}
}
},
{
"id": "10008",
"name": "Story",
"subtask": false,
"hierarchyLevel": 0
},
{
"id": "10119",
"name": "Bug",
"subtask": false,
"hierarchyLevel": 0
}
]Response headers
X-Ratelimit-Limit: 350
X-Ratelimit-Remaining: 349Sent to Atlassian Cloud on .
GET /rest/api/3/issuetype/project
The same list filtered by the id of the test project. Only Task and the sub-task type come back.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'projectId={projectId}' \
'https://your-domain.atlassian.net/rest/api/3/issuetype/project'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issuetype/project',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'projectId': '{projectId}'},
)
print(r.status_code, r.text)Response: HTTP 200
[
{
"id": "10117",
"name": "Task",
"untranslatedName": "Task",
"subtask": false,
"hierarchyLevel": 0
},
{
"id": "10118",
"name": "Sub-task",
"untranslatedName": "Sub-task",
"subtask": true,
"hierarchyLevel": -1
}
]Sent to Atlassian Cloud on .
GET /rest/api/3/issue/createmeta/ZZREF/issuetypes
Create metadata gives the same two work types for the project, which are the ones that can be used on create.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/ZZREF/issuetypes'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/ZZREF/issuetypes',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"total": 2,
"issueTypes": [
{
"id": "10117",
"name": "Task",
"subtask": false
},
{
"id": "10118",
"name": "Sub-task",
"subtask": true
}
]
}Sent to Atlassian Cloud on .
POST /rest/api/3/issue
Creating with a work type name that exists on the site but not in the project fails with 400.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"project": {
"key": "ZZREF"
},
"issuetype": {
"name": "Bug"
},
"summary": "x"
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/issue',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'fields': {'project': {'key': 'ZZREF'}, 'issuetype': {'name': 'Bug'}, 'summary': 'x'}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"issuetype": "Specify a valid issue type"
}
}Sent to Atlassian Cloud on .
How it behaves
- The site-wide list had 24 entries and 19 of them carried a scope with a project id. Names repeat: Task, Bug, Story and Epic each appear four times, Feature and Subtask three times, and the shared sub-task type is spelled Sub-task.
- hierarchyLevel was -1 for sub-task types, 0 for base types such as Task, Bug and Story, and 1 for Epic; subtask is true only at -1.
- The project filter answered with Task (10117, hierarchyLevel 0) and Sub-task (10118, subtask true, hierarchyLevel -1), each with id, description, iconUrl, name, untranslatedName and avatarId.
Pitfalls
- Do not look a work type up by name alone. Four different Task entries exist on the site, so use the id from the project filter.
- Only the project filter says what the project can create; the site list includes work types of other projects.
- The level parameter of the project endpoint accepts -1 (sub-task), 0 (base) and 1 (epic), per the spec.
- The caller only sees work types of projects it may browse unless it has Administer Jira.
Questions and answers
Why are there several work types called Task?
A project can have its own work types, shown by a scope with the project id, so the same name occurs once per such project plus the shared one.
Which work types can I create in a project?
Call GET /rest/api/3/issuetype/project with the projectId, or the create metadata for the project.
Related
- Work type schemes
- Work type by id or by name
- Sub-task work types
- issuetype
- Team-managed vs company-managed projects
- Change the work type