# Set a Default Value for a Custom Field

Use the REST API to set the default value for a custom field in a specific project. Default values are stored in the project custom field settings.

This use case sets default values for a version field. You can use the same pattern for other bundle-based custom fields that support the `defaultValues` attribute.

## Summary

When you have the required IDs, update the project custom field by sending a `POST` request to this endpoint:

```
/api/admin/projects/{projectID}/customFields/{fieldID}?fields={fields}
```

## Step-by-Step

Procedure: To set a default value for a project custom field

1. Get the ID of the project where you want to set the default value. For instructions, see [Get a Project ID](api-usecase-get-project-id.html). This example uses the project `Sample Project` with the entity ID `0-0`.

2. Get the list of custom fields that are attached to the project. Request the field ID, field name, assigned bundle, and current default values.

```CURL
curl -X GET 'https://example.youtrack.cloud/api/admin/projects/0-0/customFields?fields=id,field(name),bundle(id,name,values(id,name)),defaultValues(id,name),$type' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YouTrack_token>' \
-H 'Content-Type: application/json'
```

In the response, locate the custom field and the value that you want to set as default. This example uses the `Affected versions` field with the entity ID `105-42` and the `2026.1` version value with the entity ID `133-19`.

```JSON
[
    {
        "field": {
            "name": "Affected versions",
            "$type": "CustomField"
        },
        "bundle": {
            "values": [
                {
                    "name": "2026.1",
                    "id": "133-19",
                    "$type": "VersionBundleElement"
                },
                {
                    "name": "2026.2",
                    "id": "133-24",
                    "$type": "VersionBundleElement"
                }
            ],
            "name": "Affected versions",
            "id": "97-4",
            "$type": "VersionBundle"
        },
        "defaultValues": [],
        "id": "105-42",
        "$type": "VersionProjectCustomField"
    }
]
```

3. Set the default value by updating the `defaultValues` attribute of the project custom field.

```CURL
curl -X POST 'https://example.youtrack.cloud/api/admin/projects/0-0/customFields/105-42?fields=id,field(name),defaultValues(id,name)' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YouTrack_token>' \
-H 'Content-Type: application/json' \
-d '{
    "defaultValues": [
        {"id": "133-19", "$type": "VersionBundleElement"}
    ]
}'
```

If the request is successful, the response contains the updated project custom field.

```JSON
{
    "field": {
        "name": "Affected versions",
        "$type": "CustomField"
    },
    "defaultValues": [
        {
            "name": "2026.1",
            "id": "133-19",
            "$type": "VersionBundleElement"
        }
    ],
    "id": "105-42",
    "$type": "VersionProjectCustomField"
}
```

As a result, new issues in the project use the selected value as the default for this custom field.

