Skip to content

node-zendesk / Exports / clients/core/tickets / Tickets

Class: Tickets

clients/core/tickets.Tickets

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Tickets(options): Tickets

Parameters

NameTypeDescription
optionsanyThe client options.

Returns

Tickets

Constructs

Tickets

Overrides

Client.constructor

Defined in

clients/core/tickets.d.ts:478

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/tickets.d.ts:479


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: { dataset: string ; field: string ; name: string }[]

Defined in

clients/core/tickets.d.ts:480


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(ticketId, tags): Promise<void>

Add tags to a specific ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to add tags to.
tagsstring[]An array of tags to add to the ticket.

Returns

Promise<void>

A promise that resolves when the tags are successfully added to the ticket.

Async

Throws

If ticketId is not a valid number or tags is not an array of strings.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#updating-tag-lists

Example

ts
// Add tags to a specific ticket
const ticketId = 12345;
const tags = ['tag1', 'tag2'];
await client.tickets.addTags(ticketId, tags);

Defined in

clients/core/tickets.d.ts:847


create

create(ticket): Promise<{ result: Ticket }>

Create a new ticket.

Parameters

NameTypeDescription
ticketCreateOrUpdateTicketDetails of the ticket to be created.

Returns

Promise<{ result: Ticket }>

The created ticket details.

Async

Throws

If the ticket details are not provided or invalid.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket

Example

ts
const newTicket = await client.tickets.create({ subject: 'New ticket', description: 'Ticket description' });

Defined in

clients/core/tickets.d.ts:617


createMany

createMany(tickets): Promise<Ticket[]>

Create multiple new tickets.

Parameters

NameTypeDescription
ticketsCreateManyTicketsAn object of tickets containing an array of tickets.

Returns

Promise<Ticket[]>

A promise that resolves to an array of created ticket objects.

Async

Throws

If the provided tickets is not an array or is empty.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-many-tickets

Example

ts
// Create multiple new tickets
const newTickets = {
 tickets: [
   { subject: 'Ticket 1', description: 'Description 1' },
   { subject: 'Ticket 2', description: 'Description 2' },
  ]
};
const createdTickets = await client.tickets.createMany(newTickets);

Defined in

clients/core/tickets.d.ts:637


delete

delete(ticketId): Promise<void>

Delete a ticket by its ID.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to delete.

Returns

Promise<void>

A promise that resolves when the ticket is successfully deleted.

Async

Throws

If ticketId is not a number or is not provided.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket

Example

ts
// Delete a ticket by its ID
const ticketIdToDelete = 123;
await client.tickets.delete(ticketIdToDelete);

Overrides

Client.delete

Defined in

clients/core/tickets.d.ts:691


deleteMany

deleteMany(ticketIds): Promise<void>

Delete multiple tickets by their IDs.

Parameters

NameTypeDescription
ticketIdsnumber[]An array of ticket IDs to delete.

Returns

Promise<void>

A promise that resolves when the tickets are successfully deleted.

Async

Throws

If ticketIds is not an array of valid ticket IDs.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#bulk-delete-tickets

Example

ts
// Delete multiple tickets by their IDs
const ticketIdsToDelete = [123, 456, 789];
await client.tickets.deleteMany(ticketIdsToDelete);

Defined in

clients/core/tickets.d.ts:704


emit

emit(eventType, eventData): void

Parameters

NameType
eventTypeany
eventDataany

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:95


export

export(startTime): Promise<object>

DEPRECATED: Use the TicketExport class method export instead.

Export tickets based on a specified start time.

Parameters

NameTypeDescription
startTimestringThe start time for exporting tickets.

Returns

Promise<object>

A promise that resolves with the exported tickets.

Async

Throws

If startTime is not a valid string.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export

Example

ts
// Export tickets based on a start time
const startTime = '2023-01-01T00:00:00Z';
const exportedTickets = await client.tickets.export(startTime);

Deprecated

Use TicketExport.export(startTime) method instead.

Defined in

clients/core/tickets.d.ts:739


exportAudit

exportAudit(ticketId): Promise<any[]>

Retrieve audits associated with a specific ticket. (Deprecated: Use TicketAudits class list method instead)

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to retrieve audits for.

Returns

Promise<any[]>

A promise that resolves with an array of audits associated with the ticket.

Async

Throws

If ticketId is not a valid number.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#listing-ticket-audits

Example

ts
// Retrieve audits for a specific ticket (deprecated)
const ticketId = 12345;
const audits = await client.tickets.exportAudit(ticketId);

Deprecated

Use the TicketAudits class list method instead.

Defined in

clients/core/tickets.d.ts:832


exportSample

exportSample(startTime): Promise<object>

DEPRECATED: Use the TicketExport class method sample instead.

Export a sample of tickets based on a specified start time.

Parameters

NameTypeDescription
startTimestringThe start time for exporting the sample of tickets.

Returns

Promise<object>

A promise that resolves with the exported sample of tickets.

Async

Throws

If startTime is not a valid string.

See

https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-sample-export

Example

