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 endpoint for the webhook.
Array of trigger events for the webhook.
The unique identifier for the webhook.
Alias used to refer to the webhook configuration.
API the webhook subscribes to—com for the store API.
Determines whether the webhook is enabled. Defaults to false.
Indicates whether the webhook was automatically disabled. This occurs when the webhook has failed for 4 days with no successful delivery in that time.
Determines whether the webhook retries disabled events.
The number of failed webhook attempts.
The date of the webhook's first failed attempt.
Date of the last successful webhook delivery.
The date of the last warning for a failed attempt.
The final attempt for a webhook after continuous failed attempts. Webhooks are disabled after failing for 4 days with no successful delivery.
const { swell } = require('swell-node');
swell.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"
}