Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
223 lines (161 sloc) 8.32 KB


Users represent an individual's account on Box.

Get the Current User's Information

To get the current user, call the static getCurrentUser(BoxAPIConnection api) method. Then use getInfo(String... fields) to get information about the user.

BoxUser user = BoxUser.getCurrentUser(api);
BoxUser.Info info = user.getInfo();

Get User Information

To get information about a user, call the getInfo() method on the user object.

String userID = "33333";
BoxUser user = new BoxUser(api, userID);
BoxUser.Info userInfo = user.getInfo();

Create An Enterprise User

To create an enterprise user, call the createEnterpriseUser(BoxAPIConnection api, String loginEmail, String userName). To pass additional optional parameters, use the createEnterpriseUser(BoxAPIConnection api, String loginEmail, String userName, CreateUserParams options) method.

BoxUser.Info createdUserInfo = BoxUser.createEnterpriseUser(api, "", "A User");

Create An App User

To create an app user, call the createAppUser(BoxAPIConnection api, String userName) method. To pass additional optional parameters, use the createAppUser(BoxAPIConnection api, String userName, CreateUserParams options) method.

BoxUser.Info createdUserInfo = BoxUser.createAppUser(api, "A User");
CreateUserParams params = new CreateUserParams();
params.setExternalAppUserId("An Identifier Like Login");
BoxUser.Info createdUserInfo = BoxUser.createAppUser(api, "A User", params);

Update User

To update a user call the updateInfo(BoxUser.Info fieldsToUpdate) method.

BoxUser user = new BoxUser(api, "0");
BoxUser.Info info = Info();

Delete User

To delete a user call the delete(boolean notifyUser, boolean force) method.

The notifyUser determines whether the user should receive an email about the deletion, and the force parameter will cause the user to be deleted even if they still have files in their account.

BoxUser user = new BoxUser(api, "0");
user.delete(false, false);

Invite User

To invite an existing user to join an Enterprise call the inviteUser(String enterpriseID, String userEmail) method.

BoxUser user = new BoxUser(api, "0");
user.invite("Enterprise ID", "Invited User Login");

Get Email Aliases

To get a user's email aliases call the getEmailAliases() method.

BoxUser user = new BoxUser(api, "0");
Collection<EmailAlias> emailAliases = user.getEmailAliases();

Add Email Alias

To add an email alias for a user, call the addEmailAlias(String emailAddress) method.

BoxUser user = new BoxUser(api, "0");

Enterprise admins can automatically confirm the new email alias by calling the addEmailAlias(String emailAddress, boolean confirm) method:

BoxUser user = new BoxUser(api, "0");
user.addEmailAlias("", true);

Delete Email Alias

To delete a users email alias call the deleteEmailAlias(String emailAliasID) method.

BoxUser user = new BoxUser(api, "0");

Get Enterprise Users

To get an enterprises users call the getAllEnterpriseUsers(BoxAPIConnection api), getAllEnterpriseUsers(BoxAPIConnection api, String filterTerm, String... fields), or getAllEnterpriseOrExternalUsers(BoxAPIConnection api, String filterTerm, String... fields) method.

Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api);

Get App Users By External App User ID

To get app user using external app user ID, call the getAppUsersByExternalAppUserID(BoxAPIConnection api, String externalID, String... fields). This method allows you to easily associate Box app users with your application's identifiers for those users.

Iterable<BoxUser.Info> users = BoxUser.getAppUsersByExternalAppUserID(api, "external_app_user_id");

Move User's Folder

To move all of a user's content to another user, call the transferContent(String destinationUserID) method.

String sourceUserID = "11111";
String destinationUserID = "22222";
BoxUser sourceUser = new BoxUser(api, sourceUserID);
BoxFolder.Info transferredFolderInfo = sourceUser.transferContent(destinationUserID);