//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Create contact
* You can create a new contact (ie. user or lead).
*/
export async function main(auth: Intercom, body: {} | {} | {}) {
const url = new URL(`https://api.intercom.io/contacts`)
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