Group management API

IAM IAM

  • API Reference
    • Common request header and common response header
    • Data type
    • Error code
    • Feature Update Records
    • General Description
    • Introduction
    • Service domain
    • STS-Related Interfaces
  • API Reference_IAM
    • Common request header and common response header
    • Data type
    • Error code
    • General Description
    • Group management API
    • Introduction
    • Policy management API
    • Role Management Interfaces
    • Service domain
    • User management API
  • FAQs
    • Common Questions Overview
    • FAQs related to IAM users
    • FAQs related to product permissions
  • Function Release Records
  • Operation guide
    • Account Security Audit
    • Enterprise Account Integration
      • Federated Login Overview
      • IAM Role-based SSO
      • IAM User-based SSO
    • Group Management
    • Message Center
    • Permission Policies
      • ACL
      • Authorization
      • Managing IAM Policies
      • Permission Policy Overview
      • Policy Authentication Evaluation Logic
      • Strategy type
      • Tag-Based Authorization and Authentication
    • Role Management
      • Common scenarios
      • Create role
      • FAQs
      • Managing Roles
      • Overview
      • Related concepts
      • Using Roles
    • Settings
    • User
      • IAM User Operations
      • Two-Factor Authentication
      • User management
    • User Anomaly Behavior Analysis (Public Beta)
      • Risk Behavior Management
  • Operation records
    • Cloud Trail (Public Beta)
  • Product Announcement
    • Baidu Intelligent Cloud Enables Login Protection MFA Multi-Factor Authentication Notification for All Users
  • Product Description
    • Application scenarios
    • Concepts
    • Currently Supported Product Lines
    • Product functions
    • Product overview
    • System Restrictions
    • Enterprise Organization vs Identity and Access Management
  • Product pricing
    • Product pricing
  • Quick Start
    • Create groups and grant permissions
    • Creating IAM User Administrators
  • SDK
    • Go-SDK
      • Error handling
      • Group management API
      • Initialize SDK
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Java-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Python-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
  • Testing Knowledge Base SDK
  • Typical Practices
    • Baidu Intelligent Cloud Partner Guide to Creating IAM Users
    • User Management and Permission Assignment
All documents
menu
No results found, please re-enter

IAM IAM

  • API Reference
    • Common request header and common response header
    • Data type
    • Error code
    • Feature Update Records
    • General Description
    • Introduction
    • Service domain
    • STS-Related Interfaces
  • API Reference_IAM
    • Common request header and common response header
    • Data type
    • Error code
    • General Description
    • Group management API
    • Introduction
    • Policy management API
    • Role Management Interfaces
    • Service domain
    • User management API
  • FAQs
    • Common Questions Overview
    • FAQs related to IAM users
    • FAQs related to product permissions
  • Function Release Records
  • Operation guide
    • Account Security Audit
    • Enterprise Account Integration
      • Federated Login Overview
      • IAM Role-based SSO
      • IAM User-based SSO
    • Group Management
    • Message Center
    • Permission Policies
      • ACL
      • Authorization
      • Managing IAM Policies
      • Permission Policy Overview
      • Policy Authentication Evaluation Logic
      • Strategy type
      • Tag-Based Authorization and Authentication
    • Role Management
      • Common scenarios
      • Create role
      • FAQs
      • Managing Roles
      • Overview
      • Related concepts
      • Using Roles
    • Settings
    • User
      • IAM User Operations
      • Two-Factor Authentication
      • User management
    • User Anomaly Behavior Analysis (Public Beta)
      • Risk Behavior Management
  • Operation records
    • Cloud Trail (Public Beta)
  • Product Announcement
    • Baidu Intelligent Cloud Enables Login Protection MFA Multi-Factor Authentication Notification for All Users
  • Product Description
    • Application scenarios
    • Concepts
    • Currently Supported Product Lines
    • Product functions
    • Product overview
    • System Restrictions
    • Enterprise Organization vs Identity and Access Management
  • Product pricing
    • Product pricing
  • Quick Start
    • Create groups and grant permissions
    • Creating IAM User Administrators
  • SDK
    • Go-SDK
      • Error handling
      • Group management API
      • Initialize SDK
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Java-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Python-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
  • Testing Knowledge Base SDK
  • Typical Practices
    • Baidu Intelligent Cloud Partner Guide to Creating IAM Users
    • User Management and Permission Assignment
  • Document center
  • arrow
  • IAMIAM
  • arrow
  • SDK
  • arrow
  • Go-SDK
  • arrow
  • Group management API
