# Web API

## Documentation <a href="#documentation" id="documentation"></a>

SonarQube provides web API to access its functionalities from applications. The web services composing the web API are documented within SonarQube, by URL. You can also access the [web API documentation](https://next.sonarqube.com/sonarqube/web_api/api/alm_integrations) from the top bar in SonarQube:

![](https://931701944-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FguPtldYmKsIetAs13CP3%2Fuploads%2Fgit-blob-8203b225ed08667124547dd357202c90704232b2%2F833bff6ec93e7074a1e20c364d7de1e19ac77c0c.png?alt=media)

## Authentication <a href="#authentication" id="authentication"></a>

Administrative web services are secured and require the user to have specific permissions. In order to be authenticated, the user must provide credentials as described below.

### User token <a href="#user-token" id="user-token"></a>

This is the recommended way. Benefits are described on the page [generating-and-using-tokens](https://docs.sonarsource.com/sonarqube-server/10.1/user-guide/user-account/generating-and-using-tokens "mention").

SonarQube supports the bearer authentication scheme:

```css-79elbk
curl --header 'Authorization: Bearer MY_TOKEN' https://sonarqube.com/api/user_tokens/search
```

Alternatively, you can use the basic scheme with an empty password:

```css-79elbk
# note that the colon after the token is required in curl to set an empty password 
curl -u THIS_IS_MY_TOKEN: https://sonarqube.com/api/user_tokens/search
```

### HTTP Basic Access <a href="#http-basic-access" id="http-basic-access"></a>

Login and password are sent via the standard HTTP Basic fields:

```css-79elbk
curl -u MY_LOGIN:MY_PASSWORD https://sonarqube.com/api/user_tokens/search
```

Users who authenticate in the web application through an OAuth provider, for instance, GitHub or Bitbucket, don’t have credentials and can’t use HTTP Basic mode. They must generate and use tokens.
