Developer Portal for YouTrack and Hub 2021.4 Help

Custom Fields in REST API

This page describes the hierarchy of custom fields in YouTrack and how the CustomField, ProjectCustomField, and IssueCustomField entities differ from each other.

CustomField

CustomField is an entity that defines a common custom field which contains basic attributes like name and fieldType. The instances property contains the settings for this field in different projects. For the complete list of attributes, see CustomField.

For the complete list of the CustomField attributes, see CustomField.

The following sample shows how to get all custom fields in YouTrack. By default, YouTrack returns only the $type and id attributes of the requested entities. To get more information about custom fields, we explicitly provide a list of returned entity attributes in the fields parameter of the request. The $type and id attributes will appear in the response regardless of whether you specify it explicitly or not.

Sample Request

curl -X GET \ 'https://example.youtrack.cloud/api/admin/customFieldSettings/customFields?fields=id,name,aliases,instances(id,project(id,name))' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json'

Sample Response Body

[ ... { "id":"58-1", "name":"Priority", "$type":"CustomField", "aliases":null, "instances":[ { "id":"92-1", "$type":"EnumProjectCustomField", "project":{ "id":"0-0", "name":"Sample Project" } }, ... ] }, ... { "id":"58-4", "name":"Assignee", "$type":"CustomField", "aliases":"for, assigned to", "instances":[ { "id":"94-0", "$type":"UserProjectCustomField", "project":{ "id":"0-0", "name":"Sample Project" } }, ... ] }, ... ]

ProjectCustomField

ProjectCustomField is an entity that contains settings of a CustomField (the field attribute) in a particular project (project), such as the set of possible values (bundle), whether the field can be empty or not (canBeEmpty) and so on.

For the complete list of the ProjectCustomField attributes, see ProjectCustomField.

The following sample shows how to get all custom fields with their settings in a particular project.

Sample Request

curl -X GET \ 'https://example.youtrack.cloud/api/admin/projects/0-0/customFields?fields=id,canBeEmpty,emptyFieldText,project(id,name),field(id,name)' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json'

Sample Response Body

[ ... { "id":"92-1", "$type":"EnumProjectCustomField", "canBeEmpty":false, "emptyFieldText":"No Priority", "field":{ "id":"58-1", "name":"Priority", "$type":"CustomField" }, "project":{ "id":"0-0", "name":"Sample Project" } }, ... { "id":"94-0", "$type":"UserProjectCustomField", "canBeEmpty":true, "emptyFieldText":"Unassigned", "field":{ "id":"58-4", "name":"Assignee", "$type":"CustomField" }, "project":{ "id":"0-0", "name":"Sample Project" } }, ... ]

IssueCustomField

The IssueCustomField entity contains the value (the value attribute) of a ProjectCustomField (projectCustomField) in a particular issue. The value can be a simple one (for example, string or integer), a link to an existing entity (a link to a specific user for the Assignee field), or a collection of values (the Affected versions field).

For the complete list of the IssueCustomField attributes, see IssueCustomField.

The following sample shows how to get all custom fields with their values in a particular issue.

Sample Request

curl -X GET \ 'https://example.youtrack.cloud/api/issues/2-7/customFields?fields=id,value(id,name,login,fullName),projectCustomField(id,field(id,name))' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer perm:am9obi5kb2U=.UG9zdG1hbiBKb2huIERvZQ==.jJe0eYhhkV271j1lCpfknNYOEakNk7' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json'

Sample Response Body

[ { "id":"92-1", "$type":"SingleEnumIssueCustomField", "projectCustomField":{ "id":"92-1", "$type":"EnumProjectCustomField", "field":{ "id":"58-1", "name":"Priority", "$type":"CustomField" } }, "value":{ "id":"67-2", "name":"Major", "$type":"EnumBundleElement" } }, ... { "id":"94-0", "$type":"SingleUserIssueCustomField", "projectCustomField":{ "id":"94-0", "$type":"UserProjectCustomField", "field":{ "id":"58-4", "name":"Assignee", "$type":"CustomField" } }, "value":{ "id":"1-3", "login":"jane.doe", "fullName":"Jane Doe", "name":"Jane Doe", "$type":"User" } }, ... ]

$type Mapping for Custom Fields

The following table shows the mapping between supported issue custom fields and their corresponding $type values. You must provide the $type value in the POST request when you need to set or update a custom field in an issue.

Custom Field Type

IssueCustomField $type

ProjectCustomField $type

enum[1]SingleEnumIssueCustomFieldEnumProjectCustomField
enum[*]MultiEnumIssueCustomFieldEnumProjectCustomField
build[1]SingleBuildIssueCustomFieldBuildProjectCustomField
build[*]MultiBuildIssueCustomFieldBuildProjectCustomField
state[1]StateIssueCustomFieldStateProjectCustomField
version[1]SingleVersionIssueCustomFieldVersionProjectCustomField
version[*]MultiVersionIssueCustomFieldVersionProjectCustomField
ownedField[1]SingleOwnedIssueCustomFieldOwnedProjectCustomField
ownedField[*]MultiOwnedIssueCustomFieldOwnedProjectCustomField
user[1]SingleUserIssueCustomFieldUserProjectCustomField
user[*]MultiUserIssueCustomFieldUserProjectCustomField
group[1]SingleGroupIssueCustomFieldGroupProjectCustomField
group[*]MultiGroupIssueCustomFieldGroupProjectCustomField
integerSimpleIssueCustomFieldSimpleProjectCustomField
floatSimpleIssueCustomFieldSimpleProjectCustomField
dateDateIssueCustomFieldSimpleProjectCustomField
date and timeSimpleIssueCustomFieldSimpleProjectCustomField
periodPeriodIssueCustomFieldPeriodProjectCustomField
stringSimpleIssueCustomFieldSimpleProjectCustomField
textTextIssueCustomFieldTextProjectCustomField
Last modified: 17 November 2021