Jira Cloud fields and work types
Jira work type schemes via API: scheme, project, mapping
In a company-managed project the work types come from an issue type scheme. GET /rest/api/3/issuetypescheme/project names the scheme of a project and its default work type, and /issuetypescheme/mapping lists the work types in it. Creating with a work type that is not in the scheme fails.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/issuetypescheme/project | Returns the scheme of each project with the projects that use it. |
GET | /rest/api/3/issuetypescheme/mapping | Lists the work types in one or more schemes. |
PUT | /rest/api/3/issuetypescheme/project | Assigns a scheme to a project. |
GET | /rest/api/3/issuetype/{id}/alternatives | Lists work types that could replace one. |
Examples
GET /rest/api/3/issuetypescheme/project
Looks up the scheme for a project id. The answer holds the scheme, its default work type and the projects that use it.
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/issuetypescheme/project'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issuetypescheme/project',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'projectId': '{projectId}'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"maxResults": 50,
"startAt": 0,
"total": 1,
"isLast": true,
"values": [
{
"issueTypeScheme": {
"id": "10311",
"name": "ZZREF: Task Management Issue Type Scheme",
"description": "",
"defaultIssueTypeId": "10117"
},
"projectIds": [
"10100"
]
}
]
}Response headers
X-Ratelimit-Limit: 350Sent to Atlassian Cloud on .
GET /rest/api/3/issuetypescheme/mapping
Lists the items of that scheme. Two work types are in it, the ids of Task and Sub-task.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'issueTypeSchemeId={issueTypeSchemeId}' \
'https://your-domain.atlassian.net/rest/api/3/issuetypescheme/mapping'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issuetypescheme/mapping',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'issueTypeSchemeId': '{issueTypeSchemeId}'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"maxResults": 50,
"startAt": 0,
"total": 2,
"isLast": true,
"values": [
{
"issueTypeSchemeId": "10311",
"issueTypeId": "10117"
},
{
"issueTypeSchemeId": "10311",
"issueTypeId": "10118"
}
]
}Sent to Atlassian Cloud on .
GET /rest/api/3/issuetype/project
The project's work type list matches the scheme items.
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"
},
{
"id": "10118",
"name": "Sub-task"
}
]Sent to Atlassian Cloud on .
POST /rest/api/3/issue
Bug exists on the site but is not in the scheme. A create with it fails with a message keyed on issuetype.
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 .
GET /rest/api/3/issuetype/{issueTypeId}/alternatives
Asks which work types could replace Task. The list is empty.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issuetype/{issueTypeId}/alternatives'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issuetype/{issueTypeId}/alternatives',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
[]Sent to Atlassian Cloud on .
How it behaves
- The scheme for the project had id 10311, defaultIssueTypeId 10117 (Task) and projectIds ['10100'].
- The mapping returned total 2: issueTypeId 10117 and 10118, the same ids as the project's work type list.
- Creating a work item with the work type name Bug in that project answered 400 with errors.issuetype = 'Specify a valid issue type'.
- The alternatives list for Task was an empty array; the spec defines alternatives as types assigned to the same workflow scheme, field configuration scheme and screen scheme.
Pitfalls
- The scheme endpoints return only schemes used in company-managed (classic) projects, per the spec; a team-managed project has no such scheme to read.
- Assigning a scheme fails while the project still has work items of a type that the new scheme lacks (spec text), so move those items first.
- A scheme needs Administer Jira to read, unlike the work type list.
Questions and answers
How do I find which work types a project allows?
Read the scheme with GET /rest/api/3/issuetypescheme/project, then its items with /issuetypescheme/mapping, or call the issuetype/project endpoint.
Can I use a work type that is not in the scheme?
Not in that project. The create call with Bug failed with 'Specify a valid issue type'.
Related
- List work types
- Team-managed vs company-managed projects
- Change the work type
- Work type by id or by name
- Field configurations
- issuetype