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)).

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
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
StringThe ID of a 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.

Parameters

NameTypeDescription
id
Path, required
StringThe ID of a 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.

Parameters

NameTypeDescription
id
Path, required
StringThe ID of a group

Request body (application/json)

PropertyTypeDescription
batchedBooleanWhether to export in batches

Responses

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

Download a relations export for a group

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

Downloads a group relations export file.

Parameters

NameTypeDescription
id
Path, required
StringThe ID of a group
relation
Query, required
StringGroup relation name
batched
Query
BooleanWhether to download in batches
batch_number
Query
IntegerBatch number to download

Responses

CodeDescriptionSchema
200OKString (binary) (application/octet-stream)
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
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.

Parameters

NameTypeDescription
id
Path, required
StringThe ID of a group
relation
Query
StringGroup relation name

Responses

CodeDescriptionSchema
200OKAPIEntitiesBulkImportsExportStatus
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
batchesAPIEntitiesBulkImportsExportBatchStatus—
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