---
title: "Import a repository from GitHub"
method: POST
path: "/api/v4/import/github"
tags: ["project_import"]
---

# Import a repository from GitHub

`POST /api/v4/import/github`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/import/github`
- Auth: none declared

Imports a repository from GitHub to GitLab.

## Request body

- PostApiV4ImportGithub: Import a repository from GitHub
  - `personal_access_token` string, required: GitHub personal access token
  - `repo_id` integer, required: GitHub repository ID
  - `new_name` string: New repo name
  - `target_namespace` string, required: Namespace or group to import repository into
  - `github_hostname` string: Custom GitHub enterprise hostname. For example: https://github.example.com. From GitLab 16.5 to GitLab 17.1, you must include the path `/api/v3`.
  - `optional_stages` object: Optional stages of import to be performed
  - `timeout_strategy` 'optimistic' | 'pessimistic': Strategy for behavior on timeouts
  - `pagination_limit` integer: Pagination limit

## Response `201`

Import a repository from GitHub

- ProjectEntity: ProjectEntity model
  - `id` integer, required
  - `name` string, required
  - `full_path` string, required
  - `full_name` string, required
  - `refs_url` string, required
  - `forked` boolean, required

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `403`: Forbidden
- `422`: Unprocessable entity
- `503`: Service unavailable

---

[API](https://skmtc.dev/gitlab/apis/gitlab-api.md) - [All operations](https://skmtc.dev/gitlab/apis/gitlab-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitlab/apis/gitlab-api/revisions/b234947ef3f2?raw)