ts
// Export a sample of tickets based on a start time
const startTime = '2023-01-01T00:00:00Z';
const exportedSample = await client.tickets.exportSample(startTime);

Deprecated

Use TicketExport.sample(startTime) method instead.

Defined in

clients/core/tickets.d.ts:755


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


getComments

getComments(ticketId): Promise<any[]>

Retrieve comments associated with a specific ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to retrieve comments for.

Returns

Promise<any[]>

A promise that resolves with an array of comments associated with the ticket.

Async

Throws

If ticketId is not a valid number.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/

Example

ts
// Retrieve comments for a specific ticket
const ticketId = 12345;
const comments = await client.tickets.getComments(ticketId);

Defined in

clients/core/tickets.d.ts:818


incremental

incremental(startTime): Promise<any[]>

DEPRECATED: Use the TicketExport class method export instead.

Export incremental tickets based on a specified start time.

Parameters

NameTypeDescription
startTimestringThe start time for exporting incremental tickets.

Returns

Promise<any[]>

A promise that resolves with an array of exported incremental tickets.

Async

Throws

If startTime is not a valid string.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental

Example

ts
// Export incremental tickets based on a start time
const startTime = '2023-01-01T00:00:00Z';
const incrementalTickets = await client.tickets.incremental(startTime);

Deprecated

Use TicketExport.export(startTime) method instead.

Defined in

clients/core/tickets.d.ts:771


incrementalInclude

incrementalInclude(startTime, include): Promise<any[]>

DEPRECATED: Use the TicketExport class method exportWithInclude instead.

Export incremental tickets based on a specified start time and optional include parameters.

Parameters

NameTypeDescription
startTimestringThe start time for exporting incremental tickets.
includestringOptional parameters to include in the export.

Returns

Promise<any[]>

A promise that resolves with an array of exported incremental tickets.

Async

Throws

If startTime is not a valid string.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental-include

Example

ts
// Export incremental tickets based on a start time with optional include parameters
const startTime = '2023-01-01T00:00:00Z';
const include = 'users,groups';
const incrementalTickets = await client.tickets.incrementalInclude(startTime, include);

Deprecated

Use TicketExport.exportWithInclude(startTime, include) method instead.

Defined in

clients/core/tickets.d.ts:789


incrementalSample

incrementalSample(startTime): Promise<any[]>

DEPRECATED: Use the TicketExport class method sample instead.

Export a sample of incremental tickets based on a specified start time.

Parameters

NameTypeDescription
startTimestringThe start time for exporting the sample of incremental tickets.

Returns

Promise<any[]>

A promise that resolves with an array of exported incremental tickets.

Async

Throws

If startTime is not a valid string.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental-sample

Example

ts
// Export a sample of incremental tickets based on a start time
const startTime = '2023-01-01T00:00:00Z';
const incrementalSampleTickets = await client.tickets.incrementalSample(startTime);

Deprecated

Use TicketExport.sample(startTime) method instead.

Defined in

clients/core/tickets.d.ts:805


list

list(): Promise<Ticket[]>

List all the tickets.

Returns

Promise<Ticket[]>

An array of tickets.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const tickets = await client.tickets.list();

Defined in

clients/core/tickets.d.ts:493


listAssigned

listAssigned(userID): Promise<Ticket[]>

List all tickets assigned to a specific user.

Parameters

NameTypeDescription
userIDnumberThe ID of the user.

Returns

Promise<Ticket[]>

An array of tickets assigned to the user.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const assignedTickets = await client.tickets.listAssigned(12345);

Defined in

clients/core/tickets.d.ts:503


listByOrganization

listByOrganization(orgID): Promise<Ticket[]>

List all tickets associated with a specific organization.

Parameters

NameTypeDescription
orgIDnumberThe ID of the organization.

Returns

Promise<Ticket[]>

An array of tickets under the organization.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const orgTickets = await client.tickets.listByOrganization(6789);

Defined in

clients/core/tickets.d.ts:513


listByUserCCD

listByUserCCD(userID): Promise<Ticket[]>

List all tickets where a specific user is CC'd.

Parameters

NameTypeDescription
userIDnumberThe ID of the user.

Returns

Promise<Ticket[]>

An array of tickets where the user is CC'd.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const ccdTickets = await client.tickets.listByUserCCD(12345);

Defined in

clients/core/tickets.d.ts:533


listByUserRequested

listByUserRequested(userID): Promise<Ticket[]>

List all tickets requested by a specific user.

Parameters

NameTypeDescription
userIDnumberThe ID of the user.

Returns

Promise<Ticket[]>

An array of tickets requested by the user.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const requestedTickets = await client.tickets.listByUserRequested(12345);

Defined in

clients/core/tickets.d.ts:523


listCollaborators

listCollaborators(ticketId): Promise<any[]>

List collaborators of a specific ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket.

Returns

Promise<any[]>

An array of collaborators for the ticket.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const collaborators = await client.tickets.listCollaborators(7890);

Defined in

clients/core/tickets.d.ts:563


listIncidents

listIncidents(ticketId): Promise<any[]>

List incidents related to a specific ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket.

Returns

