const url = 'https://api.channelautomation.com/api/analytics/export/csv';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
sql_query: 'SELECT id, name, email FROM contacts WHERE workspace_id = \'workspace-id\'',
filename: 'monthly_leads_report'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));