All Products
Search
Document Center

Drive and Photo Service:Manage users

Last Updated:Dec 22, 2025

Note

A user has a unique ID in a domain. An account is used by a user for logon. A user may have multiple logon accounts, such as a mobile number and an email address.

Note

The system predefined roles include user, admin, and superadmin.

The admin permission mentioned in this topic refers to the permission of the user whose role is admin or superadmins.

Note

The options parameter of the IPDSRequestConfig type is encapsulated based on the request config options of axios. For more information, see AxiosRequestConfig.

createUser method

Important

To use this method, you must have the admin permission.

Creates a user.

This method is used only to create a user. If you want to use logon methods that are provided by Drive and Photo Service, you must call the LinkAccount operation.

If you access Drive and Photo Service by using JSON Web Token (JWT) authentication, you do not need to call the LinkAccount operation.

const result = await client.createUser(params, options)

Example

const userInfo = await client.createUser({
  user_id: 'id_123',
  phone: '135****8888',
  email:'username@aliyundoc.com',
  nick_name: 'Nickname',
  user_name: 'Username',
  role: 'user'
})

Request parameters

Parameter

Type

Required

Description

params

ICreateUserReq

Yes

The request parameters that are used to create a user.

options

IPDSRequestConfig

Other request parameters.

ICreateUserReq parameters

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

role

string

The role of the user. Valid values: user, admin, superadmin, subdomain, subdomain_super_admin, and subdomain_admin. Default value: user. If you create a user in the current domain, you can set this parameter to subdomain.

user_name

string

The username.

nick_name

string

The nickname of the user.

description

string

The description of the user.

email

string

The email address of the user.

phone

string

The mobile number of the user.

status

string

The status of the user. Valid values: disabled and enabled.

avatar

string

The profile picture of the user. The value must be a URI that starts with http:// or be encoded in Base64.

Response parameter

Parameter

Type

Required

Description

result

IUserItem

Yes

The returned result.

IUserItem parameters

Parameter

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address of the user.

role

string

The role of the user.

description

string

The description of the user.

phone

string

The mobile number of the user.

nick_name

string

The nickname of the user.

user_name

string

The username.

status

string

The status of the user. Valid values: enabled and disabled.

avatar

string

The profile picture of the user.

created_at

number

The time when the user was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

updated_at

number

The time when the user information was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

default_drive_id

string

The default drive ID.

listUsers method

Important

To use this method, you must have the admin permission.

Queries users.

const result = await client.listUsers(params, options)

Example:

const {items=[],next_marker} = await client.listUsers({
  limit: 100,
  marker: ''
})

Request parameters

Parameter

Type

Required

Description

params

IListReq

The request parameters that are used to query users. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

IListReq parameters

Parameter

Type

Required

Description

marker

string

The start marker of the query.

limit

string

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

Response parameter

Parameter

Type

Required

Description

result

IListRes

Yes

The returned result.

IListRes parameter

Parameter

Type

Required

Description

items

IUserItem[]

Yes

The list of users.

getUser method

Important

If you have the admin permission, you can query the information about all users. Otherwise, you can query only the information about the current user.

Queries the user information.

const result = await client.getUser(params, options)

Example

const userInfo = await client.getUser({
   user_id: 'id_123'
})

Request parameters

Parameter

Type

Required

Description

params

Object

Yes

The request parameters that are used to query the user information. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

params parameter

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

Response parameter

Parameter

Type

Required

Description

result

IUserItem

Yes

The returned result.

IUserItem parameters

Parameter

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address of the user.

role

string

The role of the user.

description

string

The description of the user.

phone

string

The mobile number of the user.

nick_name

string

The nickname of the user.

user_name

string

The username.

status

string

The status of the user. Valid values: enabled and disabled.

avatar

string

The profile picture of the user.

created_at

number

The time when the user was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

updated_at

number

The time when the user information was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

default_drive_id

string

The default drive ID.

generalGetUser method

Queries a specific user.

const result = await client.generalGetUser(params, options)

Example

