> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SonarQube Cloud Webhook Setup Guide

> Configure SonarQube Cloud to deliver events to StackOne.

## Prerequisites

Before continuing, you should have already completed the following for this connector:

<Steps>
  <Step title="Configure the Connector">
    Enable the connector and set up its connector profile in your project. See <a href="/connect/managing-connectors/overview">Managing Connectors</a>.

    <Columns cols={2}>
      <Card title="Connector Profile" href="/connectors/sonarcloud/guides/connector-profile/personal-access-token-bearer" icon="https://stackone-logos.com/api/sonarcloud/filled/png" horizontal>
        SonarQube Cloud - Personal Access Token (Bearer)
      </Card>
    </Columns>
  </Step>

  <Step title="Link an Account">
    Connect an account using <a href="/embed/account-linking/overview">StackOne Hub</a> or <a href="/embed/account-linking/auth-link">Auth Link</a>.

    <Columns cols={2}>
      <Card title="Link Account" href="/connectors/sonarcloud/guides/link-account/personal-access-token-bearer" icon="https://stackone-logos.com/api/sonarcloud/filled/png" horizontal>
        SonarQube Cloud - Personal Access Token (Bearer)
      </Card>
    </Columns>
  </Step>
</Steps>

<section data-guide-section data-guide-scopes="">
  <h2>Subscribe via the StackOne dashboard</h2>

  <p>This connector uses <strong>Programmatic Webhooks</strong>. When you enable webhook events for a connected SonarCloud account, StackOne automatically registers a single organisation-scoped webhook via the SonarCloud Webhooks API (`POST api/webhooks/create`), pointing at your StackOne callback URL. No manual configuration in SonarCloud is required.</p>

  <Steps>
    <Step title="Confirm permissions">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>The Personal Access Token used to authenticate must belong to a user with <strong>Administer</strong> permission on the SonarCloud organisation. Webhook creation will fail with a 403 if the token holder is not an org admin.</p>
      </div>
    </Step>

    <Step title="Enable events in the StackOne dashboard">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>In the StackOne dashboard, open the SonarCloud connector profile and enable the webhook events you want delivered downstream. StackOne creates a single webhook that receives all event types — you can enable or disable individual event types from the dashboard without modifying the webhook in SonarCloud.</p>
      </div>
    </Step>

    <Step title="Verify delivery">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Trigger a matching change in SonarCloud (for example, run an analysis or triage an issue to flip the quality gate) and confirm the event reaches your downstream consumer.</p>

        <ul>
          <li>SonarCloud posts each event as a JSON payload; StackOne responds with `200 OK` automatically.</li>
          <li>SonarCloud retries failed deliveries a limited number of times. If your endpoint is persistently unavailable, the webhook may be automatically deactivated.</li>
        </ul>
      </div>
    </Step>

    <Step title="Webhook signature verification">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>If a <strong>Secret</strong> is configured when the webhook is created, SonarCloud signs each delivery with an `X-Sonar-Webhook-HMAC-SHA256` header (lowercase-hex HMAC-SHA256 of the raw request body). The full raw payload is forwarded so downstream consumers can verify the signature independently.</p>
      </div>
    </Step>

    <Step title="Unsubscribe">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Disconnecting the account in StackOne automatically deletes the managed webhook from SonarCloud, stopping all deliveries.</p>
      </div>
    </Step>
  </Steps>
</section>

<section data-guide-section data-guide-scopes="">
  <h2>Available Webhook Events</h2>

  <p>SonarCloud has a single underlying webhook — analysis-result delivery — with no typed discriminator field. StackOne carves the following mutually-exclusive events from the delivery's `status` and `qualityGate.status` fields, so you can subscribe to exactly the outcomes you care about. All events carry the same envelope: `taskId`, `status`, `analysedAt`, `revision`, `project`, `branch`, `qualityGate` (when evaluated), and `properties`.</p>

  <Steps>
    <Step title="Analysis outcome events">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Fired when a CI/CD analysis background task completes. The webhook fires regardless of task status, so failures and cancellations are delivered too.</p>

        <ul>
          <li><strong>Project Analysis Completed</strong> (`project_analysis_completed`) — analysis succeeded but no quality gate verdict was present (gate not configured/evaluated). The gate-less completion signal.</li>
          <li><strong>Project Analysis Failed</strong> (`project_analysis_failed`) — the analysis background task failed (`status: FAILED`). Useful for CI reliability alerting.</li>
          <li><strong>Project Analysis Canceled</strong> (`project_analysis_canceled`) — the analysis background task was canceled (`status: CANCELED`).</li>
        </ul>
      </div>
    </Step>

    <Step title="Quality gate events">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Fired when a successful analysis produces a quality gate verdict.</p>

        <ul>
          <li><strong>Quality Gate Passed</strong> (`quality_gate_passed`) — analysis succeeded and the quality gate result is `OK` (the code passed the gate). Carries the passing `qualityGate` with all evaluated conditions.</li>
          <li><strong>Quality Gate Failed</strong> (`quality_gate_failed`) — analysis succeeded but the quality gate result is `ERROR` (the code did not pass the gate). Carries the failing `qualityGate` with all evaluated conditions.</li>
        </ul>
      </div>
    </Step>
  </Steps>
</section>

<section data-guide-section data-guide-scopes="">
  <h2>Delivery format</h2>

  <p>Details of how SonarCloud delivers events to StackOne.</p>

  <Steps>
    <Step title="JSON payloads, one event per request">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>SonarCloud delivers each event as an HTTP POST with `Content-Type: application/json`. Events are NOT batched — one webhook call per event. Both event types share the same JSON envelope shape; StackOne routes them by field presence (`taskId` present → analysis completed; `taskId` absent and `changedAt` present → quality gate changed).</p>
      </div>
    </Step>

    <Step title="Additional headers">
      <div data-guide-step data-guide-scopes="" data-guide-display-scopes-list="">
        <p>Every delivery includes `X-SonarQube-Project` (the project key). When a webhook secret is configured, `X-Sonar-Webhook-HMAC-SHA256` carries the HMAC-SHA256 hex signature of the raw body.</p>
      </div>
    </Step>
  </Steps>
</section>

## Verify

Your Connector should now be able to receive and process events. Try triggering an event and you should see an Event appear in the Connector logs.
