0

Show content data export

by
Published Dec 20, 2024

You can view the status of your job by sending a `GET` request to the URL `https://api.

Script intercom Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Intercom = {
3
	apiVersion: string
4
	token: string
5
}
6
/**
7
 * Show content data export
8
 * You can view the status of your job by sending a `GET` request to the URL
9
`https://api.
10
 */
11
export async function main(auth: Intercom, job_identifier: string) {
12
	const url = new URL(`https://api.intercom.io/export/content/data/${job_identifier}`)
13

14
	const response = await fetch(url, {
15
		method: 'GET',
16
		headers: {
17
			'Intercom-Version': auth.apiVersion,
18
			Authorization: 'Bearer ' + auth.token
19
		},
20
		body: undefined
21
	})
22
	if (!response.ok) {
23
		const text = await response.text()
24
		throw new Error(`${response.status} ${text}`)
25
	}
26
	return await response.json()
27
}
28