const userInfo = await client.generalGetUser({
  user_id: 'id_123',
  extra_return_info: ['drive', 'group']
})

Request parameters

Parameter

Type

Required

Description

params

Object

Yes

The request parameters that are used to query a specific user. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

params parameters

Parameter

Type

Required

Description

user_id

string

Yes

The user ID. If you do not specify this parameter, the current user is queried.

extra_return_info

string[]

The type of user information to query. Valid values: drive and group.

This parameter is valid only if you have the admin permission.

If you set this parameter to group, the query speed is significantly reduced. In this case, the number of requests cannot exceed 30.

Response parameter

Parameter

Type

Required

Description

result

IUserItem

Yes

The returned result.

IUserItem parameters

Parameter

Type

Description

domain_id

string

The domain ID.

user_id

string

The user ID.

email

string

The email address of the user.

role

string

The role of the user.

description

string

The description of the user.

phone

string

The mobile number of the user.

nick_name

string

The nickname of the user.

user_name

string

The username.

status

string

The status of the user. Valid values: enabled and disabled.

avatar

string

The profile picture of the user.

created_at

number

The time when the user was created. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

updated_at

number

The time when the user information was last modified. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

default_drive_id

string

The default drive ID.

updateUser method

Important

To use this method, you must have the admin permission.

Modifies the information such as the nickname and profile picture of a user.

await client.updateUser(params, options)

Example

// Disable a user.
await client.updateUser({  
  user_id: 'id_123',
  status : 'disabled'
})

Request parameters

Parameter

Type

Required

Description

params

IUpdateUserReq

Yes

The request parameters that are used to modify the user information. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

IUpdateUserReq parameters

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

role

string

The role of the user. Valid values: user, admin, and superadmin. Default value: user.

nick_name

string

The nickname of the user.

description

string

The description of the user.

email

string

The email address of the user.

phone

string

The mobile number of the user.

status

string

The status of the user. Valid values: disabled and enabled.

avatar

string

The profile picture of the user. The value must be a URI that starts with http:// or be encoded in Base64.

Response parameter

Parameter

Type

Required

Description

result

IUserItem

Yes

The returned result.

deleteUser method

Important

To use this method, you must have the admin permission.

Deletes a user and the account that is associated with the user.

await client.deleteUser(params, options)

Example

await client.deleteUser({
  user_id: 'id_123'
})

Request parameters

Parameter

Type

Required

Description

params

Object

Yes

The request parameters that are used to delete a user and the account that is associated with the user. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

params parameters

Parameter

Type

Required

Description

user_id

string

Yes

The user ID.

Response parameters

None.

searchUsers method

Important

To use this method, you must have the admin permission.

Searches for users.

const result = await client.searchUsers(params, options)

Example

const {items=[]} = await client.searchUsers({  
  nick_name_for_fuzzy: 'test'
})

Request parameters

Parameter

Type

Required

Description

params

ISearchUsersReq

Yes

The request parameters that are used to search for users. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

ISearchUsersReq parameters

Parameter

Type

Required

Description

nick_name

string

The user nickname. Prefix match is supported.

nick_name_for_fuzzy

string

The user nickname for fuzzy search.

user_name

string

The username. Prefix match is supported.

email

string

The user email address. Prefix match is supported.

phone

string

The user mobile number. Prefix match is supported.

role

string

The user role. Exact match is used.

status

string

The user status. Exact match is used.

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker of the query.

Response parameter

Parameter

Type

Required

Description

result

IListRes

Yes

The returned result.

IListRes parameters

Parameter

Type

Description

items

IUserItem[]

The users returned.

next_marker

string

The pagination token. It can be used in the next request to retrieve a new page of results.

generalSearchUsers method

Searches for users of a group.

const result = await client.generalSearchUsers(params, options)

Example

const {items=[], next_marker} = await client.generalSearchUsers({  
  nick_name_for_fuzzy: 'test',
  direct_parent_group_id: '123456',
  extra_return_info: ['drive', 'group'],
  limit: 30,
  marker: ''
})

Request parameters

