> For the complete documentation index, see [llms.txt](https://docs.snyk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snyk.io/developer-tools/snyk-apps/tool-snyk-api-import/mirroring-gitlab-organizations-and-repos-in-snyk.md).

# Mirroring GitLab organizations and repos in Snyk

How to import all GitLab organizations and repositories into Snyk with snyk-api-import

You can use four commands in the available utils to import the entirety of GitLab repos into Snyk. You must configure both the GitLab token and Snyk token as environment variables to proceed.

## General steps to import GitLab repos

Refer to individual documentation pages for detailed information. The general steps are as follows:

1. `export GITLAB_TOKEN=***` and `export SNYK_TOKEN=***`
2. Generate organization data, for example, `snyk-api-import orgs:data --source=gitlab --groupId=<snyk_group_id>` Full instructions: [Creating organizations in Snyk](/developer-tools/snyk-apps/tool-snyk-api-import/creating-organizations-in-snyk.md)
3. Create organizations in Snyk: `snyk-api-import orgs:create --file=orgs.json` By following the full instructions on [Creating organizations in Snyk](/developer-tools/snyk-apps/tool-snyk-api-import/creating-organizations-in-snyk.md) you will create a `snyk-created-orgs.json` file with Snyk organization ids and integration ids that are needed for import.
4. Generate import data: `snyk-api-import import:data --orgsData=snyk-created-orgs.json --source=gitlab --integrationType=gitlab` Full instructions: [Creating import targets data for import](/developer-tools/snyk-apps/tool-snyk-api-import/creating-import-targets-data-for-import-command.md)
5. Run import :`DEBUG=*snyk* snyk-api-import import`Full instructions: [Kicking off an import](/developer-tools/snyk-apps/tool-snyk-api-import/kicking-off-an-import.md)

## Re-importing new repos and Orgs only while mirroring

Once initial import is complete you can periodically check for new repos and make sure they are added into Snyk by following these steps, which are similar to the preceding steps to import repos.

1. `export GITLAB_TOKEN=***` and `export SNYK_TOKEN=***`
2. Generate organization data in Snyk and skip any that do not have any repos by using `--skipEmptyOrg` `snyk-api-import orgs:data --source=gitlab --groupId=<snyk_group_id> --skipEmptyOrg` Full instructions: [Creating organizations in Snyk](/developer-tools/snyk-apps/tool-snyk-api-import/creating-organizations-in-snyk.md)
3. Create organizations in Snyk and this time skip any that have been created already with `--noDuplicateNames` parameter `snyk-api-import orgs:create --file=orgs.json --noDuplicateNames` By following the full instructions on [Creating organizations in Snyk](/developer-tools/snyk-apps/tool-snyk-api-import/creating-organizations-in-snyk.md) you will create a `snyk-created-orgs.json` file with Snyk organization ids and integration ids that are needed for import.
4. Generate import data: `snyk-api-import import:data --orgsData=snyk-created-orgs.json --source=gitlab --integrationType=gitlab` Full instructions: [Creating import targets data for import](/developer-tools/snyk-apps/tool-snyk-api-import/creating-import-targets-data-for-import-command.md)
5. Optional - Generate the previously imported log to skip all previously imported repos in a Group: `snyk-api-import-macos list:imported --integrationType=gitlab --groupId=<snyk_group_id>` Full instructions: [Kicking off an import](/developer-tools/snyk-apps/tool-snyk-api-import/kicking-off-an-import.md)
6. Run import: `DEBUG=*snyk* snyk-api-import import`Full instructions: [Kicking off an import](/developer-tools/snyk-apps/tool-snyk-api-import/kicking-off-an-import.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snyk.io/developer-tools/snyk-apps/tool-snyk-api-import/mirroring-gitlab-organizations-and-repos-in-snyk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
