For the complete documentation index, see llms.txt. This page is also available as Markdown.

Web API

How to use SonarQube Cloud’s Web API.

SonarQube Cloud offers a Web API, allowing external applications to access its features. The base URL for accessing the API depends on whether you are using the SonarQube Cloud’s EU or US instance

Web API documentation

The SonarQube Cloud’s Web API v2 documentation is available here.

The web services composing the Web API v1 are documented within SonarQube Cloud, through the URL https://sonarcloud.io/web_api.

You can also access the Web API documentation from the top bar in Cloud by selecting the help button.

Select the help menu (question mark icon) in the top right corner.

Authenticating to the Web API

Administrative web services are secured and require the user to have specific permissions.

To authenticate to the Web API, use the bearer authentication scheme. With this scheme, a SonarQube Cloud token is used:

Sending an API request

Web API v2

To make a request, you need to find the SonarQube Cloud API and the right path for the operation that you want to use. The following APIs are available:

  • Analysis

  • Authentication domain

  • Audit logs

  • AICA (AI Code Assurance)

  • Enterprises, Reports, Portfolios, Portfolio Permission Templates

  • Organizations

  • Projects

  • Quality Gates

  • SCA (Software Composition Analysis)

  • Software Quality Reports

  • Users and roles

Sample request

The code block below shows a request with cURL.

Where <domain> is:

  • For the EU instance: sonarcloud.io

  • For the US instance: sonarqube.us

Example

For more information about API request and response, see the SonarQube Cloud’s Web API v2 documentation.

Web API v1

To make a request, you need to find the HTTP method and the right path for the operation that you want to use.

Content-Type header

Unless the Sonar Web API endpoint specifications list a specific Content-Type value, your request should use the following Content-Type header:

Content-Type: application/x-www-form-urlencoded

This is the default Content-Type value set by most tools and libraries, such as curl and Python’s requests module, but you should check their documentation for proper usage.

Sample API request

If, for example, you want to use the Web API to extract measures, you can make a "GET MEASURES" call to the SonarQube Cloud /api/measures endpoint in order to extract measures of a given metric for a given project. For this example, a possible request and response are shown below.

Sample request

Where <domain> is:

  • For the EU instance: sonarcloud.io

  • For the US instance: sonarqube.us

Sample response

Taking into account the API rate limiting

Some of SonarQube Cloud’s APIs are rate-limited in order to ensure that we can continue to deliver the service smoothly and with optimum performance. In most cases, you should take this into account when automating tasks and processes by using the SonarQube Cloud Web API.

Your API calls will fail with a 429 status code when the rate limit has been reached. If this happens, wait a few minutes before retrying the operation.

Last updated

Was this helpful?