//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Create content data export
* To create your export job, you need to send a `POST` request to the export endpoint `https://api.
*/
export async function main(
auth: Intercom,
body: { created_at_after: number; created_at_before: number }
) {
const url = new URL(`https://api.intercom.io/export/content/data`)
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