Setting up your first webhook
Learn how to set up a webhook endpoint on your server which will listen to events sent from Mobile Text Alerts
4
Register your webhook
curl --location 'https://api.mobile-text-alerts.com/v3/webhooks' \
--header 'Authorization: Bearer 89fa747a-e01b-5940-99c2-4e96fa996258' \
--data-raw '{
"event": "delivery-status",
"url": "https://www.example.com/app/hooks",
"secret": "abc123-abc2-cde1-1234-xyz123456",
"alertEmail": "[email protected]",
"sendAlertEmail": true
}'async function main() {
const response = await fetch('https://api.mobile-text-alerts.com/v3/webhooks', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MTA_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
event: 'delivery-status',
url: 'https://www.example.com/app/hooks',
secret: 'abc123-abc2-cde1-1234-xyz123456',
alertEmail: '[email protected]',
sendAlertEmail: true
})
});
const data = await response.json();
console.log(data);
}
main().catch((err) => {
console.error('Request failed:', err);
process.exitCode = 1;
});{
"message": "Webhook 11 created successfully.",
"data": {
"id": 11,
"event": "delivery-status",
"url": "https://www.example.com/app/hooks",
"alertEmail": "[email protected]",
"sendAlertEmail": true,
"skipErrors": false,
"skipErrorCodes": [],
"retryOnError": true,
"maxThroughputPerMinute": 600,
"createdAt": "2022-04-18T05:00:00.000Z"
}
}Last updated
Was this helpful?