const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-chatobserver-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '<string>',
definition: {
schemaVersion: 2,
expression: {kind: 'literal', value: '<string>'},
currencyContext: {sourceCurrencyFieldId: '<string>', targetCurrency: '<string>'},
dateContext: {timeZone: '<string>', locale: '<string>'},
validationFixtures: [{expected: '<string>', name: '<string>', input: {}}]
},
description: null,
visibility: 'workspace',
publish: false
})
};
fetch('https://app.chatobserver.com/api/v2/metrics/definitions/{resourceType}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));