Parameter

Type

Required

Description

params

IUserGeneralSearchReq

Yes

The request parameters that are used to search for users of a group. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

IUserGeneralSearchReq parameters

Parameter

Type

Required

Description

nick_name

string

The user nickname. Prefix match is supported.

nick_name_for_fuzzy

string

The user nickname for fuzzy search.

parent_group_id_list

string[]

The group whose direct users and users of subgroups you want to query.

direct_parent_group_id

string

The group whose direct users you want to query.

extra_return_info

string[]

The type of user information to query. Valid values: drive and group.

This parameter is valid only if you have the admin permission.

If you set this parameter to group, the query speed is significantly reduced. In this case, the number of requests cannot exceed 30.

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker of the query.

Response parameter

Parameter

Type

Required

Description

result

IListRes

Yes

The returned result.

IListRes parameters

Parameter

Type

Description

items

IUserItem[]

The users returned.

next_marker

string

The pagination token. It can be used in the next request to retrieve a new page of results.

listGroupUsers method

Queries the direct members of a group.

Both administrators and regular users can use this method.

const result = await client.listGroupUsers(params, options)

Example

const params = {
  group_id: "abc"
}
const {items=[], next_marker} = await client.listGroupUsers(params)

Request parameters

Parameter

Type

Required

Description

params

IListGroupUserReq

Yes

The request parameters that are used to query the direct members of a group. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

IListGroupUserReq parameters

Parameter

Type

Required

Description

group_id

string

The ID of the group that you want to query.

member_type

string

The type of the group members that you want to query. Valid values: user and group. If you do not specify this parameter, the direct users and subgroups of the group are queried.

extra_return_info

string[]

The type of user information to query. Valid values: group and drive.

This parameter is valid only if you have the admin permission. If you set this parameter to group, the query speed is significantly reduced. In this case, the number of requests cannot exceed 30.

limit

number

The maximum number of entries to return. Valid values: 1 to 100. Default value: 100.

marker

string

The start marker of the query.

Response parameter

Parameter

Type

Required

Description

result

IListRes

Yes

The returned result.

IListRes parameters

Parameter

Type

Description

items

IGroupItem[] or

IUserItem[]

The members returned.

next_marker

string

The pagination token. It can be used in the next request to retrieve a new page of results.

importUser method

Important

To use this method, you must have the admin permission.

Imports a user who uses a mobile number or an email address for logon.

An alternative way to perform this operation is to call the createUser operation first and then call the createAccountLink operation after the first call is successful.

const result = await client.importUser(params, options)

Example

The following sample code provides an example on how to import a user who uses a mobile number for logon:

await client.importUser({
  authentication_type: 'mobile',
  auto_create_drive: true,
  identity:'135****8888',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

The following sample code provides an example on how to import a user who uses an email address for logon:

await client.importUser({
  authentication_type: 'email',
  auto_create_drive: true,
  identity:'username@example.com',
  drive_total_size: 1024 * 1024 * 1024,
  nick_name: 'W123'
})

Request parameters

Parameter

Type

Required

Description

params

IImportUserReq

Yes

The request parameters that are used to import a user. If you do not specify this parameter, the default value {} is used.

options

IPDSRequestConfig

Other request parameters.

IImportUserReq parameters

Parameter

Type

Required

Description

auto_create_drive

boolean

Specifies whether to automatically create a drive.

drive_total_size

number

The total size of the drive.

authentication_type

string

The type of logon authentication. Valid values: mobile, email, ldap, and custom.

identity

string

Yes

The unique identifier of the user. If you set the authentication_type parameter to mobile, you must set this parameter to the mobile number of the user. If you set the authentication_type parameter to email, you must set this parameter to the email address of the user. If you set the authentication_type parameter to idap, you must set this parameter to the LDAP account of the user. If you set the authentication_type parameter to custom, you must set this parameter to a custom ID.

parent_group_id

string

nick_name

string

The nickname of the user.

Response parameter

Parameter

Type

Required

Description

result

IUserItem

Yes

The returned result.