Archive a Value in a Set
Use the REST API to archive a value in a set of values for a custom field. In the REST API, a set of values for a custom field is represented by a bundle entity.
This use case archives a value in an enum bundle. You can use the same pattern with other bundle element types that support the archived attribute, such as BuildBundleElement, OwnedBundleElement, StateBundleElement, and VersionBundleElement.
Summary
When you have the required IDs, update the value by sending a POST request to this endpoint:
Step-by-Step
To archive an enum value in a set
Get the list of enum bundles and their values. See Enum Bundles.
curl -X GET 'https://example.youtrack.cloud/api/admin/customFieldSettings/bundles/enum?fields=id,name,values(id,name,archived)' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <YouTrack_token>' \ -H 'Content-Type: application/json'In the response, locate the bundle and value that you want to archive. This example uses the
Prioritiesbundle with the entity ID86-125and theMinorvalue with the entity ID67-5.[ { "values": [ { "name": "Major", "archived": false, "id": "67-2", "$type": "EnumBundleElement" }, { "name": "Normal", "archived": false, "id": "67-3", "$type": "EnumBundleElement" }, { "name": "Minor", "archived": false, "id": "67-5", "$type": "EnumBundleElement" } ], "name": "Priorities", "id": "86-125", "$type": "EnumBundle" } ]Archive the value by setting its
archivedattribute totrue.curl -X POST 'https://example.youtrack.cloud/api/admin/customFieldSettings/bundles/enum/86-125/values/67-5?fields=id,name,archived' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <YouTrack_token>' \ -H 'Content-Type: application/json' \ -d '{"archived": true}'If the request is successful, the response contains the archived value.
{ "name": "Minor", "archived": true, "id": "67-5", "$type": "EnumBundleElement" }Optional. Check the value in the bundle.
curl -X GET 'https://example.youtrack.cloud/api/admin/customFieldSettings/bundles/enum/86-125?fields=id,name,values(id,name,archived)' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <YouTrack_token>' \ -H 'Content-Type: application/json'The archived value is listed with the
archivedattribute set totrue.
As a result, the value is archived in the set of values.