How to manipulate Custom Field Contexts using REST API in Jira Data Center

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This is a guide of how to manipulate custom field contexts using REST API. As an example, we'll add a project to a context.

The REST API endpoint described here (/rest/internal/2/field/{CustomField}/context) is not considered public, so it is not officially supported .

⚠️ This means that any Jira updates could potentially break this endpoint without warning, so make sure to validate any workflows that use it before any upgrades in production. It is also not very friendly, requiring the user to set all the context data, instead of just adding a project or an issue type.

This procedure was validated in Jira 9.12 and 10.3.

Environment

Jira Data Center 9.12 / 10.3

Solution

  • First, we need to get the custom field ID. When we navigate to the custom field screen, we can see it in the end of the URL, such as:/secure/admin/ConfigureCustomField!default.jspa?fieldId=customfield_10701

In this case, I'll use customfield_10701 as an example.

  • With that, we can call the endpoint to get the context details: /rest/internal/2/field/{CustomField}/context using GET.

Here's an example, already with jq to fetch some data we'll need to the next steps:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $ curl -s -u admin:password https://myjira.com/rest/internal/2/field/customfield_10701/context | jq '.[] | "Context ID:", .id , "Context name:", .name, "Projects IDs in context:", .projects[].id, "Project keys in context:", .projects[].key, "All issue types?", .allIssueTypes, "Issue types list (if allIssueTypes is false)", .issueTypes[].id' "Context ID:" 11001 "Context name:" "Default context for Text multi line" "Projects IDs in context:" "10000" "Project keys in context:" "SP" "All issue types?" true "Issue types list (if allIssueTypes is false)" "Context ID:" 11536 "Context name:" "Second Context -JSM" "Projects IDs in context:" "10100" "Project keys in context:" "SD" "All issue types?" false "Issue types list (if allIssueTypes is false)" "10101" "10002" "10103" "10301" "10102" "10003" "10300" "10302"

  • Now, we can call the endpoint /rest/internal/2/field/{CustomField}/context/{ContextID} using the

    PUT method, to update the context.

For example, let's add the project with ID 10200 to the first context (11001), along with the existing project (10000).

So, we need to make a PUT call to https://myjira.com/rest/internal/2/field/customfield_10701/context/11001 with this payload:

1 2 3 4 5 6 7 8 9 10 { "name":"Default context for Text multi line", "allProjects":false, "projects":[ {"id":"10200"}, {"id":"10000"} ], "allIssueTypes":true, "issueTypes":[] }

A curl example:

1 2 3 4 5 6 7 8 9 10 curl -u admin:password -X PUT -H "Content-Type: application/json" --data '{ "name":"Default context for Text multi line", "allProjects":false, "projects":[ {"id":"10200"}, {"id":"10000"} ], "allIssueTypes":true, "issueTypes":[] }' https://myjira.com/rest/internal/2/field/customfield_10701/context/11001
Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.