Skip to content

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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Users(options): Users

Parameters

NameType
optionsany

Returns

Users

Overrides

Client.constructor

Defined in

clients/core/users.d.ts:206

Properties

_transporter

_transporter: Transporter

Inherited from

Client._transporter

Defined in

clients/client.d.ts:94


eventTarget

eventTarget: CustomEventTarget

Event target to handle custom events.

Inherited from

Client.eventTarget

Defined in

clients/client.d.ts:92


jsonAPINames

jsonAPINames: string[]

Array to hold names used in the JSON API.

Overrides

Client.jsonAPINames

Defined in

clients/core/users.d.ts:207


options

options: ClientOptions & { get: (key: string) => any }

Configuration options for the client.

Inherited from

Client.options

Defined in

clients/client.d.ts:86


sideLoad

sideLoad: any[]

Array to handle side-loaded resources.

Inherited from

Client.sideLoad

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

Client.useDotJson

Defined in

clients/client.d.ts:91

Accessors

transporter

get transporter(): Transporter

Transporter for making requests.

Returns

Transporter

Inherited from

Client.transporter

Defined in

clients/client.d.ts:93

Methods

_rawRequest

_rawRequest(method, uri, ...args): Promise<{ response: any ; result: {} }>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<{ response: any ; result: {} }>

Inherited from

Client._rawRequest

Defined in

clients/client.d.ts:130


addTags

addTags(userId, tags): Promise<object>

Adds tags to a user.

Parameters

NameTypeDescription
userIdnumberThe ID of the user.
tagsstring[]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

ts
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

https://developer.zendesk.com/api-reference/ticketing/users/users/#show-the-currently-authenticated-user

Example

ts
const user = await client.users.auth();

Defined in

clients/core/users.d.ts:238


create

create(user): Promise<User>

Creates a new user.

Parameters

NameTypeDescription
userobjectThe user details.

Returns

Promise<User>

The created user's details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/users/users/#create-user

Example

ts
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

NameTypeDescription
usersobject[]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

ts
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

NameTypeDescription
userobjectThe 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

ts
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

NameTypeDescription
usersobject[]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

ts
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

NameTypeDescription
idnumberThe 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

ts
await client.users.delete(12345);

Overrides

Client.delete

Defined in

clients/core/users.d.ts:393


destroyMany

destroyMany(...args): Promise<void>

Deletes multiple users.

Parameters

NameTypeDescription
...argsany[]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

ts
await client.users.destroyMany([12345, 67890]);

Defined in

clients/core/users.d.ts:404


emit

emit(eventType, eventData): void

Parameters

NameType
eventTypeany
eventDataany

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:95


get

get(resource): Promise<NodeModule>

Parameters

NameType
resourceany

Returns

Promise<NodeModule>

Inherited from

Client.get

Defined in

clients/client.d.ts:114


getAll

getAll(resource): Promise<any[]>

Parameters

NameType
resourceany

Returns

Promise<any[]>

Inherited from

Client.getAll

Defined in

clients/client.d.ts:129


incremental

incremental(startTime): Promise<object[]>

Retrieves users incrementally.

Parameters

NameTypeDescription
startTimenumberThe 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

ts
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

NameTypeDescription
startTimenumberThe start time for the incremental export.
includestringThe 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

ts
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

NameTypeDescription
startTimenumberThe 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

ts
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

ts
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

NameTypeDescription
idnumberThe 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

ts
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

NameTypeDescription
idnumberThe 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

ts
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

NameTypeDescription
userIdnumberThe 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

ts
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

NameTypeDescription
typestringThe type of filter.
valuestring | numberThe 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

ts
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

https://developer.zendesk.com/api-reference/ticketing/users/users/#show-the-currently-authenticated-user

Example

ts
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

NameTypeDescription
idnumberThe ID of the user to be merged.
targetIdnumberThe 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

ts
await client.users.merge(12345, 67890);

Defined in

clients/core/users.d.ts:436


on

on(eventType, callback): void

Parameters

NameType
eventTypeany
callbackany

Returns

void

Inherited from

Client.on

Defined in

clients/client.d.ts:96


password

password(userId, oldPassword, newPassword): Promise<object>

Changes the password of a user.

Parameters

NameTypeDescription
userIdnumberThe ID of the user whose password is to be changed.
oldPasswordstringThe current password of the user.
newPasswordstringThe 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

ts
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

NameTypeDescription
...argsany[]The resources or parts of the resource path followed by the body.

Returns

Promise<void | object>

  • Either void or response object

Inherited from

Client.patch

Defined in

clients/client.d.ts:120


post

post(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.post

Defined in

clients/client.d.ts:122


put

put(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.put

Defined in

clients/client.d.ts:121


removeTags

removeTags(userId, tags): Promise<void>

Removes tags from a user.

Parameters

NameTypeDescription
userIdnumberThe ID of the user.
tagsstring[]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

ts
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

NameTypeDescription
methodstringHTTP method (e.g., 'GET', 'POST').
uristringThe URI for the request.
...argsany[]Additional arguments for the request.

Returns

Promise<NodeModule>

  • The API response.

Inherited from

Client.request

Defined in

clients/client.d.ts:148


requestAll

requestAll(method, uri, ...args): Promise<any[]>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<any[]>

Inherited from

Client.requestAll

Defined in

clients/client.d.ts:149


requestUpload

requestUpload(uri, file): Promise<any>

Parameters

NameType
uriany
fileany

Returns

Promise<any>

Inherited from

Client.requestUpload

Defined in

clients/client.d.ts:150


search(parameters): Promise<User[]>

Searches for users based on specific parameters.

Parameters

NameTypeDescription
parametersobjectThe 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

ts
const users = await client.users.search({query: 'john@example.com'});

Defined in

clients/core/users.d.ts:414


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


setTags

setTags(userId, tags): Promise<object>

Sets tags for a user.

Parameters

NameTypeDescription
userIdnumberThe ID of the user.
tagsstring[]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

ts
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

NameTypeDescription
idnumberThe 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

ts
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

NameTypeDescription
userIdsnumber[]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

ts
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

NameTypeDescription
idnumberThe 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

ts
await client.users.suspend(12345);

Defined in

clients/core/users.d.ts:372


unsuspend

unsuspend(id): Promise<User>

Unsuspends a user by ID.

Parameters

NameTypeDescription
idnumberThe 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

ts
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

NameTypeDescription
idnumberThe ID of the user.
userobjectThe 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

ts
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

NameTypeDescription
...argsany[]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

ts
const updatedUsers = await client.users.updateMany([12345, 67890], [{name: 'John Doe'}, {name: 'Jane Smith'}]);

Defined in

clients/core/users.d.ts:362

Released under the MIT License.