box-node-sdk

UsersManager

List enterprise users

Returns a list of all users for the Enterprise along with their user_id, public_name, and login.

The application and the authenticated user need to have the permission to look up users in the entire enterprise.

This operation is performed by calling function getUsers.

See the endpoint docs at API Reference.

await client.users.getUsers();

Arguments

Returns

This function returns a value of type Users.

Returns all of the users in the enterprise.

Create user

Creates a new managed user in an enterprise. This endpoint is only available to users and applications with the right admin permissions.

This operation is performed by calling function createUser.

See the endpoint docs at API Reference.

await client.users.createUser({
  name: userName,
  login: userLogin,
  isPlatformAccessOnly: true,
} satisfies CreateUserRequestBody);

Arguments

Returns

This function returns a value of type UserFull.

Returns a user object for the newly created user.

Get current user

Retrieves information about the user who is currently authenticated.

In the case of a client-side authenticated OAuth 2.0 application this will be the user who authorized the app.

In the case of a JWT, server-side authenticated application this will be the service account that belongs to the application by default.

Use the As-User header to change who this API call is made on behalf of.

This operation is performed by calling function getUserMe.

See the endpoint docs at API Reference.

await client.users.getUserMe();

Arguments

Returns

This function returns a value of type UserFull.

Returns a single user object.

Get user

Retrieves information about a user in the enterprise.

The application and the authenticated user need to have the permission to look up users in the entire enterprise.

This endpoint also returns a limited set of information for external users who are collaborated on content owned by the enterprise for authenticated users with the right scopes. In this case, disallowed fields will return null instead.

This operation is performed by calling function getUserById.

See the endpoint docs at API Reference.

await client.users.getUserById(user.id);

Arguments

Returns

This function returns a value of type UserFull.

Returns a single user object.

Not all available fields are returned by default. Use the fields query parameter to explicitly request any specific fields using the fields parameter.

Update user

Updates a managed or app user in an enterprise. This endpoint is only available to users and applications with the right admin permissions.

This operation is performed by calling function updateUserById.

See the endpoint docs at API Reference.

await client.users.updateUserById(user.id, {
  requestBody: { name: updatedUserName } satisfies UpdateUserByIdRequestBody,
} satisfies UpdateUserByIdOptionalsInput);

Arguments

Returns

This function returns a value of type UserFull.

Returns the updated user object.

Delete user

Deletes a user. By default, this operation fails if the user still owns any content, was recently active, or recently joined the enterprise from a free account. To proceed, move their owned content first, or use the force parameter to delete the user and their files.

This operation is performed by calling function deleteUserById.

See the endpoint docs at API Reference.

await client.users.deleteUserById(user.id);

Arguments

Returns

This function returns a value of type undefined.

Removes the user and returns an empty response.