> 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-github.com-and-github-enterprise-organizations-and-repos-in-snyk.md).

# Mirroring GitHub.com and GitHub Enterprise organizations and repos in Snyk

How to import all GitHub.com and GitHub Enterprise organizations and repositories into Snyk with snyk-api-import

You can use four commands in the available utilities to import the entirety of GitHub and GitHub Enterprise repositories into Snyk. You must configure both the GitHub token and the Snyk token as environment variables to proceed.

## General steps to import GitHub and GitHub Enterprise repositories

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

1. `export GITHUB_TOKEN=***` and `export SNYK_TOKEN=***`
2. Generate organization data, for example, `snyk-api-import orgs:data --source=github --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=github --integrationType=github` Full instructions: [Creating imports 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 repositories and Organizations only while mirroring

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

1. `export GITHUB_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=github --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=github --integrationType=github` 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=<integration-type> --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-github.com-and-github-enterprise-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.
