Skip to content

Add archive/unarchive groups API feature

What does this MR do and why?

  • Adds archive/unarchive group API feature behind a feature flag
  • Only owner and admin roles can archive/unarchive group
  • Archives and Unarchives all projects inside the group

Transfer and edits of any kind to group will be added as followup MR

Endpoint Rate limit per user
POST /api/v4/groups/:id/archive 60 requests per minute
POST /api/v4/groups/:id/unarchive 60 requests per minute

Query Plans

APIs

curl -X POST 'http://localhost:3000/api/v4/groups/96/archive' --header 'PRIVATE-TOKEN: <YOUR_TOKEN>'
{
  "id": 96,
  "web_url": "http://127.0.0.1:3000/groups/shubham-archive-1",
  "name": "shubham-archive-1",
  "path": "shubham-archive-1",
  "description": "",
  "visibility": "public",
  "share_with_group_lock": false,
  "require_two_factor_authentication": false,
  "two_factor_grace_period": 48,
  "project_creation_level": "developer",
  "auto_devops_enabled": null,
  "subgroup_creation_level": "maintainer",
  "emails_disabled": false,
  "emails_enabled": true,
  "mentions_disabled": null,
  "lfs_enabled": true,
  "archived": true, // --- set as true
  "math_rendering_limits_enabled": true,
  "lock_math_rendering_limits_enabled": false,
  "default_branch": null,
  "default_branch_protection": 2,
  "default_branch_protection_defaults": {
    "allowed_to_push": [
      {
        "access_level": 40
      }
    ],
    "allow_force_push": false,
    "allowed_to_merge": [
      {
        "access_level": 40
      }
    ],
    "developer_can_initial_push": false
  },
  "avatar_url": null,
  "request_access_enabled": true,
  "full_name": "shubham-archive-1",
  "full_path": "shubham-archive-1",
  "created_at": "2025-03-25T12:05:24.813Z",
  "parent_id": null,
  "organization_id": 1,
  "shared_runners_setting": "enabled",
  "max_artifacts_size": null,
  "ldap_cn": null,
  "ldap_access": null,
  "wiki_access_level": "enabled",
  "shared_with_groups": [],
  "prevent_sharing_groups_outside_hierarchy": false,
  "shared_runners_minutes_limit": null,
  "extra_shared_runners_minutes_limit": null,
  "prevent_forking_outside_group": null,
  "membership_lock": false
}
curl -X POST 'http://localhost:3000/api/v4/groups/96/unarchive' --header 'PRIVATE-TOKEN: <YOUR_TOKEN>
{
  "id": 96,
  "web_url": "http://127.0.0.1:3000/groups/shubham-archive-1",
  "name": "shubham-archive-1",
  "path": "shubham-archive-1",
  "description": "",
  "visibility": "public",
  "share_with_group_lock": false,
  "require_two_factor_authentication": false,
  "two_factor_grace_period": 48,
  "project_creation_level": "developer",
  "auto_devops_enabled": null,
  "subgroup_creation_level": "maintainer",
  "emails_disabled": false,
  "emails_enabled": true,
  "mentions_disabled": null,
  "lfs_enabled": true,
  "archived": false, // --- set as false
  "math_rendering_limits_enabled": true,
  "lock_math_rendering_limits_enabled": false,
  "default_branch": null,
  "default_branch_protection": 2,
  "default_branch_protection_defaults": {
    "allowed_to_push": [
      {
        "access_level": 40
      }
    ],
    "allow_force_push": false,
    "allowed_to_merge": [
      {
        "access_level": 40
      }
    ],
    "developer_can_initial_push": false
  },
  "avatar_url": null,
  "request_access_enabled": true,
  "full_name": "shubham-archive-1",
  "full_path": "shubham-archive-1",
  "created_at": "2025-03-25T12:05:24.813Z",
  "parent_id": null,
  "organization_id": 1,
  "shared_runners_setting": "enabled",
  "max_artifacts_size": null,
  "ldap_cn": null,
  "ldap_access": null,
  "wiki_access_level": "enabled",
  "shared_with_groups": [],
  "prevent_sharing_groups_outside_hierarchy": false,
  "shared_runners_minutes_limit": null,
  "extra_shared_runners_minutes_limit": null,
  "prevent_forking_outside_group": null,
  "membership_lock": false
}

References

Closes #519586 (closed)

Screenshots or screen recordings

  • When the group is archived all of it's project's shown in the inactive tab:

Screenshot_2025-04-02_at_13.38.13

How to set up and validate locally

  • Create a new group
  • Create a new project inside the group
  • Get the group_id from localhost

Make sure you add access_token with owner role in group's settings

Inside rails console:

group = Group.find(group_id)
Feature.enable(:archive_group, group)
curl -X POST 'http://localhost:3000/api/v4/groups/<group_id>/archive' --header 'PRIVATE-TOKEN: <your-token>'
curl -X POST 'http://localhost:3000/api/v4/groups/<group_id>/unarchive' --header 'PRIVATE-TOKEN: <your-token>'

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Shubham Kumar

Merge request reports

Loading