//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Create a ticket type
* You can create a new ticket type.
> 📘 Creating ticket types.
>
> Every ticket type will be created with two default attributes: _default_title_ and _default_description_.
> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/)
*/
export async function main(
auth: Intercom,
body: {
name: string
description?: string
category?: 'Customer' | 'Back-office' | 'Tracker'
icon?: string
is_internal?: false | true
}
) {
const url = new URL(`https://api.intercom.io/ticket_types`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Intercom-Version': auth.apiVersion,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago