//native
type Codat = {
encodedKey: string
}
/**
* Initiate sync
* Initiate sync of pending transactions.
*/
export async function main(auth: Codat, companyId: string, body: { datasetIds?: string[] }) {
const url = new URL(`https://api.codat.io/companies/${companyId}/sync/expenses/syncs`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${auth.encodedKey}`
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago