node-zendesk / Exports / clients/core/users / Users
Class: Users
clients/core/users.Users
Client for the Zendesk Users API.
See
https://developer.zendesk.com/api-reference/ticketing/users/users/
Hierarchy
↳
Users
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- addTags
- auth
- create
- createMany
- createOrUpdate
- createOrUpdateMany
- delete
- destroyMany
- emit
- get
- getAll
- incremental
- incrementalInclude
- incrementalSample
- list
- listByGroup
- listByOrganization
- listTags
- listWithFilter
- me
- merge
- on
- password
- patch
- post
- put
- removeTags
- request
- requestAll
- requestUpload
- search
- setSideLoad
- setTags
- show
- showMany
- suspend
- unsuspend
- update
- updateMany
Constructors
constructor
• new Users(options
): Users
Parameters
Name | Type |
---|---|
options | any |
Returns
Overrides
Defined in
clients/core/users.d.ts:206
Properties
_transporter
• _transporter: Transporter
Inherited from
Defined in
clients/client.d.ts:94
eventTarget
• eventTarget: CustomEventTarget
Event target to handle custom events.
Inherited from
Defined in
clients/client.d.ts:92
jsonAPINames
• jsonAPINames: string
[]
Array to hold names used in the JSON API.
Overrides
Defined in
clients/core/users.d.ts:207
options
• options: ClientOptions
& { get
: (key
: string
) => any
}
Configuration options for the client.
Inherited from
Defined in
clients/client.d.ts:86
sideLoad
• sideLoad: any
[]
Array to handle side-loaded resources.
Inherited from
Defined in
clients/client.d.ts:89
sideLoadMap
• sideLoadMap: ({ all
: boolean
; array?
: undefined
; dataKey?
: undefined
; dataset
: string
; field
: string
; name
: string
} | { all?
: undefined
; array
: boolean
; dataKey
: string
; dataset
: string
; field
: string
; name
: string
} | { all?
: undefined
; array?
: undefined
; dataKey?
: undefined
; dataset
: string
; field
: string
; name
: string
})[]
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:91
Accessors
transporter
• get
transporter(): Transporter
Transporter for making requests.
Returns
Inherited from
Client.transporter
Defined in
clients/client.d.ts:93
Methods
_rawRequest
▸ _rawRequest(method
, uri
, ...args
): Promise
<{ response
: any
; result
: {} }>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<{ response
: any
; result
: {} }>
Inherited from
Defined in
clients/client.d.ts:130
addTags
▸ addTags(userId
, tags
): Promise
<object
>
Adds tags to a user.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:511
auth
▸ auth(): Promise
<object
>
Authenticates the current user.
Returns
Promise
<object
>
The authenticated user's details.
Async
See
Example
const user = await client.users.auth();
Defined in
clients/core/users.d.ts:238
create
▸ create(user
): Promise
<User
>
Creates a new user.
Parameters
Name | Type | Description |
---|---|---|
user | object | The user details. |
Returns
Promise
<User
>
The created user's details.
Async
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:310
createMany
▸ createMany(users
): Promise
<User
[]>
Creates multiple users.
Parameters
Name | Type | Description |
---|---|---|
users | object [] | An array of user details. |
Returns
Promise
<User
[]>
An array of created user details.
Async
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:320
createOrUpdate
▸ createOrUpdate(user
): Promise
<User
>
Creates or updates a user.
Parameters
Name | Type | Description |
---|---|---|
user | object | The user details. |
Returns
Promise
<User
>
The created or updated user's details.
Async
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:330
createOrUpdateMany
▸ createOrUpdateMany(users
): Promise
<User
[]>
Creates or updates multiple users.
Parameters
Name | Type | Description |
---|---|---|
users | object [] | An array of user details. |
Returns
Promise
<User
[]>
An array of created or updated user details.
Async
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:340
delete
▸ delete(id
): Promise
<void
>
Deletes a user by ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the user to delete. |
Returns
Promise
<void
>
Async
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:393
destroyMany
▸ destroyMany(...args
): Promise
<void
>
Deletes multiple users.
Parameters
Name | Type | Description |
---|---|---|
...args | any [] | Arguments including optional IDs and user details. |
Returns
Promise
<void
>
Async
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:404
emit
▸ emit(eventType
, eventData
): void
Parameters
Name | Type |
---|---|
eventType | any |
eventData | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:95
get
▸ get(resource
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:114
getAll
▸ getAll(resource
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:129
incremental
▸ incremental(startTime
): Promise
<object
[]>
Retrieves users incrementally.
Parameters
Name | Type | Description |
---|---|---|
startTime | number | The start time for the incremental export. |
Returns
Promise
<object
[]>
An array of user objects.
Async
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:469
incrementalInclude
▸ incrementalInclude(startTime
, include
): Promise
<object
[]>
Retrieves users incrementally with included related data.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:459
incrementalSample
▸ incrementalSample(startTime
): Promise
<object
[]>
Retrieves a sample of users incrementally.
Parameters
Name | Type | Description |
---|---|---|
startTime | number | The start time for the incremental export. |
Returns
Promise
<object
[]>
A sample array of user objects.
Async
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:479
list
▸ list(): Promise
<User
[]>
Lists all users.
Returns
Promise
<User
[]>
An array of user objects.
Async
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:247
listByGroup
▸ listByGroup(id
): Promise
<User
[]>
Lists users by group ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the group. |
Returns
Promise
<User
[]>
An array of user objects.
Async
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:268
listByOrganization
▸ listByOrganization(id
): Promise
<User
[]>
Lists users by organization ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the organization. |
Returns
Promise
<User
[]>
An array of user objects.
Async
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:278
listTags
▸ listTags(userId
): Promise
<string
[]>
Lists tags associated with a user.
Parameters
Name | Type | Description |
---|---|---|
userId | number | The ID of the user. |
Returns
Promise
<string
[]>
An array of tags associated with the user.
Async
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:489
listWithFilter
▸ listWithFilter(type
, value
): Promise
<User
[]>
Lists users with a specific filter.
Parameters
Name | Type | Description |
---|---|---|
type | string | The type of filter. |
value | string | number | The value for the filter. |
Returns
Promise
<User
[]>
An array of user objects.
Async
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
<{ result
: User
}>
Retrieves details of the currently authenticated user.
Returns
Promise
<{ result
: User
}>
The user's details.The authenticated user's details.
Async
See
Example
const user = await client.users.me();
Defined in
clients/core/users.d.ts:423
merge
▸ merge(id
, targetId
): Promise
<object
>
Merges a user into another user.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:436
on
▸ on(eventType
, callback
): void
Parameters
Name | Type |
---|---|
eventType | any |
callback | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:96
password
▸ password(userId
, oldPassword
, newPassword
): Promise
<object
>
Changes the password of a user.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:448
patch
▸ patch(...args
): Promise
<void
| object
>
Patches a resource.
Parameters
Name | Type | Description |
---|---|---|
...args | 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:120
post
▸ post(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:122
put
▸ put(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:121
removeTags
▸ removeTags(userId
, tags
): Promise
<void
>
Removes tags from a user.
Parameters
Name | Type | Description |
---|---|---|
userId | number | The ID of the user. |
tags | string [] | An array of tags to remove from the user. |
Returns
Promise
<void
>
Async
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:522
request
▸ request<T
>(method
, uri
, ...args
): Promise
<NodeModule
>
Request method that handles various HTTP methods.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
method | string | HTTP method (e.g., 'GET', 'POST'). |
uri | string | The URI for the request. |
...args | any [] | Additional arguments for the request. |
Returns
Promise
<NodeModule
>
- The API response.
Inherited from
Defined in
clients/client.d.ts:148
requestAll
▸ requestAll(method
, uri
, ...args
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:149
requestUpload
▸ requestUpload(uri
, file
): Promise
<any
>
Parameters
Name | Type |
---|---|
uri | any |
file | any |
Returns
Promise
<any
>
Inherited from
Defined in
clients/client.d.ts:150
search
▸ search(parameters
): Promise
<User
[]>
Searches for users based on specific parameters.
Parameters
Name | Type | Description |
---|---|---|
parameters | object | The search parameters. |
Returns
Promise
<User
[]>
An array of user objects that match the search criteria.
Async
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:414
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
setTags
▸ setTags(userId
, tags
): Promise
<object
>
Sets tags for a user.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:500
show
▸ show(id
): Promise
<{ result
: User
}>
Shows details of a user by ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the user. |
Returns
Promise
<{ result
: User
}>
The user's details.
Async
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:288
showMany
▸ showMany(userIds
): Promise
<User
[]>
Shows details of multiple users by their IDs.
Parameters
Name | Type | Description |
---|---|---|
userIds | number [] | An array of user IDs. |
Returns
Promise
<User
[]>
An array of user details.
Async
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:300
suspend
▸ suspend(id
): Promise
<User
>
Suspends a user by ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the user to suspend. |
Returns
Promise
<User
>
The suspended user's details.
Async
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:372
unsuspend
▸ unsuspend(id
): Promise
<User
>
Unsuspends a user by ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the user to unsuspend. |
Returns
Promise
<User
>
The unsuspended user's details.
Async
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:382
update
▸ update(id
, user
): Promise
<User
>
Updates a user by ID.
Parameters
Name | Type | Description |
---|---|---|
id | number | The ID of the user. |
user | object | The updated user details. |
Returns
Promise
<User
>
The updated user's details.
Async
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:351
updateMany
▸ updateMany(...args
): Promise
<User
[]>
Updates multiple users.
Parameters
Name | Type | Description |
---|---|---|
...args | any [] | Arguments including optional IDs and user details. |
Returns
Promise
<User
[]>
An array of updated user details.
Async
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:362