//native
/**
* Add Ticket Tags
* Add tags to a ticket, keeping the ones it already has. Returns the ticket's full tag list.
*/
export async function main(
auth: RT.Zendesk,
ticket_id: number,
tags: string[]
) {
const response = await fetch(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/tags`,
{
method: "PUT",
headers: {
Authorization: auth.token
? `Bearer ${auth.token}`
: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ tags }),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago