node-zendesk • Docs
node-zendesk / clients/core/users / Users
Class: Users
Client for the Zendesk Users API.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/
Extends
Constructors
new Users()
new Users(
options
):Users
Parameters
• options: any
Returns
Overrides
Defined in
clients/core/users.d.ts:206
Properties
_transporter
_transporter:
Transporter
Inherited from
Defined in
clients/client.d.ts:42
eventTarget
eventTarget:
CustomEventTarget
Event target to handle custom events.
Inherited from
Defined in
clients/client.d.ts:40
jsonAPINames
jsonAPINames:
string
[]
Array to hold names used in the JSON API.
Overrides
Defined in
clients/core/users.d.ts:207
options
options:
ZendeskClientOptions
&object
Configuration options for the client.
Type declaration
get()
get: (
key
) =>any
Parameters
• key: string
Returns
any
Inherited from
Defined in
clients/client.d.ts:34
sideLoad
sideLoad:
any
[]
Array to handle side-loaded resources.
Inherited from
Defined in
clients/client.d.ts:37
sideLoadMap
sideLoadMap: (
object
|object
|object
)[]
Defined in
clients/core/users.d.ts:208
useDotJson
useDotJson:
boolean
Flag to indicate if the API endpoint should use '.json' ending.
Inherited from
Defined in
clients/client.d.ts:39
Accessors
transporter
Get Signature
get transporter():
Transporter
Returns
Transporter for making requests.
Inherited from
Defined in
clients/client.d.ts:41
Methods
_rawRequest()
_rawRequest(
method
,uri
, ...arguments_
):Promise
<object
>
Parameters
• method: any
• uri: any
• ...arguments_: any
[]
Returns
Promise
<object
>
response
response:
any
result
result:
object
Inherited from
Defined in
clients/client.d.ts:78
addTags()
addTags(
userId
,tags
):Promise
<object
>
Adds tags to a user.
Parameters
• userId: number
The ID of the user.
• tags: string
[]
An array of tags to add to the user.
Returns
Promise
<object
>
The user's details with the added tags.
response
response:
object
result
result:
object
See
https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#add-tags
Example
await client.users.addTags(12345, ['tag3', 'tag4']);
Defined in
clients/core/users.d.ts:528
auth()
auth():
Promise
<object
>
Authenticates the current user.
Returns
Promise
<object
>
The authenticated user's details.
response
response:
object
result
result:
User
See
Example
const user = await client.users.auth();
Defined in
clients/core/users.d.ts:237
create()
create(
user
):Promise
<object
>
Creates a new user.
Parameters
• user: object
The user details.
Returns
Promise
<object
>
The created user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#create-user
Example
const newUser = await client.users.create({name: 'John Doe', email: 'john@example.com'});
Defined in
clients/core/users.d.ts:309
createMany()
createMany(
users
):Promise
<object
>
Creates multiple users.
Parameters
• users: object
[]
An array of user details.
Returns
Promise
<object
>
An array of created user details.
response
response:
object
result
result:
User
[]
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#create-many-users
Example
const newUsers = await client.users.createMany([{name: 'John Doe', email: 'john@example.com'}, {name: 'Jane Smith', email: 'jane@example.com'}]);
Defined in
clients/core/users.d.ts:321
createOrUpdate()
createOrUpdate(
user
):Promise
<object
>
Creates or updates a user.
Parameters
• user: object
The user details.
Returns
Promise
<object
>
The created or updated user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-user
Example
const user = await client.users.createOrUpdate({name: 'John Doe', email: 'john@example.com'});
Defined in
clients/core/users.d.ts:333
createOrUpdateMany()
createOrUpdateMany(
users
):Promise
<object
>
Creates or updates multiple users.
Parameters
• users: object
[]
An array of user details.
Returns
Promise
<object
>
An array of created or updated user details.
response
response:
object
result
result:
User
[]
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-many-users
Example
const users = await client.users.createOrUpdateMany([{name: 'John Doe', email: 'john@example.com'}, {name: 'Jane Smith', email: 'jane@example.com'}]);
Defined in
clients/core/users.d.ts:345
delete()
delete(
id
):Promise
<void
>
Deletes a user by ID.
Parameters
• id: number
The ID of the user to delete.
Returns
Promise
<void
>
Throws
Throws an error if the user cannot be deleted.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#delete-user
Example
await client.users.delete(12345);
Overrides
Defined in
clients/core/users.d.ts:408
destroyMany()
destroyMany(...
arguments_
):Promise
<void
>
Deletes multiple users.
Parameters
• ...arguments_: any
[]
Arguments including optional IDs and user details.
Returns
Promise
<void
>
Throws
Throws an error if not enough arguments are provided.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#delete-many-users
Example
await client.users.destroyMany([12345, 67890]);
Defined in
clients/core/users.d.ts:418
emit()
emit(
eventType
,eventData
):void
Parameters
• eventType: any
• eventData: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:43
get()
get(
resource
):Promise
<NodeModule
>
Parameters
• resource: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:62
getAll()
getAll(
resource
):Promise
<any
[]>
Parameters
• resource: any
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:77
incremental()
incremental(
startTime
):Promise
<object
[]>
Retrieves users incrementally.
Parameters
• startTime: number
The start time for the incremental export.
Returns
Promise
<object
[]>
An array of user objects.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-export-users
Example
const users = await client.users.incremental(1632614395);
Defined in
clients/core/users.d.ts:484
incrementalInclude()
incrementalInclude(
startTime
,include
):Promise
<object
[]>
Retrieves users incrementally with included related data.
Parameters
• startTime: number
The start time for the incremental export.
• include: string
The related data to include.
Returns
Promise
<object
[]>
An array of user objects with included data.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-export-users
Example
const users = await client.users.incrementalInclude(1632614395, 'relatedData');
Defined in
clients/core/users.d.ts:475
incrementalSample()
incrementalSample(
startTime
):Promise
<object
>
Retrieves a sample of users incrementally.
Parameters
• startTime: number
The start time for the incremental export.
Returns
Promise
<object
>
A sample array of user objects.
response
response:
object
result
result:
object
[]
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-sample-export-users
Example
const usersSample = await client.users.incrementalSample(1632614395);
Defined in
clients/core/users.d.ts:493
list()
list():
Promise
<User
[]>
Lists all users.
Returns
Promise
<User
[]>
An array of user objects.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
Example
const users = await client.users.list();
Defined in
clients/core/users.d.ts:248
listByGroup()
listByGroup(
id
):Promise
<User
[]>
Lists users by group ID.
Parameters
• id: number
The ID of the group.
Returns
Promise
<User
[]>
An array of user objects.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
Example
const users = await client.users.listByGroup(12345);
Defined in
clients/core/users.d.ts:267
listByOrganization()
listByOrganization(
id
):Promise
<User
[]>
Lists users by organization ID.
Parameters
• id: number
The ID of the organization.
Returns
Promise
<User
[]>
An array of user objects.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
Example
const users = await client.users.listByOrganization(12345);
Defined in
clients/core/users.d.ts:276
listTags()
listTags(
userId
):Promise
<string
[]>
Lists tags associated with a user.
Parameters
• userId: number
The ID of the user.
Returns
Promise
<string
[]>
An array of tags associated with the user.
See
https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#list-tags
Example
const tags = await client.users.listTags(12345);
Defined in
clients/core/users.d.ts:505
listWithFilter()
listWithFilter(
type
,value
):Promise
<User
[]>
Lists users with a specific filter.
Parameters
• type: string
The type of filter.
• value: string
| number
The value for the filter.
Returns
Promise
<User
[]>
An array of user objects.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
Example
const users = await client.users.listWithFilter('type', 'value');
Defined in
clients/core/users.d.ts:258
me()
me():
Promise
<object
>
Retrieves details of the currently authenticated user.
Returns
Promise
<object
>
The authenticated user's details.
response
response:
object
result
result:
User
See
Example
const user = await client.users.me();
Defined in
clients/core/users.d.ts:435
merge()
merge(
id
,targetId
):Promise
<object
>
Merges a user into another user.
Parameters
• id: number
The ID of the user to be merged.
• targetId: number
The ID of the user into which the first user will be merged.
Returns
Promise
<object
>
The details of the merged user.
response
response:
object
result
result:
object
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#merge-user-into-another-user
Example
await client.users.merge(12345, 67890);
Defined in
clients/core/users.d.ts:448
on()
on(
eventType
,callback
):void
Parameters
• eventType: any
• callback: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:44
password()
password(
userId
,oldPassword
,newPassword
):Promise
<object
>
Changes the password of a user.
Parameters
• userId: number
The ID of the user whose password is to be changed.
• oldPassword: string
The current password of the user.
• newPassword: string
The new password for the user.
Returns
Promise
<object
>
The user's details after the password change.
response
response:
object
result
result:
object
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#change-password
Example
await client.users.password(12345, 'oldPassword123', 'newPassword456');
Defined in
clients/core/users.d.ts:462
patch()
patch(...
arguments_
):Promise
<void
|object
>
Patches a resource.
Parameters
• ...arguments_: any
[]
The resources or parts of the resource path followed by the body.
Returns
Promise
<void
| object
>
- Either void or response object
Inherited from
Defined in
clients/client.d.ts:68
post()
post(
resource
,body
):Promise
<NodeModule
>
Parameters
• resource: any
• body: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:70
put()
put(
resource
,body
):Promise
<NodeModule
>
Parameters
• resource: any
• body: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:69
removeTags()
removeTags(
userId
,tags
):Promise
<void
>
Removes tags from a user.
Parameters
• userId: number
The ID of the user.
• tags: string
[]
An array of tags to remove from the user.
Returns
Promise
<void
>
See
https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#remove-tags
Example
await client.users.removeTags(12345, ['tag3', 'tag4']);
Defined in
clients/core/users.d.ts:541
request()
request<
T
>(method
,uri
, ...arguments_
):Promise
<NodeModule
>
Request method that handles various HTTP methods.
Type Parameters
• T
Parameters
• method: string
HTTP method (e.g., 'GET', 'POST').
• uri: string
The URI for the request.
• ...arguments_: any
[]
Additional arguments for the request.
Returns
Promise
<NodeModule
>
- The API response.
Inherited from
Defined in
clients/client.d.ts:96
requestAll()
requestAll(
method
,uri
, ...arguments_
):Promise
<any
[]>
Parameters
• method: any
• uri: any
• ...arguments_: any
[]
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:97
requestUpload()
requestUpload(
uri
,file
):Promise
<any
>
Parameters
• uri: any
• file: any
Returns
Promise
<any
>
Inherited from
Defined in
clients/client.d.ts:98
search()
search(
parameters
):Promise
<User
[]>
Searches for users based on specific parameters.
Parameters
• parameters: object
The search parameters.
Returns
Promise
<User
[]>
An array of user objects that match the search criteria.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#search-users
Example
const users = await client.users.search({query: 'john@example.com'});
Defined in
clients/core/users.d.ts:427
setSideLoad()
setSideLoad(
array
):void
Parameters
• array: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:61
setTags()
setTags(
userId
,tags
):Promise
<object
>
Sets tags for a user.
Parameters
• userId: number
The ID of the user.
• tags: string
[]
An array of tags to set for the user.
Returns
Promise
<object
>
The user's details with the updated tags.
response
response:
object
result
result:
object
See
https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#set-tags
Example
await client.users.setTags(12345, ['tag1', 'tag2']);
Defined in
clients/core/users.d.ts:515
show()
show(
id
):Promise
<object
>
Shows details of a user by ID.
Parameters
• id: number
The ID of the user.
Returns
Promise
<object
>
The user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user
Example
const user = await client.users.show(12345);
Defined in
clients/core/users.d.ts:285
showMany()
showMany(
userIds
):Promise
<object
>
Shows details of multiple users by their IDs.
Parameters
• userIds: number
[]
An array of user IDs.
Returns
Promise
<object
>
An array of user details.
response
response:
object
result
result:
User
[]
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#show-many-users
Example
const users = await client.users.showMany([12345, 67890]);
Defined in
clients/core/users.d.ts:297
suspend()
suspend(
id
):Promise
<object
>
Suspends a user by ID.
Parameters
• id: number
The ID of the user to suspend.
Returns
Promise
<object
>
The suspended user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#suspend-user
Example
await client.users.suspend(12345);
Defined in
clients/core/users.d.ts:383
unsuspend()
unsuspend(
id
):Promise
<object
>
Unsuspends a user by ID.
Parameters
• id: number
The ID of the user to unsuspend.
Returns
Promise
<object
>
The unsuspended user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#unsuspend-user
Example
await client.users.unsuspend(12345);
Defined in
clients/core/users.d.ts:395
update()
update(
id
,user
):Promise
<object
>
Updates a user by ID.
Parameters
• id: number
The ID of the user.
• user: object
The updated user details.
Returns
Promise
<object
>
The updated user's details.
response
response:
object
result
result:
User
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#update-user
Example
const updatedUser = await client.users.update(12345, {name: 'Johnathan Doe'});
Defined in
clients/core/users.d.ts:358
updateMany()
updateMany(...
arguments_
):Promise
<object
>
Updates multiple users.
Parameters
• ...arguments_: any
[]
Arguments including optional IDs and user details.
Returns
Promise
<object
>
An array of updated user details.
response
response:
object
result
result:
User
[]
Throws
Throws an error if not enough arguments are provided.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/#update-many-users
Example
const updatedUsers = await client.users.updateMany([12345, 67890], [{name: 'John Doe'}, {name: 'Jane Smith'}]);
Defined in
clients/core/users.d.ts:371