Jira Cloud fields and work types
Jira editmeta and createmeta: which fields can be set
Before writing a field, ask Jira what the work item accepts. GET /rest/api/3/issue/{key}/editmeta returns an object of editable fields; GET /rest/api/3/issue/createmeta/{project}/issuetypes/{id} returns a paged list for creating. Both show required, operations, allowedValues and the schema that tells the value shape.
Endpoints
| Method | Path | What it does |
|---|---|---|
GET | /rest/api/3/issue/{issueIdOrKey}/editmeta | Lists the fields the caller can edit on one work item. |
GET | /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes | Lists the work types available for creation in a project. |
GET | /rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId} | Lists the fields for creating a work item of one work type. |
Examples
GET /rest/api/3/issue/{issueIdOrKey}/editmeta
Edit metadata of one work item, cut to three fields. A select list shows its allowedValues, a multiple select lists the operations add, set and remove, and a user picker carries an autoCompleteUrl.
curl
curl \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.get(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/editmeta',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"fields": {
"summary": {
"required": true,
"name": "Summary",
"operations": [
"set"
]
},
"customfield_10164": {
"name": "zz-ref select",
"schema": {
"type": "option",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
"customId": 10164
},
"operations": [
"set"
],
"allowedValues": [
{
"value": "Red",
"id": "10036"
},
{
"value": "Green",
"id": "10037"
},
{
"value": "Blue",
"id": "10038"
}
]
},
"customfield_10165": {
"name": "zz-ref multiselect",
"operations": [
"add",
"set",
"remove"
]
},
"customfield_10173": {
"name": "zz-ref user",
"operations": [
"set"
],
"autoCompleteUrl": "https://your-domain.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10173&fieldConfigId=10356&projectId=10100&showAvatar=true&query="
}
}
}Response headers
X-Ratelimit-Limit: 350
X-Ratelimit-Remaining: 349Sent to Atlassian Cloud on .
GET /rest/api/3/issue/createmeta/ZZREF/issuetypes
Lists the work types a project can create. Task and Sub-task are the two choices, and subtask tells them apart.
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,
"hierarchyLevel": 0
},
{
"id": "10118",
"name": "Sub-task",
"subtask": true,
"hierarchyLevel": -1
}
]
}Sent to Atlassian Cloud on .
GET /rest/api/3/issue/createmeta/ZZREF/issuetypes/{issueTypeId}
Create metadata for the Task work type. Each field has a fieldId, required and operations. The list was cut to the first three entries; paging fields startAt, maxResults and total come with it.
curl
curl -G \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
--data-urlencode 'maxResults=60' \
'https://your-domain.atlassian.net/rest/api/3/issue/createmeta/ZZREF/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/ZZREF/issuetypes/{issueTypeId}',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'maxResults': '60'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"startAt": 0,
"maxResults": 60,
"total": 33,
"fields": [
{
"fieldId": "assignee",
"name": "Assignee",
"required": false,
"operations": [
"set"
],
"hasDefaultValue": false
},
{
"fieldId": "attachment",
"name": "Attachment",
"required": false,
"operations": [
"set",
"copy"
],
"hasDefaultValue": false
},
{
"fieldId": "customfield_10001",
"name": "Team",
"required": false,
"operations": [
"set"
],
"hasDefaultValue": false
}
]
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Writes a value that is not among the allowed values. The error is keyed on the field and says to specify a valid value.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10164": {
"value": "Purple"
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10164'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10164',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10164'},
json={'fields': {'customfield_10164': {'value': 'Purple'}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_10164": "Specify a valid value for zz-ref select"
}
}Sent to Atlassian Cloud on .
PUT /rest/api/3/issue/{issueIdOrKey}
Writes a child that does not belong to the chosen parent. The cascading field reports a bad child option.
curl
curl -X PUT \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10168": {
"value": "Asia",
"child": {
"value": "Romania"
}
}
}
}' \
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10168'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.put(
'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10168',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
params={'returnIssue': 'true', 'fields': 'customfield_10168'},
json={'fields': {'customfield_10168': {'value': 'Asia', 'child': {'value': 'Romania'}}}},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [],
"errors": {
"customfield_10168": "Specify a valid child option 'name' for zz-ref cascading"
}
}Sent to Atlassian Cloud on .
How it behaves
- editmeta listed 35 fields keyed by id and createmeta listed 33 as an array with a fieldId on each entry, requested with maxResults 60 so that one page held everything.
- operations tells how a value may be written: ['set'] for scalar fields, ['add', 'set', 'remove'] for labels and multiple choice fields, ['set', 'copy'] for attachment, and an empty list for issuetype.
- Only createmeta listed project (required true); only editmeta listed comment, environment and the Flagged field. summary and issuetype were required in both. reporter was in neither, although it is on the screen tab.
- A field with allowedValues lists each option with self, value and id; a cascading field nests its children under each parent in children.
Pitfalls
- The all-in-one GET /rest/api/3/issue/createmeta is deprecated in the spec; use the per-project, per-work-type form, which is paged.
- editmeta only reports what the caller may edit, so a missing field can mean a permission, a screen or a context problem; the spec lists nine conditions.
- allowedValues are values for the write, but the shape of the write body comes from schema and the field page for that type, not from the metadata alone.
- createmeta needs the Create issues permission in the project.
Questions and answers
How do I know the JSON shape to send for a custom field?
Read schema.custom and schema.type in the metadata and then see the page for that field type; the metadata gives the options, not the body.
Why is a field I created missing from editmeta?
It must be on a screen and have a valid context for the project and work type, among other conditions the spec lists. Compare with the screen tab listing and the contexts.
Related
- Fields on screens
- Field configurations
- Default values
- Reading field values: names, schema, v2 and v3
- Custom field contexts
- List work types