> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.another-horizon.eu/llms.txt
> Use this file to discover all available pages before exploring further.

# GitLab

> Connect to a GitLab repository for automated deployments and preview builds.

We use access tokens and webhooks to authenticate and sync changes between GitLab and Mintlify.

* Mintlify uses access tokens to pull information from GitLab.
* GitLab uses webhooks to notify Mintlify when changes are made, enabling preview deployments for merge requests.

## Set up the connection

<Note>
  **HTTPS cloning required**: Your GitLab project must have HTTPS cloning enabled for Mintlify to access your repository. You can verify this in GitLab by going to your project's **Settings** > **General** > **Visibility and access controls** section.
</Note>

<Steps>
  <Step title="Find your project ID">
    In your GitLab project, navigate to **Settings** > **General** and locate your **Project ID**.

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-project-id.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=dcfc391bd023570429543e036134a226" alt="The General Settings page in the GitLab dashboard. The Project ID is highlighted." width="950" height="775" data-path="images/gitlab/gitlab-project-id.png" />
    </Frame>
  </Step>

  <Step title="Generate an access token">
    Navigate to **Settings** > **Access Tokens** and select **Add new token**.

    Configure the token with these settings:

    * **Name**: Mintlify
    * **Role**: Maintainer (required for private repos)
    * **Scopes**: `api` and `read_api`

    Click **Create project access token** and copy the token.

    <Note>
      If Project Access Tokens are not available, you can use a Personal Access Token instead. Note that Personal Access Tokens expire and must be updated.
    </Note>

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-project-access-token.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=669e54a51f98187265880f74e07c76be" alt="The Access tokens page in the GitLab dashboard. The settings to configure for Mintlify are highlighted." width="1166" height="904" data-path="images/gitlab/gitlab-project-access-token.png" />
    </Frame>
  </Step>

  <Step title="Set up the connection">
    In the [Mintlify dashboard](https://dashboard.mintlify.com/settings/deployment/git-settings):

    1. Enter your project ID and access token.
    2. Complete any other required configurations.
    3. Click **Save Changes**.

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-config.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=c668e4819319cda470a395bc08a83b62" alt="The Git Settings page in the Mintlify dashboard. The GitLab configuration settings are highlighted." width="2994" height="1704" data-path="images/gitlab/gitlab-config.png" />
    </Frame>
  </Step>
</Steps>

## Create the webhook

Webhooks allow us to receive events when changes are made so that we can
automatically trigger deployments.

<Steps>
  <Step title="Navigate to Settings > Webhooks and click 'Add new Webhook'">
    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-webhook.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=d98ab6149bea516fce81948b3d1348f2" alt="Screenshot of the Webhooks page in the GitLab dashboard." width="3014" height="1704" data-path="images/gitlab/gitlab-webhook.png" />
    </Frame>
  </Step>

  <Step title="Set up URL and webhook">
    In the "URL" field, enter the endpoint `https://leaves.mintlify.com/gitlab-webhook` and name the webhook "Mintlify".
  </Step>

  <Step title="Paste token">
    Paste the Webhook token generated after setting up the connection.

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-show-webtoken.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=1417caca27f124ee37c190d22fbd15f7" alt="Screenshot of the GitLab connection in the Mintlify dashboard. The Show Webtoken button is highlighted." width="555" height="527" data-path="images/gitlab/gitlab-show-webtoken.png" />
    </Frame>
  </Step>

  <Step title="Select events">
    Select these events to trigger the webhook:

    * **Push events** (All branches)
    * **Merge requests events**

    When you're done it should look like this:

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-project-webtoken.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=5f77f9e10bf7e72ce406e1382c840f76" alt="The Webhook page in the GitLab dashboard. The settings to configure for Mintlify are highlighted." width="1161" height="1740" data-path="images/gitlab/gitlab-project-webtoken.png" />
    </Frame>
  </Step>

  <Step title="Test the Webhook">
    After creating the Webhook, click the "Test" dropdown and select "Push events" to send a sample payload to ensure it's configured correctly. It'll say "Hook executed successfully: HTTP 200" if configured correctly.

    This will help you verify that everything is working correctly and that your documentation will sync properly with your GitLab repository.

    <Frame>
      <img src="https://mintcdn.com/anotherhorizon/JcCuRMYxa7xgY0h0/images/gitlab/gitlab-project-webtoken-test.png?fit=max&auto=format&n=JcCuRMYxa7xgY0h0&q=85&s=7ec82f915ca31d43889fd50ca2976572" alt="Screenshot of the GitLab Webhooks page. The 'Push events' menu item is highlighted in the 'Test' menu." width="1161" height="724" data-path="images/gitlab/gitlab-project-webtoken-test.png" />
    </Frame>
  </Step>
</Steps>
