Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Jira createmeta: issue types and fields for create
Two paged endpoints cover create metadata: one lists the issue types of a project, the other lists the fields of one issue type. Use them to build a valid create body without guessing which fields are required.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes | Returns a page of issue types for a project. |
GET | /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId} | Returns a page of fields for a project and issue type. |
GET | /rest/api/3/issuetype/project | Returns the issue types of a project by id. |
Examples
GET /rest/api/3/issue/createmeta/WEB/issuetypes
List the issue types of project WEB. The page object has startAt, maxResults and total, and the types live under issueTypes.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/WEB/issuetypes'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/WEB/issuetypes',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"startAt": 0,
"maxResults": 50,
"total": 6,
"issueTypes": [
{
"id": "10079",
"name": "Epic",
"subtask": false,
"hierarchyLevel": 1
},
{
"id": "10080",
"name": "Subtask",
"subtask": true,
"hierarchyLevel": -1
},
{
"id": "10081",
"name": "Task",
"subtask": false,
"hierarchyLevel": 0
}
]
}Response headers
X-Ratelimit-Limit: 350
X-Ratelimit-Remaining: 348Sent to Atlassian Cloud on .
GET /rest/api/3/issue/createmeta/WEB/issuetypes/{issueTypeId}
List the fields of one issue type, five at a time. Each field has required, schema, operations and a fieldId.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'maxResults=5' \
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/WEB/issuetypes/{issueTypeId}'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/WEB/issuetypes/{issueTypeId}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'maxResults': '5'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"startAt": 0,
"maxResults": 5,
"total": 18,
"fields": [
{
"fieldId": "assignee",
"name": "Assignee",
"required": false,
"operations": [
"set"
]
},
{
"fieldId": "attachment",
"name": "Attachment",
"required": false,
"operations": [
"set",
"copy"
]
},
{
"fieldId": "customfield_10000",
"name": "Development",
"required": false,
"operations": [
"set"
]
}
]
}Sent to Atlassian Cloud on .
GET /rest/api/3/issuetype/project
The project-scoped issue type list from the general issue type endpoint, keyed by projectId.
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": "10079",
"name": "Epic",
"subtask": false,
"scope": {
"type": "PROJECT",
"project": {
"id": "10066"
}
}
},
{
"id": "10080",
"name": "Subtask",
"subtask": true,
"scope": {
"type": "PROJECT",
"project": {
"id": "10066"
}
}
}
]Sent to Atlassian Cloud on .
POST /rest/api/3/issue
An issue type name that is not in the list is rejected at create time.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"project": {
"key": "WEB"
},
"issuetype": {
"name": "NoSuchType"
},
"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': 'WEB'},
'issuetype': {'name': 'NoSuchType'},
'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 issue type list for WEB reported total 6 and included Epic, Subtask and Task; subtask: true marks the sub-task type.
- The fields call is paged: maxResults was honoured at 5 while total was 18, so a full field list needs more than one request.
- Each field entry carries a fieldId and an operations array; hasDefaultValue was true for assignee.
- Fields such as assignee carry an autoCompleteUrl pointing at the matching search endpoint.
Pitfalls
- Page through the fields endpoint. Reading only the first page can hide a required field.
- Issue type ids are per site. Do not reuse ids copied from another Jira site.
- The createmeta paths take a project key or id in the path, while the general issue type call takes projectId as a query parameter.
- A required: false field can still be rejected on create if its value is invalid, so validate values as well as presence.
Questions and answers
Which call lists required fields?
The fields endpoint for a project and issue type. Each entry has a required flag.
Is there a way to get everything in one call?
The spec still lists GET /rest/api/3/issue/createmeta. It was not tried, so the two paged endpoints are the ones documented above.
Related
- Create a work item
- Create work item errors
- editmeta
- startAt and maxResults
- Fields, work types, priorities, statuses
- Bulk create work items