Backend API
When setting up webhooks for custom models, you will need to create them via the API referencing the events listed on the custom model. For webhooks that utilize Swell's standard models, we recommend configuration through the Swell dashboard under Developer tools > Webhooks—each standard model's events are easily referenced within the UI.
Arguments
url
stringrequiredURL endpoint for the webhook.
events
array of stringrequiredArray of trigger events for the webhook.
id
objectIdautoThe unique identifier for the webhook.
alias
stringAlias used to refer to the webhook configuration.
enabled
booleanDetermines whether the webhook is enabled. Defaults to false.
auto_disabled
booleanautoIndicates whether the webhook was automatically disabled. This occurs seven days after the first failed attempt and no subsequent successes.
retry_disabled_events
booleanDetermines whether the webhook retries disabled events.
attempts_failed
intDisplays the number failed webhook attempts.
date_first_failed
dateautoThe date the webhook's first failed attempt.
date_last_warned
dateautoThe date of the last warning for a failed attempt.
date_final_attempt
dateThe final attempt for a webhook after continuous failed attempts. Webhooks are disabled 7 days after the first failed attempt.
schedule
objectSchedule for specifying when a webhook is to be fired.
schedule.hour
intThe hour for which to fire the webhook. Min 0, max 23.
schedule.month_day
intThe day of the month for which to fire the webhook. Min 1, max 31.
schedule.month
intThe month for which to fire the webhook. Min 1, max 12.
schedule.week_day
intThe month for which to fire the webhook. Min 0, max 6.
date_scheduled
dateDate for which the webhook is scheduled to fire.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/:webhooks', {
"url":"http://localhost:5000",
"events":[
"order.created",
"order.submitted"
],
});
The webhook model
{
"url": "http://localhost:5000",
"enabled": false,
"alias": "webhook",
"description": null,
"events": [
"order.created",
"order.submitted",
"order.updated"
],
"api": "com",
"date_final_attempt": null,
"date_scheduled": null,
"date_created": "2021-09-27T16:30:11.837Z",
"date_updated": "2021-10-28T16:04:21.648Z",
"id": "6151f193ae97e82ccbf6f0a7"
}