Promise<any[]>

An array of incidents related to the ticket.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const incidents = await client.tickets.listIncidents(7890);

Defined in

clients/core/tickets.d.ts:573


listMetrics

listMetrics(ticketId): Promise<object>

Retrieve metrics for a specific ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket.

Returns

Promise<object>

Metrics details for the ticket.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const metrics = await client.tickets.listMetrics(7890);

Defined in

clients/core/tickets.d.ts:583


listRecent

listRecent(): Promise<Ticket[]>

List recently viewed tickets by the requesting agent.

Returns

Promise<Ticket[]>

An array of recently viewed tickets.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const recentTickets = await client.tickets.listRecent();

Defined in

clients/core/tickets.d.ts:553


listWithFilter

listWithFilter(type, value): Promise<Ticket[]>

List tickets based on a specific filter.

Parameters

NameTypeDescription
typestringType of filter.
valuestring | numberValue for the filter.

Returns

Promise<Ticket[]>

An array of tickets matching the filter.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets

Example

ts
const filteredTickets = await client.tickets.listWithFilter('status', 'open');

Defined in

clients/core/tickets.d.ts:544


merge

merge(ticketId, mergedTicket): Promise<object>

Merge a ticket with another ticket.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to be merged.
mergedTicketobjectThe ticket object representing the ticket to merge with.

Returns

Promise<object>

A promise that resolves with the merged ticket object.

Async

Throws

If ticketId is not a valid ticket ID or mergedTicket is not a valid ticket object.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#merge-tickets

Example

ts
// Merge a ticket with another ticket
const sourceTicketId = 123;
const targetTicket = {
  subject: 'Merged Ticket',
  description: 'This is the merged ticket description.',
  // ...other ticket properties
};
const mergedTicket = await client.tickets.merge(sourceTicketId, targetTicket);

Defined in

clients/core/tickets.d.ts:723


on

on(eventType, callback): void

Parameters

NameType
eventTypeany
callbackany

Returns

void

Inherited from

Client.on

Defined in

clients/client.d.ts:96


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


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


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(ticketId): Promise<{ result: Ticket }>

Retrieve a specific ticket by its ID.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket.

Returns

Promise<{ result: Ticket }>

Details of the ticket.

Async

Throws

If the ticket ID is not provided or invalid.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket

Example

ts
const ticket = await client.tickets.show(12345);

Defined in

clients/core/tickets.d.ts:594


showMany

showMany(ticketIds): Promise<Ticket[]>

Retrieve details for multiple tickets based on their IDs.

Parameters

NameTypeDescription
ticketIdsnumber[]An array of ticket IDs to fetch.

Returns

Promise<Ticket[]>

An array of ticket details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-multiple-tickets

Example

ts
const ticketsDetails = await client.tickets.showMany([123, 456, 789]);

Defined in

clients/core/tickets.d.ts:606


update

update(ticketId, ticket): Promise<{ response: { audit: any[] ; ticket: Ticket } ; result: Ticket }>

Update an existing ticket by its ID.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to update.
ticketCreateOrUpdateTicketThe updated ticket data as an object.

Returns

Promise<{ response: { audit: any[] ; ticket: Ticket } ; result: Ticket }>

A promise that resolves to the updated ticket object.

Async

Throws

If ticketId is not a number or if ticket is not an object.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket

Example

ts
// Update an existing ticket
const updatedTicketData = {
  subject: 'Updated Ticket Subject',
  description: 'Updated Ticket Description',
};
const updatedTicket = await client.tickets.update(123, updatedTicketData);

Defined in

clients/core/tickets.d.ts:654


updateMany

updateMany(ticketIds, ticket): Promise<object>

Update multiple tickets by their IDs.

Parameters

NameTypeDescription
ticketIdsnumber[]An array of ticket IDs to update.
ticketobjectThe updated ticket data as an object.

Returns

Promise<object>

A promise that resolves to the updated ticket object.

Async

Throws

If ticketIds is not an array of numbers or if ticket is not an object.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-many-tickets

Example

ts
// Update multiple tickets by their IDs
const ticketIdsToUpdate = [123, 456, 789];
const updatedTicketData = {
  status: 'solved',
  priority: 'high',
};
const updatedTickets = await client.tickets.updateMany(ticketIdsToUpdate, updatedTicketData);

Defined in

clients/core/tickets.d.ts:678


updateTags

updateTags(ticketId, tags): Promise<void>

Replace tags on a specific ticket with new tags.

Parameters

NameTypeDescription
ticketIdnumberThe ID of the ticket to replace tags on.
tagsstring[]An array of new tags to replace the existing tags on the ticket.

Returns

Promise<void>

A promise that resolves when the tags are successfully replaced on the ticket.

Async

Throws

If ticketId is not a valid number or tags is not an array of strings.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#updating-tag-lists

Example

ts
// Replace tags on a specific ticket
const ticketId = 12345;
const newTags = ['newTag1', 'newTag2'];
await client.tickets.updateTags(ticketId, newTags);

Defined in

clients/core/tickets.d.ts:862

Released under the MIT License.