List the groups:

groups = gl.groups.list()

Get a group’s detail:

group = gl.groups.get(group_id)

List a group’s projects:

projects = group.projects.list()


GroupProject objects returned by this API call are very limited, and do not provide all the features of Project objects. If you need to manipulate projects, create a new Project object:

first_group_project = group.projects.list()[0]
manageable_project = gl.projects.get(, lazy=True)

You can filter and sort the result using the following parameters:

  • archived: limit by archived status
  • visibility: limit by visibility. Allowed values are public, internal and private
  • search: limit to groups matching the given value
  • order_by: sort by criteria. Allowed values are id, name, path, created_at, updated_at and last_activity_at
  • sort: sort order: asc or desc
  • ci_enabled_first: return CI enabled groups first
  • include_subgroups: include projects in subgroups

Create a group:

group = gl.groups.create({'name': 'group1', 'path': 'group1'})

Update a group:

group.description = 'My awesome group'

Set the avatar image for a group:

# the avatar image can be passed as data (content of the file) or as a file
# object opened in binary mode
group.avatar = open('path/to/file.png', 'rb')

Remove a group:

# or

Import / Export

You can export groups from gitlab, and re-import them to create new groups.


A group export is an asynchronous operation. To retrieve the archive generated by GitLab you need to:

  1. Create an export using the API
  2. Wait for the export to be done
  3. Download the result


Unlike the Project Export API, GitLab does not provide an export_status for Group Exports. It is up to the user to ensure the export is finished.

However, Group Exports only contain metadata, so they are much faster than Project Exports.

# Create the export
group = gl.groups.get(my_group)
export = group.exports.create()

# Wait for the export to finish

# Download the result
with open('/tmp/export.tgz', 'wb') as f:, action=f.write)

Import the group:

with open('/tmp/export.tgz', 'rb') as f:
    gl.groups.import_group(f, path='imported-group', name="Imported Group")




List the subgroups for a group:

subgroups = group.subgroups.list()


The GroupSubgroup objects don’t expose the same API as the Group objects. If you need to manipulate a subgroup as a group, create a new Group object:

real_group = gl.groups.get(subgroup_id, lazy=True)

Group custom attributes


List custom attributes for a group:

attrs = group.customattributes.list()

Get a custom attribute for a group:

attr = group.customattributes.get(attr_key)

Set (create or update) a custom attribute for a group:

attr = group.customattributes.set(attr_key, attr_value)

Delete a custom attribute for a group:

# or

Search groups by custom attribute:

group.customattributes.set('role': 'admin')
gl.groups.list(custom_attributes={'role': 'admin'})

Group members

The following constants define the supported access levels:

  • gitlab.GUEST_ACCESS = 10
  • gitlab.REPORTER_ACCESS = 20
  • gitlab.DEVELOPER_ACCESS = 30
  • gitlab.MAINTAINER_ACCESS = 40
  • gitlab.OWNER_ACCESS = 50


List group members:

members = group.members.list()

List the group members recursively (including inherited members through ancestor groups):

members = group.members.all(all=True)

Get a group member:

members = group.members.get(member_id)

Add a member to the group:

member = group.members.create({'user_id': user_id,
                               'access_level': gitlab.GUEST_ACCESS})

Update a member (change the access level):

member.access_level = gitlab.DEVELOPER_ACCESS

Remove a member from the group:

# or