Table of contents on this page
  • Create group
  • Query group
  • Update group
  • Delete group
  • List groups
  • Add user to group
  • Remove user from group
  • List the group to which a user belongs
  • List users within a group

Group management API

Updated at:2025-10-27

Create group

Create a group with the following code

Go
1	name := "test_group_sdk_go"
2	args := &api.CreateGroupArgs{
3		Name:        name,
4		Description: name,
5	}
6	result, err := client.CreateGroup(args)
7	if err != nil {
8		fmt.Println("Create group failed", err)
9	} else {
10		fmt.Println("Create group success", result)
11	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Create Group

Query group

Query a group with the following code

Go
1	name := "test_group_sdk_go"
2	result, err := client.GetGroup(name)
3	if err != nil {
4		fmt.Println("Get group failed", err)
5	} else {
6		fmt.Println("Get group success", result)
7	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Query Group

Update group

Update a group with the following codes

Go
1	name := "test_group_sdk_go"
2	args := &api.UpdateGroupArgs{
3		Description: "newDes",
4	}
5	result, err := client.UpdateGroup(name, args)
6	if err != nil {
7		fmt.Println("Update group failed", err)
8	} else {
9		fmt.Println("Update group success", result)
10	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Update Group

Delete group

Delete a group with the following code

Go
1	name := "test_group_sdk_go"
2	err = client.DeleteGroup(name)
3	if err != nil {
4		fmt.Println("Delete group failed", err)
5	} else {
6		fmt.Println("Delete group success", name)
7	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Delete Group

List groups

Delete a group with the following code

Go
1	result, err := client.ListGroup()
2	if err != nil {
3		fmt.Println("Delete group failed", err)
4	} else {
5		fmt.Println("Delete group success", result)
6	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation List Groups

Add user to group

Add a user to a group with the following codes

Go
1	userName := "test_user_sdk_go"
2	groupName := "test_user_sdk_go"
3	err = client.AddUserToGroup(userName, groupName)
4	if err != nil {
5		fmt.Println("Add user to group failed", err)
6	} else {
7		fmt.Println("Add user to group success", userName)
8	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Add a User to a Group

Remove user from group

Remove a user from a group with the following codes

Go
1	userName := "test_user_sdk_go"
2    groupName := "test_user_sdk_go"
3    err = client.DeleteUserFromGroup(userName, groupName)
4    if err != nil {
5        fmt.Println("Add user to group failed", err)
6    } else {
7        fmt.Println("Add user to group success", userName)
8    }

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation Remove a User from a Group

List the group to which a user belongs

To list groups to which the users belong with the following codes

Go
1    userName := "test_user_sdk_go"
2	result, err := client.ListGroupsForUser(userName)
3	if err != nil {
4		fmt.Println("List groups for user failed", err)
5	} else {
6		fmt.Println("List groups for user success", result)
7	}
8	

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentationList the Group to Which a User Belongs

List users within a group

List a user within a group with the following codes

Go
1	groupName := "test_user_sdk_go"
2	result, err := client.ListUsersInGroup(groupName)
3	if err != nil {
4		fmt.Println("List user in group failed", err)
5	} else {
6		fmt.Println("List user in group success", result)
7	}

Prompt:

  • For detailed parameter configuration and constraints, refer to the IAM API documentation List a User Within a Group

Previous
Error handling
Next
Initialize SDK