Going Stellar

Home/Jira fields reference

Jira Cloud fields and work types

Jira checkboxes custom field: set and read via API

Checkboxes store several options as an array of option objects. The edit metadata allows add, set and remove, and the response lists the selected options with their ids.

Endpoints

MethodPathWhat it does
PUT/rest/api/3/issue/{issueIdOrKey}Sets or changes the value.
GET/rest/api/3/issue/{issueIdOrKey}Reads the stored value.
GET/rest/api/3/issue/{issueIdOrKey}/editmetaLists what can be edited.

Examples

PUT /rest/api/3/issue/{issueIdOrKey}

Ticks two boxes by option text in one request.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "customfield_10167": [
      {
        "value": "Frontend"
      },
      {
        "value": "Docs"
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10167'

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_10167',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10167'},
    json={'fields': {'customfield_10167': [{'value': 'Frontend'}, {'value': 'Docs'}]}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10167": [
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10044",
    "value": "Frontend",
    "id": "10044"
   },
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10046",
    "value": "Docs",
    "id": "10046"
   }
  ]
 }
}

Sent to Atlassian Cloud on .

PUT /rest/api/3/issue/{issueIdOrKey}

A box that is not in the option list is refused.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "fields": {
    "customfield_10187": [
      {
        "value": "Mobile"
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10187'

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_10187',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10187'},
    json={'fields': {'customfield_10187': [{'value': 'Mobile'}]}},
)
print(r.status_code, r.text)

Response: HTTP 400

{
 "errorMessages": [],
 "errors": {
  "customfield_10187": "Option value 'Mobile' is not valid"
 }
}

Sent to Atlassian Cloud on .

PUT /rest/api/3/issue/{issueIdOrKey}

Ticks Backend and unticks Frontend in one update block; only Backend remains.

curl

curl -X PUT \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "update": {
    "customfield_10187": [
      {
        "add": {
          "value": "Backend"
        }
      },
      {
        "remove": {
          "value": "Frontend"
        }
      }
    ]
  }
}' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}?returnIssue=true&fields=customfield_10187'

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_10187',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'returnIssue': 'true', 'fields': 'customfield_10187'},
    json={'update': {'customfield_10187': [{'add': {'value': 'Backend'}},
                                           {'remove': {'value': 'Frontend'}}]}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-11",
 "fields": {
  "customfield_10187": [
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10061",
    "value": "Backend",
    "id": "10061"
   }
  ]
 }
}

Sent to Atlassian Cloud on .

POST /rest/api/3/search/jql

Finds work items where any of the listed boxes is ticked.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "jql": "project = ZZREF AND \"zz-ref checkboxes\" in (Frontend, Docs)",
  "fields": [
    "summary"
  ],
  "maxResults": 2
}' \
  'https://your-domain.atlassian.net/rest/api/3/search/jql'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/rest/api/3/search/jql',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'jql': 'project = ZZREF AND "zz-ref checkboxes" in (Frontend, Docs)',
          'fields': ['summary'],
          'maxResults': 2},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "issues": [
  {
   "key": "ZZREF-11"
  }
 ],
 "isLast": true
}

Sent to Atlassian Cloud on .

GET /rest/api/3/issue/{issueIdOrKey}

The same two option objects come back when the work item is read.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'fields=customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181' \
  'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'fields': 'customfield_10162,customfield_10163,customfield_10164,customfield_10165,customfield_10166,customfield_10167,customfield_10168,customfield_10169,customfield_10170,customfield_10171,customfield_10172,customfield_10173,customfield_10174,customfield_10175,customfield_10176,customfield_10177,customfield_10178,customfield_10179,customfield_10180,customfield_10181'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "key": "ZZREF-6",
 "fields": {
  "customfield_10167": [
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10044",
    "value": "Frontend",
    "id": "10044"
   },
   {
    "self": "https://your-domain.atlassian.net/rest/api/3/customFieldOption/10046",
    "value": "Docs",
    "id": "10046"
   }
  ]
 }
}

Sent to Atlassian Cloud on .

GET /rest/api/3/issue/{issueIdOrKey}/editmeta

Edit metadata lists the operations and the options that can be ticked.

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": {
  "customfield_10167": {
   "name": "zz-ref checkboxes",
   "operations": [
    "add",
    "set",
    "remove"
   ],
   "allowedValues": [
    {
     "value": "Frontend",
     "id": "10044"
    },
    {
     "value": "Backend",
     "id": "10045"
    },
    {
     "value": "Docs",
     "id": "10046"
    }
   ]
  }
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • Type key com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes, searcher key com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher, schema type array with items option, display name "Checkboxes".
  • [{"value": "Frontend"}, {"value": "Docs"}] answered 200; the option ids returned are 10044 and 10046.
  • [{"value": "Mobile"}] gave 400 "Option value 'Mobile' is not valid".
  • [{"add": {"value": "Backend"}}, {"remove": {"value": "Frontend"}}] in update answered 200 and the field held Backend alone.
  • "zz-ref checkboxes" in (Frontend, Docs) found the work item with those boxes ticked; edit metadata shows operations add, set and remove.

Pitfalls

  • The message for an unknown box differs from the select list wording, so match on the key and the status, not on text.
  • Setting with fields overwrites every tick; use update with add or remove to change one box.
  • A single object in place of an array was refused for the multi-select field; that shape was not probed for checkboxes.

Questions and answers

Does the checkboxes field store an array?

Yes. The schema is array of option and the value is a list of option objects.

Sources

  1. Issues (Jira REST API v3)
  2. Issue fields (Jira REST API v3)

Markdown version · All Jira fields pages