How to fetch the unused Quality Gates and Quality Profiles defined at instance level using API

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension) - Community Build 2025.1 LTA
  • how is SonarQube deployed: zip, Docker, Helm - zip
  • what are you trying to achieve - I want to get the details of unused Quality Gates and Quality Profiles defined at instance level using API
  • what have you tried so far to achieve this - I’m able to fetch the information about all the Quality Gates and Quality profiles but unable to retrieve the unused QG and QP as there is no direct API. There is no suitable parameter in json response that can be used to filter so that I can achieve my task. I observed that id field was missing.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

@HarishVegolam,

Welcome to the community, and thank you for reaching out!

To fetch the unused Quality Gates and Quality Profiles, you can try the following approach:

  1. Use the API /api/components/search?qualifiers=TRK to list all SonarQube projects.
  2. For each project, call the API /api/qualitygates/get_by_project to retrieve the associated Quality Gates.

By identifying which Quality Gates and Quality Profiles are not linked to any project, you can infer which ones are unused. If you lack the necessary privileges to access certain api, you might need elevated permissions, or check if alternative api do to the same.

I hope this helps you achieve your goal! If you have further questions, feel free to ask.