node-zendesk • Docs
node-zendesk / clients/core/tickets / Tickets
Class: Tickets
Client for the Zendesk API - Tickets.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/
Extends
Constructors
new Tickets()
new Tickets(
options
):Tickets
Parameters
• options: ZendeskClientOptions
The client options.
Returns
Overrides
Defined in
clients/core/tickets.d.ts:480
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/tickets.d.ts:481
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
[]
Defined in
clients/core/tickets.d.ts:482
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(
ticketId
,tags
):Promise
<void
>
Add tags to a specific ticket.
Parameters
• ticketId: number
The ID of the ticket to add tags to.
• tags: string
[]
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.
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
// 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:848
create()
create(
ticket
):Promise
<object
>
Create a new ticket.
Parameters
• ticket: CreateOrUpdateTicket
Details of the ticket to be created.
Returns
Promise
<object
>
The created ticket details.
response
response:
object
result
result:
Ticket
Throws
If the ticket details are not provided or invalid.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket
Example
const newTicket = await client.tickets.create({ subject: 'New ticket', description: 'Ticket description' });
Defined in
clients/core/tickets.d.ts:613
createMany()
createMany(
tickets
):Promise
<object
>
Create multiple new tickets.
Parameters
• tickets: CreateManyTickets
An object of tickets containing an array of tickets.
Returns
Promise
<object
>
A promise that resolves to an array of created ticket objects.
response
response:
object
result
result:
Ticket
[]
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
// 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:633
delete()
delete(
ticketId
):Promise
<void
>
Delete a ticket by its ID.
Parameters
• ticketId: number
The ID of the ticket to delete.
Returns
Promise
<void
>
A promise that resolves when the ticket is successfully deleted.
Throws
If ticketId
is not a number or is not provided.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket
Example
// Delete a ticket by its ID
const ticketIdToDelete = 123;
await client.tickets.delete(ticketIdToDelete);
Overrides
Defined in
clients/core/tickets.d.ts:690
deleteMany()
deleteMany(
ticketIds
):Promise
<void
>
Delete multiple tickets by their IDs.
Parameters
• ticketIds: number
[]
An array of ticket IDs to delete.
Returns
Promise
<void
>
A promise that resolves when the tickets are successfully deleted.
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
// Delete multiple tickets by their IDs
const ticketIdsToDelete = [123, 456, 789];
await client.tickets.deleteMany(ticketIdsToDelete);
Defined in
clients/core/tickets.d.ts:702
emit()
emit(
eventType
,eventData
):void
Parameters
• eventType: any
• eventData: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:43
export()
export(
startTime
):Promise
<object
>
DEPRECATED: Use the TicketExport
class method export
instead.
Export tickets based on a specified start time.
Parameters
• startTime: string
The start time for exporting tickets.
Returns
Promise
<object
>
A promise that resolves with the exported tickets.
response
response:
object
result
result:
object
Throws
If startTime
is not a valid string.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export
Example
// 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:738
exportAudit()
exportAudit(
ticketId
):Promise
<any
[]>
Retrieve audits associated with a specific ticket. (Deprecated: Use TicketAudits class list method instead)
Parameters
• ticketId: number
The ID of the ticket to retrieve audits for.
Returns
Promise
<any
[]>
A promise that resolves with an array of audits associated with the ticket.
Throws
If ticketId
is not a valid number.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#listing-ticket-audits
Example
// 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:834
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
• startTime: string
The start time for exporting the sample of tickets.
Returns
Promise
<object
>
A promise that resolves with the exported sample of tickets.
response
response:
object
result
result:
object
Throws
If startTime
is not a valid string.
See
Example
// 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:756
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
getComments()
getComments(
ticketId
):Promise
<any
[]>
Retrieve comments associated with a specific ticket.
Parameters
• ticketId: number
The ID of the ticket to retrieve comments for.
Returns
Promise
<any
[]>
A promise that resolves with an array of comments associated with the ticket.
Throws
If ticketId
is not a valid number.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/
Example
// Retrieve comments for a specific ticket
const ticketId = 12345;
const comments = await client.tickets.getComments(ticketId);
Defined in
clients/core/tickets.d.ts:821
incremental()
incremental(
startTime
):Promise
<any
[]>
DEPRECATED: Use the TicketExport
class method export
instead.
Export incremental tickets based on a specified start time.
Parameters
• startTime: string
The start time for exporting incremental tickets.
Returns
Promise
<any
[]>
A promise that resolves with an array of exported incremental tickets.
Throws
If startTime
is not a valid string.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental
Example
// 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:774
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
• startTime: string
The start time for exporting incremental tickets.
• include: string
Optional parameters to include in the export.
Returns
Promise
<any
[]>
A promise that resolves with an array of exported incremental tickets.
Throws
If startTime
is not a valid string.
See
Example
// 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:791
incrementalSample()
incrementalSample(
startTime
):Promise
<object
>
DEPRECATED: Use the TicketExport
class method sample
instead.
Export a sample of incremental tickets based on a specified start time.
Parameters
• startTime: string
The start time for exporting the sample of incremental tickets.
Returns
Promise
<object
>
A promise that resolves with an array of exported incremental tickets.
response
response:
object
result
result:
Ticket
[]
Throws
If startTime
is not a valid string.
See
Example
// 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:806
list()
list():
Promise
<Ticket
[]>
List all the tickets.
Returns
Promise
<Ticket
[]>
An array of tickets.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const tickets = await client.tickets.list();
Defined in
clients/core/tickets.d.ts:494
listAssigned()
listAssigned(
userID
):Promise
<Ticket
[]>
List all tickets assigned to a specific user.
Parameters
• userID: number
The ID of the user.
Returns
Promise
<Ticket
[]>
An array of tickets assigned to the user.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
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
• orgID: number
The ID of the organization.
Returns
Promise
<Ticket
[]>
An array of tickets under the organization.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const orgTickets = await client.tickets.listByOrganization(6789);
Defined in
clients/core/tickets.d.ts:512
listByUserCCD()
listByUserCCD(
userID
):Promise
<Ticket
[]>
List all tickets where a specific user is CC'd.
Parameters
• userID: number
The ID of the user.
Returns
Promise
<Ticket
[]>
An array of tickets where the user is CC'd.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const ccdTickets = await client.tickets.listByUserCCD(12345);
Defined in
clients/core/tickets.d.ts:530
listByUserRequested()
listByUserRequested(
userID
):Promise
<Ticket
[]>
List all tickets requested by a specific user.
Parameters
• userID: number
The ID of the user.
Returns
Promise
<Ticket
[]>
An array of tickets requested by the user.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const requestedTickets = await client.tickets.listByUserRequested(12345);
Defined in
clients/core/tickets.d.ts:521
listCollaborators()
listCollaborators(
ticketId
):Promise
<any
[]>
List collaborators of a specific ticket.
Parameters
• ticketId: number
The ID of the ticket.
Returns
Promise
<any
[]>
An array of collaborators for the ticket.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const collaborators = await client.tickets.listCollaborators(7890);
Defined in
clients/core/tickets.d.ts:557
listIncidents()
listIncidents(
ticketId
):Promise
<any
[]>
List incidents related to a specific ticket.
Parameters
• ticketId: number
The ID of the ticket.
Returns
Promise
<any
[]>
An array of incidents related to the ticket.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const incidents = await client.tickets.listIncidents(7890);
Defined in
clients/core/tickets.d.ts:566
listMetrics()
listMetrics(
ticketId
):Promise
<object
>
Retrieve metrics for a specific ticket.
Parameters
• ticketId: number
The ID of the ticket.
Returns
Promise
<object
>
Metrics details for the ticket.
response
response:
object
result
result:
Ticket
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const metrics = await client.tickets.listMetrics(7890);
Defined in
clients/core/tickets.d.ts:575
listRecent()
listRecent():
Promise
<Ticket
[]>
List recently viewed tickets by the requesting agent.
Returns
Promise
<Ticket
[]>
An array of recently viewed tickets.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const recentTickets = await client.tickets.listRecent();
Defined in
clients/core/tickets.d.ts:548
listWithFilter()
listWithFilter(
type
,value
):Promise
<Ticket
[]>
List tickets based on a specific filter.
Parameters
• type: string
Type of filter.
• value: string
| number
Value for the filter.
Returns
Promise
<Ticket
[]>
An array of tickets matching the filter.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
Example
const filteredTickets = await client.tickets.listWithFilter('status', 'open');
Defined in
clients/core/tickets.d.ts:540
merge()
merge(
ticketId
,mergedTicket
):Promise
<object
>
Merge a ticket with another ticket.
Parameters
• ticketId: number
The ID of the ticket to be merged.
• mergedTicket: object
The ticket object representing the ticket to merge with.
Returns
Promise
<object
>
A promise that resolves with the merged ticket object.
response
response:
object
result
result:
Ticket
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
// 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:720
on()
on(
eventType
,callback
):void
Parameters
• eventType: any
• callback: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:44
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
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
setSideLoad()
setSideLoad(
array
):void
Parameters
• array: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:61
show()
show(
ticketId
):Promise
<object
>
Retrieve a specific ticket by its ID.
Parameters
• ticketId: number
The ID of the ticket.
Returns
Promise
<object
>
Details of the ticket.
response
response:
object
result
result:
Ticket
Throws
If the ticket ID is not provided or invalid.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket
Example
const ticket = await client.tickets.show(12345);
Defined in
clients/core/tickets.d.ts:588
showMany()
showMany(
ticketIds
):Promise
<object
>
Retrieve details for multiple tickets based on their IDs.
Parameters
• ticketIds: number
[]
An array of ticket IDs to fetch.
Returns
Promise
<object
>
An array of ticket details.
response
response:
object
result
result:
Ticket
[]
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-multiple-tickets
Example
const ticketsDetails = await client.tickets.showMany([123, 456, 789]);
Defined in
clients/core/tickets.d.ts:600
update()
update(
ticketId
,ticket
):Promise
<object
>
Update an existing ticket by its ID.
Parameters
• ticketId: number
The ID of the ticket to update.
• ticket: CreateOrUpdateTicket
The updated ticket data as an object.
Returns
Promise
<object
>
A promise that resolves to the updated ticket object.
response
response:
object
response.audit
audit:
any
[]
response.ticket
ticket:
Ticket
result
result:
Ticket
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
// 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:652
updateMany()
updateMany(
ticketIds
,ticket
):Promise
<object
>
Update multiple tickets by their IDs.
Parameters
• ticketIds: number
[]
An array of ticket IDs to update.
• ticket: object
The updated ticket data as an object.
Returns
Promise
<object
>
A promise that resolves to the updated ticket object.
response
response:
object
result
result:
object
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
// 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:675
updateTags()
updateTags(
ticketId
,tags
):Promise
<void
>
Replace tags on a specific ticket with new tags.
Parameters
• ticketId: number
The ID of the ticket to replace tags on.
• tags: string
[]
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.
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
// 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