List user's groups

get
https://api.box.com/2.0
/users/:user_id/memberships

Retrieves all the groups for a user. The user making an API call must have admin permissions to inspect the enterprise's groups.

Request

Bearer [ACCESS_TOKEN]
application/json

Path Parameters

stringin pathrequired
12345

The ID of the user.

Query Parameters

integer / int64in queryoptional
10001000

The maximum number of items to return per page.

integer / int64in queryoptional
10000

The offset of the item at which to begin the response.

Response

application/jsonGroup memberships

Returns a collection of membership objects. If there are no memberships, an empty collection will be returned.

application/jsonClient error

An unexpected client error.

get
List user's groups
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -X GET https://api.box.com/2.0/users/12345/memberships \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
.NET
BoxCollection<BoxGroupMembership> memberships = await client.GroupsManager
    .GetAllGroupMembershipsForUserAsync(userId: "11111");
Java
BoxUser user = new BoxUser(api, id);
Iterable<BoxGroupMembership.Info> memberships = user.getAllMemberships();
for (BoxGroupMembership.Info membershipInfo : memberships) {
    // Do something with the membership.
}
Python
user_memberships = client.user(user_id='33333').get_group_memberships()
for membership in user_memberships:
    print('User is in the {0} group'format(membership.group.name))
Node
var userID = '22222';
client.users.getGroupMemberships(userID)
	.then(memberships => {
		/* memberships -> {
			total_count: 1,
			entries: 
			[ { type: 'group_membership',
				id: '12345',
				user: 
					{ type: 'user',
					id: '22222',
					name: 'Alison Wonderland',
					login: 'alice@example.com' },
				group: { type: 'group', id: '11111', name: 'Employees' },
				role: 'member' } ],
			limit: 100,
			offset: 0 }
		*/
	});
iOS
client.groups.listMembershipsForUser(userId: "12345") {
    switch results {
    case let .success(iterator):
        for i in 1 ... 10 {
            iterator.next { result in
                switch result {
                case let .success(membership):
                    print("Group Membership with ID \(membership.id) was retrieved")
                case let .failure(error):
                    print(error)
                }
            }
        }
    case let .failure(error):
        print(error)
    }
}

Response Example

{
  "entries": [
    {
      "id": 11446498,
      "type": "group_membership",
      "user": {
        "id": 11446498,
        "type": "user",
        "name": "Aaron Levie",
        "login": "ceo@example.com"
      },
      "group": {
        "id": 11446498,
        "type": "group",
        "name": "Support",
        "group_type": "managed_group"
      },
      "role": "member",
      "created_at": "2012-12-12T10:53:43-08:00",
      "modified_at": "2012-12-12T10:53:43-08:00"
    }
  ],
  "limit": 1000,
  "offset": 2000,
  "order": [
    {
      "by": "type",
      "direction": "ASC"
    }
  ],
  "total_count": 5000
}