---
title: "GitLab"
description: "Connect GitLab.com or a self-managed GitLab instance to Baz with a personal access token from a service account."
canonical: "https://baz.ai/docs/connect/gitlab"
---

# GitLab

Connect GitLab.com or a self-managed GitLab instance to Baz with a personal access token from a service account.

Baz connects to GitLab with a personal access token (PAT). Baz calls the GitLab API as the token's owner, so comments and approvals appear under that account. On GitLab.com, Baz registers its webhooks for you. On a self-managed instance, you may need to add the webhook yourself. On GitLab, Baz reviews merge requests (MRs).

## Prepare a service account

Use a dedicated GitLab user for Baz rather than your own account, so reviews are not attributed to a person and the token does not depend on one employee.

<Steps>
  <Step title="Create the service account" icon="users">
    Create a GitLab user for Baz and add it to the group whose projects Baz should review.
  </Step>
  <Step title="Give it Developer access or higher" icon="key-round">
    Baz needs at least the **Developer** role for commit status checks, approvals, and Fixer pushes. With Reporter access, Baz warns you that these features may be unavailable.
  </Step>
  <Step title="Create a personal access token" icon="lock">
    Sign in as the service account, go to **Settings → Access Tokens**, and create a token with the `api` scope. Set the longest expiry your policy allows.
  </Step>
</Steps>

:::warning
Baz rejects a token without the `api` scope ("API Write") and a token that is inactive, expired, or revoked. If the token expires within 30 days, Baz warns you and lets you continue with **Save anyway**.
:::

## Connect GitLab

<Tabs>
  <Tab title="GitLab.com">
    <Steps>
      <Step title="Enter the token" icon="plug">
        In onboarding, choose GitLab and fill in **Fill Your Access Token** and **Fill Domain** (`https://gitlab.com`). From an existing organization, go to **Settings → Integrations → GitLab**, select **Configure**, and fill in **Personal Access Token** and **Domain** in **Add GitLab Integration**.
      </Step>
      <Step title="Review warnings" icon="check-check">
        Baz validates the token. Resolve any errors. If only warnings remain (role or expiry), select **Save anyway** or fix them first.
      </Step>
      <Step title="Select projects" icon="git-merge">
        Choose the projects Baz should review and select **Continue**. Baz registers a webhook on each top-level group automatically and syncs the projects, groups, and members.
      </Step>
    </Steps>
  </Tab>
  <Tab title="Self-managed GitLab">
    <Steps>
      <Step title="Enter the token and your domain" icon="plug">
        Follow the same steps as GitLab.com, but set **Domain** to your instance's HTTPS URL, for example `https://gitlab.your-company.com`.
      </Step>
      <Step title="Allow Baz through your firewall" icon="lock">
        If your instance is not public, allow Baz's IP addresses: `18.190.165.140`, `3.20.124.148`, and `3.12.220.91`.
      </Step>
      <Step title="Select projects" icon="git-merge">
        Choose the projects Baz should review. Baz tries to register the group webhook. If your instance blocks it, the integration is still saved and you add the webhook by hand.
      </Step>
      <Step title="Add the webhook if needed" icon="workflow">
        Contact Baz support (support@baz.ai) for your integration ID and secret token. In each top-level group, open **Settings → Webhooks → Add new webhook** and set:

        - **URL**: `https://baz.ai/api/v2/webhooks/gitlab/<integrationId>`
        - **Secret token**: the secret from Baz support
        - **Trigger**: Push events, Merge request events, Issue events, Job events, Pipeline events, Comments (note events), and Member events

        Subgroups are covered by their parent group's webhook.
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Manage the integration

Go to **Settings → Integrations → GitLab** to:

- **Change projects.** Reopen the project list to add or remove projects.
- **Replace the token.** Update the integration's token in the **Update GitLab Token** dialog before it expires. The new token must belong to the same GitLab group.
- **Remove the integration.** Baz deletes the webhooks it registered.

## Related

<CardGroup cols={2}>
  <Card title="Quickstart" href="/docs/quickstart" icon="rocket">
    From connection to first review.
  </Card>
  <Card title="Pull requests" href="/docs/work/pull-requests" icon="git-pull-request">
    Read and act on Baz reviews of merge requests.
  </Card>
  <Card title="PR commands" href="/docs/reference/pr-commands" icon="terminal">
    Comment commands Baz understands on MRs.
  </Card>
  <Card title="Data protection" href="/docs/security/data-protection" icon="lock">
    How Baz stores your token.
  </Card>
</CardGroup>
