# New code definition

The global-level new code definition is called *baseline for new code*:

* It applies by default to all projects. A specific new code definition can be applied to the project instead.
* If it applies to a project, the project consistently uses the baseline for new code. Consequently, any modifications to the baseline will automatically be applied to the project.

The default baseline for new code is the Previous version option. With the Administer System permission, you can change it to the Number of days option, either in the UI or via the Web API.

For more information about the new code options, see [about-new-code](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/about-new-code "mention").

## In the UI <a href="#in-the-ui" id="in-the-ui"></a>

1. In the top navigation bar, select **Administration** > **Configuration** > **General Settings** > **New Code**.
2. Select the new code option.
3. Select **Save**.

<figure><img src="https://2741114604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4vN6mMcoPndARxvycboz%2Fuploads%2Fgit-blob-2d7177d99752a0d6e307bbaa18ad40e2d07da97c%2F11f20347ab0ca0786d87966d9d89cf44e0a8f4e4.png?alt=media" alt="Set the new code definition by selecting a radio button corresponding to the new code option of your choice"><figcaption></figcaption></figure>

## Via the Web API <a href="#via-the-web-api" id="via-the-web-api"></a>

Use the [api/new\_code\_periods/set](https://next.sonarqube.com/sonarqube/web_api/api/new_code_periods/set) endpoint without specifying a branch or a project.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [about-new-code](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/about-new-code "mention")
* [configuring-new-code-calculation](https://docs.sonarsource.com/sonarqube-server/2025.3/project-administration/configuring-new-code-calculation "mention")


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.3/instance-administration/analysis-functions/setting-new-code-definition-at-global-level.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
