Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira select and cascading field options via the API

Options live under a context: /rest/api/3/field/{fieldId}/context/{contextId}/option. GET lists them, POST adds, PUT renames or disables, and DELETE removes one by id. Cascading fields use the same endpoint, with child options marked by an optionId that points to the parent.

Endpoints

MethodPathWhat it does
GET/rest/api/3/field/{fieldId}/context/{contextId}/optionLists options, parents first and then cascading children.
POST/rest/api/3/field/{fieldId}/context/{contextId}/optionCreates options, and cascading children when optionId is given.
PUT/rest/api/3/field/{fieldId}/context/{contextId}/optionUpdates the value or the disabled flag of existing options.
DELETE/rest/api/3/field/{fieldId}/context/{contextId}/option/{optionId}Deletes one option.

Examples

GET /rest/api/3/field/customfield_10164/context/10338/option

Lists the options of a single-choice select list in one context. Each option has a numeric id, its text and a disabled flag.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "maxResults": 100,
 "startAt": 0,
 "total": 3,
 "isLast": true,
 "values": [
  {
   "id": "10036",
   "value": "Red",
   "disabled": false
  },
  {
   "id": "10037",
   "value": "Green",
   "disabled": false
  },
  {
   "id": "10038",
   "value": "Blue",
   "disabled": false
  }
 ]
}

Sent to Atlassian Cloud on .

GET /rest/api/3/field/customfield_10168/context/10346/option

On a cascading field the list holds the parents first, then the children. A child carries optionId, the id of its parent.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10168/context/10346/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10168/context/10346/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "maxResults": 100,
 "startAt": 0,
 "total": 4,
 "isLast": true,
 "values": [
  {
   "id": "10047",
   "value": "Europe",
   "disabled": false
  },
  {
   "id": "10048",
   "value": "Asia",
   "disabled": false
  },
  {
   "id": "10049",
   "value": "Romania",
   "optionId": "10047",
   "disabled": false
  },
  {
   "id": "10050",
   "value": "France",
   "optionId": "10047",
   "disabled": false
  }
 ]
}

Sent to Atlassian Cloud on .

POST /rest/api/3/field/customfield_10164/context/10338/option

Adds one option. The response echoes the created option with its new id.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "options": [
    {
      "value": "Yellow"
    }
  ]
}' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'options': [{'value': 'Yellow'}]},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "options": [
  {
   "id": "10051",
   "value": "Yellow",
   "disabled": false
  }
 ]
}

Response headers

X-Ratelimit-Limit: 200

Sent to Atlassian Cloud on .

POST /rest/api/3/field/customfield_10164/context/10338/option

Adds a value that already exists. Jira refuses with 400 and a message about uniqueness.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "options": [
    {
      "value": "Red"
    }
  ]
}' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'options': [{'value': 'Red'}]},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [
  "An option value must be unique in its field and a cascading option value must be unique in its option."
 ],
 "errors": {}
}

Sent to Atlassian Cloud on .

PUT /rest/api/3/field/customfield_10164/context/10338/option

Disables an option without deleting it. The body repeats id and value and sets disabled to true.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "options": [
    {
      "id": "{optionId}",
      "value": "Yellow",
      "disabled": true
    }
  ]
}' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.put(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'options': [{'id': '{optionId}', 'value': 'Yellow', 'disabled': True}]},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "options": [
  {
   "id": "10051",
   "value": "Yellow",
   "disabled": true
  }
 ]
}

Sent to Atlassian Cloud on .

DELETE /rest/api/3/field/customfield_10164/context/10338/option/{optionId}

Deletes the option by id. Success is 204 with no body.

curl

curl -X DELETE \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option/{optionId}'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.delete(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10164/context/10338/option/{optionId}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)

Response: HTTP 204

No response body.

Response headers

X-Ratelimit-Limit: 400

Sent to Atlassian Cloud on .

GET /rest/api/3/field/customfield_10162/context/10334/option

Asks a single-line text field for options. The field has none, and Jira says so with a 400.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/field/customfield_10162/context/10334/option'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/field/customfield_10162/context/10334/option',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [
  "The custom field doesn't support options."
 ],
 "errors": {}
}

Sent to Atlassian Cloud on .

How it behaves

  • A listing returns maxResults 100 by default, with total, startAt and isLast, and each option has id, value and disabled.
  • In the cascading listing the children (Romania, France) have optionId equal to the id of the parent (Europe); parents have no optionId.
  • A duplicate value in the same field gives 400 with errorMessages ['An option value must be unique in its field and a cascading option value must be unique in its option.'].
  • PUT with disabled true answers 200 and the updated option; DELETE answers 204. The calls were charged to buckets of 300 and 400 requests respectively, against 200 for POST.
  • A field type without options (the single-line text field) gives 400 with 'The custom field doesn't support options.'.

Pitfalls

  • Prefer disabling to deleting. A disabled option stays in the list with disabled true, while a delete removes it, and the spec adds that an option with cascading children cannot be deleted until the children are.
  • The spec caps a request at 1000 options and a field at 10000 options.
  • These operations work for options made in Jira or through this resource, not for select list options created by Connect apps, which have their own operations.
  • An option id is only meaningful inside the field it came from; copy it from the list, never from another field.

Questions and answers

How do I add several options at once?

Send POST with an options array. The spec allows up to 1000 per request, and each element holds value and, for a cascading child, optionId.

Can I rename an option?

Yes. PUT the id with the new value; options whose value already matches are skipped and left out of the response, and if any id is unknown no option is updated.

Sources

  1. Issue custom field options (Jira REST API v3)

Markdown version · All Jira fields pages