//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Update a data attribute
*
You can update a data attribute.
> 🚧 Updating the data type is not possible
>
> It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.
*/
export async function main(
auth: Intercom,
id: string,
body: {
archived?: false | true
description?: string
options?: string[]
messenger_writable?: false | true
}
) {
const url = new URL(`https://api.intercom.io/data_attributes/${id}`)
const response = await fetch(url, {
method: 'PUT',
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