const url = 'https://app.messageport.com.au/api/v2/webhook-subscriptions/123';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json', Authorization: 'Basic <credentials>'},
body: JSON.stringify({
name: 'Inbound to CRM',
event: 'message_received',
url: 'https://example.com/hooks/inbound',
request_method: 'POST',
request_encoding_type: 'json',
headers: [{key: 'X-Api-Key', value: 'abc123'}]
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));