Cannot get `api/settings/set` to work - getting "The 'key' parameter is missing"

What I am trying to achieve:
To update my project’s “new code” start date (aka, ‘leak period’) to be a specific date via the API

Problem encountered:
Using the info found in api/settings, I attempted to use POST api/settings/set to update the value. I tried to do this through REST API and then cURL. With both, a 400 Bad Request code was returned along with the following error message: “The ‘key’ parameter is missing”

What I have tried so far:


curl --request POST \
  --url 'https://<my_URL>/api/settings/set?id=<my_project>&query=settings&deprecated=false' \
  --header 'Authorization: Bearer <my_token>' \
  --header 'Content-Type: application/json' \
  --data '{
        "key": "sonar.leak.period",
        "component": "<my_project>",
        "value": "<my_YYYY-MM-DD_value>"


URL: POST https://<my_URL>/api/settings/set?query=settings&deprecated=false
		"key": "sonar.leak.period",
		"component": "<my_project>",
		"value": "<my_YYYY-MM-DD_value>"
Token: Bearer <my_token>

What I need
A solution as to why the error message The 'key' parameter is missing is generated when key is clearly being used as a parameter.


  • SonarQube Version: Community
  • SQ Deployment: unknown
  • I have ensured that the token was created for the correct project, in the correct environment, and that it’s for an account w/ ‘sonar-administrators’ and ‘sonar-users’ access

Reference pages:

Hey there.

You need to POST like this:

POST https://<my_URL>/api/settings/set?key=sonar.leak.period&component=<my_project>&value= <my_YYYY-MM-DD_value>

Thanks for the suggestion, Colin. I tried it out and got a 204 code - “No Content” - when executed.
I then ran the second POST suggested at the bottom of “New code definition in SonarCloud” (see link above): POST https://<my_URL>/api/settings/set?key=sonar.leak.period.type&component=<my_project>&value=date. This also returned a 204.

To see if this worked, I checked in two places: the SQ page for the project and also the value of leakPeriodDate in the API for the project (GET https://<my_URL>/api/components/show?component=<my_project>). Neither place showed an updated value for “new code”.

Hey there.

I re-read your post and realize what’s going on – sonar.leak.period is no longer used to control the New Code Period in the latest versions of SonarQube, and this has been the case since SonarQube v8.0.

New code: period values simplified
It’s now easier to set your new code period in the UI. With the new settings, specific analysis has replaced setting the new code period to a specific date or version. If you were using a specific date or version for your new code period, now you’ll need to use a specific analysis. See the Setting your new code period for more info.

An additional takeaway from that upgrade note – you can no longer set a specific date.

Thanks for the follow-up, Colin. You’re right, and this is a disappointing outcome. Alas.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.