//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Redact a conversation part
* You can redact a conversation part or the source message of a conversation (as seen in the source object).
{% admonition type="info" name="Redacting parts and messages" %}
If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met.
{% /admonition %}
*/
export async function main(
auth: Intercom,
body:
| {
type: 'conversation_part'
conversation_id: string
conversation_part_id: string
}
| { type: 'source'; conversation_id: string; source_id: string }
) {
const url = new URL(`https://api.intercom.io/conversations/redact`)
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