node-zendesk • Docs
node-zendesk / clients/core/macros / Macros
Class: Macros
The Macros class provides methods for interacting with the Zendesk Macros API.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/ Zendesk Macros API
Extends
Constructors
new Macros()
new Macros(
options
):Macros
Parameters
• options: any
Returns
Overrides
Defined in
clients/core/macros.d.ts:6
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/macros.d.ts:7
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
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
apply()
apply(
macroID
):Promise
<object
>
Applies a macro to a ticket.
Parameters
• macroID: number
The ID of the macro.
Returns
Promise
<object
>
- A promise that resolves to the applied macro's result.
response
response:
object
result
result:
object
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro-replica
Example
const result = await client.macros.apply(12345);
Defined in
clients/core/macros.d.ts:74
applyTicket()
applyTicket(
ticketID
,macroID
):Promise
<object
>
Creates a macro representation derived from a ticket.
Parameters
• ticketID: number
The ID of the ticket from which to build a macro replica.
• macroID: number
The ID of the macro.
Returns
Promise
<object
>
- A promise that resolves to the macro replica.
response
response:
object
result
result:
object
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro-replica
Example
const replica = await client.macros.applyTicket(12345, 67890);
Defined in
clients/core/macros.d.ts:88
categories()
categories():
Promise
<object
>
Lists all macro categories available to the current user.
Returns
Promise
<object
>
- A promise that resolves to a list of macro categories.
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macro-categories
Example
const macroCategories = await client.macros.categories();
Defined in
clients/core/macros.d.ts:125
create()
create(
macro
):Promise
<object
>
Creates a new macro.
Parameters
• macro
The macro object containing necessary values.
• macro.actions: object
[]
List of actions that the macro will perform.
• macro.active?: boolean
Whether the macro is active.
• macro.description?: string
The description of the macro.
• macro.title: string
The title of the macro.
Returns
Promise
<object
>
- A promise that resolves to the created macro.
response
response:
object
result
result:
object
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#create-macro
Example
const newMacro = await client.macros.create({
title: "Test Macro",
actions: [{ field: "status", value: "solved" }]
});
Defined in
clients/core/macros.d.ts:108
delete()
delete(
macroID
):Promise
<void
>
Deletes a specified macro.
Parameters
• macroID: number
The ID of the macro to delete.
Returns
Promise
<void
>
- A promise indicating successful deletion.
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#delete-macro
Example
await client.macros.delete(12345);
Overrides
Defined in
clients/core/macros.d.ts:151
emit()
emit(
eventType
,eventData
):void
Parameters
• eventType: any
• eventData: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:43
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
list()
list():
Promise
<any
[]>
Lists all shared and personal macros available to the current user.
Returns
Promise
<any
[]>
Returns a promise that resolves to an array of macros.
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros Zendesk List Macros API
Example
const macros = await client.macros.list();
Defined in
clients/core/macros.d.ts:16
listActive()
listActive():
Promise
<object
>
Lists all active macros.
Returns
Promise
<object
>
- A promise that resolves to a list of active macros.
response
response:
object
result
result:
object
[]
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-active-macros
Example
const activeMacros = await client.macros.listActive();
Defined in
clients/core/macros.d.ts:51
listByParams()
listByParams(
parameters
):Promise
<object
>
Lists macros based on provided parameters.
Parameters
• parameters: object
The filtering parameters.
Returns
Promise
<object
>
- A promise that resolves to a list of macros.
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros
Example
const macros = await client.macros.listByParams({ active: true });
Defined in
clients/core/macros.d.ts:64
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
search()
search(
query
):Promise
<object
>
Searches for macros based on provided query.
Parameters
• query: string
The search query string.
Returns
Promise
<object
>
- A promise that resolves to a list of matched macros.
response
response:
object
result
result:
object
[]
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#search-macros
Example
const matchedMacros = await client.macros.search("priority:urgent");
Defined in
clients/core/macros.d.ts:39
setSideLoad()
setSideLoad(
array
):void
Parameters
• array: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:61
show()
show(
macroID
):Promise
<object
>
Retrieves details of a specific macro.
Parameters
• macroID: number
The ID of the macro to retrieve.
Returns
Promise
<object
>
Returns a promise that resolves to the macro's details.
response
response:
object
result
result:
object
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro Zendesk Show Macro API
Example
const macroDetails = await client.macros.show(123);
Defined in
clients/core/macros.d.ts:26
update()
update(
macroID
,macro
):Promise
<object
>
Updates an existing macro.
Parameters
• macroID: number
The ID of the macro to update.
• macro: object
The updates to apply to the macro.
Returns
Promise
<object
>
- A promise that resolves to the updated macro.
response
response:
object
result
result:
object
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#update-macro
Example
const updatedMacro = await client.macros.update(12345, {
title: "Updated Macro Title"
});
Defined in
clients/core/macros.d.ts:138
updateMany()
updateMany(
macrosUpdates
):Promise
<object
>
Updates multiple macros.
Parameters
• macrosUpdates: object
[]
An array of macro update objects.
Returns
Promise
<object
>
- A promise that resolves to an array of updated macros.
response
response:
object
result
result:
object
[]
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#update-many-macros
Example
const updatedMacros = await client.macros.updateMany([
{ id: 12345, title: "Updated Macro One" },
{ id: 67890, title: "Updated Macro Two" }
]);
Defined in
clients/core/macros.d.ts:164