Use this API to migrate a group structure by exporting and importing a file. When you use it with the project import and export API, you can preserve relationships that span the group, such as connections between project issues and group epics. Run the group export and import first, then import the project exports into the group structure.

A group export includes group milestones, boards, labels, badges, members, events, wikis (Premium and Ultimate only), and subgroups. Each subgroup includes all of the same data.

To preserve the member list and permissions of an imported group, make sure those users exist on the destination instance before you import.

Because of issue 405168, imported groups have a private visibility level unless you import them into a parent group. By default, groups imported into a parent group inherit the visibility of the parent.

The destination instance uses the group relations export endpoints during group migration by direct transfer. You don’t usually need to call them yourself. In this context, a relation is an exportable item such as an epic, including any related items such as a label. These endpoints require your instance to meet certain prerequisites, and can’t be used with the file-based export and import endpoints.

Create a group import

POST /api/v4/groups/import

Creates a group import. The maximum import file size can be set by the Administrator on GitLab Self-Managed (defaults to 0 (unlimited)). Administrators can set it in the Admin area or with the max_import_size application setting.

Request body (multipart/form-data)

PropertyTypeDescription
file
Required
String (binary)The group export file to be imported
name
Required
StringGroup name
organization_idIntegerThe ID of the organization that the group will be part of. Defaults to the organization of the parent group if parent_id is provided, otherwise the current organization
parent_idIntegerThe ID of the parent group that the group will be imported into. Defaults to the current user’s namespace
path
Required
StringGroup path

Responses

CodeDescriptionSchema
202Accepted—
400Bad request—
401Unauthorized—
403Forbidden—
429Too many requests—
503Service unavailable—

Workhorse authorize the group import upload

POST /api/v4/groups/import/authorize

This feature was introduced in GitLab 12.8

Responses

CodeDescriptionSchema
201Created—
400Bad Request—

Create a group export

POST /api/v4/groups/{id}/export

Creates a group export for a specified group.

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the group

Responses

CodeDescriptionSchema
202Accepted—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
429Too many requests—
503Service unavailable—

Retrieve a group export download

GET /api/v4/groups/{id}/export/download

Retrieves the exported archive for a specified group. Time spent on exporting a group might vary depending on the size of the group. This endpoint returns the exported archive when it is available, or a 404 message otherwise.

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the group

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad request—
401Unauthorized—
403Forbidden—
404Not found—
503Service unavailable—

Schedule a relations export for a group

POST /api/v4/groups/{id}/export_relations

Schedules a relations export for a specified group. By default, this endpoint has a rate limit of 6 requests per minute for each user and group. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings.

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the group

Request body (application/json)

PropertyTypeDescription
batchedBooleanIf true, exports in batches

Responses

CodeDescriptionSchema
202Accepted—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
429Too many requests—
503Service unavailable—

Download a relations export for a group

GET /api/v4/groups/{id}/export_relations/download

Downloads a group relations export file. By default, this endpoint has a rate limit of 100 requests per minute for each user and group. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings.

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the group
relation
Query, required
StringName of the group top-level relation to download or view
batched
Query
BooleanIf true, downloads the export in batches. All or none of batched, batch_number must be provided
batch_number
Query
IntegerNumber of the export batch to download. All or none of batched, batch_number must be provided

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
429Too many requests—
503Service unavailable—

Retrieve the status of an relations export for a group

GET /api/v4/groups/{id}/export_relations/status

Retrieves the status of a relations export for a group. The status is one of 0 (started), 1 (finished), or -1 (failed).

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the group
relation
Query
StringName of the group top-level relation to download or view

Responses

CodeDescriptionSchema
200OKArray of APIEntitiesBulkImportsExportStatus
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
503Service unavailable—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesBulkImportsExportBatchStatus

PropertyTypeDescription
batch_numberIntegerExample: 1
errorStringExample: Error message
objects_countIntegerExample: 100
statusStringAllowed values: started, finished, failed
Example: started
updated_atString (date-time)Example: 2012-05-28T04:42:42-07:00

APIEntitiesBulkImportsExportStatus

PropertyTypeDescription
batchedBooleanExample: true
batchesArray of APIEntitiesBulkImportsExportBatchStatus—
batches_countIntegerExample: 2
errorStringExample: Error message
relationStringExample: issues
statusStringAllowed values: pending, started, finished, failed
Example: started
total_objects_countIntegerExample: 100
updated_atString (date-time)Example: 2012-05-28T04:42:42-07:00