node-zendesk / Exports / clients/core/tickets / Tickets
Class: Tickets
clients/core/tickets.Tickets
See
https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/
Hierarchy
↳
Tickets
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- addTags
- create
- createMany
- delete
- deleteMany
- emit
- export
- exportAudit
- exportSample
- get
- getAll
- getComments
- incremental
- incrementalInclude
- incrementalSample
- list
- listAssigned
- listByOrganization
- listByUserCCD
- listByUserRequested
- listCollaborators
- listIncidents
- listMetrics
- listRecent
- listWithFilter
- merge
- on
- patch
- post
- put
- request
- requestAll
- requestUpload
- setSideLoad
- show
- showMany
- update
- updateMany
- updateTags
Constructors
constructor
• new Tickets(options
): Tickets
Parameters
Name | Type | Description |
---|---|---|
options | any | The client options. |
Returns
Constructs
Tickets
Overrides
Defined in
clients/core/tickets.d.ts:478
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/tickets.d.ts:479
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: { 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
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(ticketId
, tags
): Promise
<void
>
Add tags to a specific ticket.
Parameters
Name | Type | Description |
---|---|---|
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.
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
// 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
Name | Type | Description |
---|---|---|
ticket | CreateOrUpdateTicket | Details 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
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
Name | Type | Description |
---|---|---|
tickets | CreateManyTickets | An 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
// 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
Name | Type | Description |
---|---|---|
ticketId | number | The 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
// Delete a ticket by its ID
const ticketIdToDelete = 123;
await client.tickets.delete(ticketIdToDelete);
Overrides
Defined in
clients/core/tickets.d.ts:691
deleteMany
▸ deleteMany(ticketIds
): Promise
<void
>
Delete multiple tickets by their IDs.
Parameters
Name | Type | Description |
---|---|---|
ticketIds | number [] | 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
// 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
Name | Type |
---|---|
eventType | any |
eventData | any |
Returns
void
Inherited from
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
Name | Type | Description |
---|---|---|
startTime | string | The 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
// 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
Name | Type | Description |
---|---|---|
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.
Async
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: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
Name | Type | Description |
---|---|---|
startTime | string | The 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
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:755
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
getComments
▸ getComments(ticketId
): Promise
<any
[]>
Retrieve comments associated with a specific ticket.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
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:818
incremental
▸ incremental(startTime
): Promise
<any
[]>
DEPRECATED: Use the TicketExport
class method export
instead.
Export incremental tickets based on a specified start time.
Parameters
Name | Type | Description |
---|---|---|
startTime | string | The 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
// 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
Name | Type | Description |
---|---|---|
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.
Async
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: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
Name | Type | Description |
---|---|---|
startTime | string | The 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
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: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
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
Name | Type | Description |
---|---|---|
userID | number | The 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
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
Name | Type | Description |
---|---|---|
orgID | number | The 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
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
Name | Type | Description |
---|---|---|
userID | number | The 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
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
Name | Type | Description |
---|---|---|
userID | number | The 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
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
Name | Type | Description |
---|---|---|
ticketId | number | The 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
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
Name | Type | Description |
---|---|---|
ticketId | number | The 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
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
Name | Type | Description |
---|---|---|
ticketId | number | The 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
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
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
Name | Type | Description |
---|---|---|
type | string | Type of filter. |
value | string | number | Value 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
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
Name | Type | Description |
---|---|---|
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.
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
// 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
Name | Type |
---|---|
eventType | any |
callback | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:96
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
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
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(ticketId
): Promise
<{ result
: Ticket
}>
Retrieve a specific ticket by its ID.
Parameters
Name | Type | Description |
---|---|---|
ticketId | number | The 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
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
Name | Type | Description |
---|---|---|
ticketIds | number [] | 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
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
Name | Type | Description |
---|---|---|
ticketId | number | The ID of the ticket to update. |
ticket | CreateOrUpdateTicket | The 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
// 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
Name | Type | Description |
---|---|---|
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.
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
// 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
Name | Type | Description |
---|---|---|
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.
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
// 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