# Connect a GitLab repo

Your project files can be stored in a remote repository on GitLab.
Connect that repository so you can access, edit, and publish those files in the Redocly platform.

To connect a GitLab repository, you must first create a new access token in GitLab, then enter the connection details in Redocly.

You can connect a repository in two contexts:

- **When you create a project**: in the **Create project** modal, select **Connect existing repository**.
  The Redocly platform builds the new project from the content of your repository.
  See [Create a project from an existing repository](/docs/platform/project/manage-projects#create-a-project-from-an-existing-repository).
- **For an existing project**: on the **Settings > Git hosting** page, as described in the steps on this page.
  This replaces the current files of the project with the files from the repository.

The access token is required in both contexts.

## Create a new access token in GitLab

Before entering the connection details in the Redocly platform, you need to create and copy a new access token for your account in GitLab.
Redocly uses this access token to establish a connection to your repository.
GitLab offers multiple types of access tokens.
The access token you use needs to have `api` scope and at least `Maintainer` role.

See the GitLab documentation for creating the following access token types with the API scope option:

- [Create a personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token)
- [Create a project access token](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#create-a-project-access-token)

## Enter the connection details in Redocly

1. From your project, select **Settings > Git hosting**.
2. From the list of Git providers, select **GitLab** or a self-managed GitLab instance.
  For more information, see [Manage self-hosted Git providers in Redocly](/docs/platform/project/connect-git/self-hosted/gitlab)
3. Enter a **Credential name** for the new GitLab credential.
4. Enter the **Access token** you saved from the [Create new access token in GitLab](#create-a-new-access-token-in-gitlab) step and select **Next**.
5. Select the **Namespace > Project > Branch**.
6. (Optional) Select the **Monorepo folder**.
  Use it if your project files are part of a monorepo and you want to include only a specific folder from the repository.

  **Monorepo folder**

  If you select to only include a specific folder from a monorepo:

    - Only files listed in file tree are cloned, no other files are included
    - Project builds are started only when branch contains changes to connected folder
    - Remote content is allowed to add to connected folder only
7. Select **Next > Connect**.

  **Warning**

  **This step deletes the files currently in the Redocly project and replaces them with the files in GitLab.**

## Redocly bot account

When Redocly acts on its own in a GitLab project, it uses a bot account named **Redocly**.
For example, merge requests that Redocly opens, deployment summaries, and AI reviews show **Redocly** as the author.
Actions that you take in Redocly, such as commits from the editor, show the owner of the access token that you entered when you connected the repository.

Redocly creates the bot the first time it needs it:

- On GitLab.com and on GitLab Self-Managed with project service accounts, Redocly creates a service account and adds it to the project with the Developer role.
- On GitLab Self-Managed without project service accounts, Redocly creates a project access token named **Redocly**.
  GitLab adds the bot user of this token to the project with the Developer role.

On GitLab 14.0 and earlier, GitLab always gives the bot user of a project access token the Maintainer role.
Redocly cannot change this role.
If you don't want a bot with the Maintainer role in your project, [turn off the Redocly bot](#turn-off-the-redocly-bot).

To create the bot, the owner of the access token must have the Maintainer role in the project.
With a lower role, Redocly cannot create the bot, and everything that Redocly writes shows the owner of the access token as the author.

### Turn off the Redocly bot

You might want to turn off the bot in these cases:

- Your organization does not allow service accounts or additional members in its projects.
- Your top-level group reached the GitLab limit of service accounts.
- You want a person, not a bot, as the author of every change in the project.

When the bot is off, merge requests, deployment summaries, and AI reviews that Redocly creates show the owner of the access token as the author.

To turn off a bot that uses a service account:

1. In GitLab, open the project and select **Manage > Members**.
2. Remove the **Redocly** member from the project.

Do not delete the **Redocly** service account.
If you delete it, Redocly creates a new one.

To turn off a bot that uses a project access token:

1. In GitLab, turn off project access tokens for the top-level group, so that Redocly cannot create a new token.
2. In the project, revoke the **Redocly** token.

To turn the bot back on, add the **Redocly** member to the project again.
Redocly uses the bot again within one day.

If you disconnect the repository and connect it again, Redocly can create a new bot.
To keep the bot off, turn it off again after you reconnect.

## Resources

- **[Add remote files with one-way sync](/docs/platform/project/remote-content)** - Integrate content from external GitLab repositories into your Redocly projects for streamlined documentation workflows
- **[Use the Editor](/docs/platform/project/use-editor)** - Leverage Redocly's collaborative editing tools for content creation with GitLab repository integration and version control
- **[Manage projects](/docs/platform/project/manage-projects)** - Access feedback, deployment details, and project settings for GitLab-connected documentation projects
- **[Configuration options](/docs/platform/config)** - Complete redocly.yaml configuration options for GitLab integration, automated deployment, and project customization
