const url = '/api/v2/saved-searches';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
body: JSON.stringify({
name: 'Production Errors',
sourceId: '507f1f77bcf86cd799439012',
select: 'Timestamp, ServiceName, Body',
where: 'SeverityText:ERROR',
whereLanguage: 'lucene',
orderBy: 'Timestamp DESC',
tags: ['production', 'errors'],
filters: [{type: 'sql', condition: 'ServiceName IN (\'checkout\', \'payments\')'}]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));