Skip to main content
Preview
Preview Feature — This feature is currently in preview and under active development. APIs and functionality may change. We recommend testing thoroughly before using in production.

Managing Webhook Events

Ductape allows you to handle webhook events efficiently. Each webhook serves as a single point of registration for multiple events emitted by your app. You can define multiple events within a webhook that your partners or internal systems will receive.

Setting Up Webhook Events​

To create a webhook event in Ductape, use the create function from the app.webhook.event interface.

Example​

const event = await ductape.app.webhook.event.create({
name: "New Event",
tag: "new-webhook:new-event",
description: "Notify customer of great things",
selector: "$Event{identifier}",
sample: {
event: "new-transaction",
transaction_id: "1229100110101-192920101",
event_id: "119100101020201-1919010101"
}
});

Webhook Event Fields​

FieldTypeRequiredDescription
namestringYesA human-readable name for the webhook event.
tagstringYesA unique identifier combining the webhook and event (webhook-tag:event-tag).
descriptionstringYesA brief explanation of the event's purpose.
selectorstringYesThe key path used to identify the event type from incoming payloads. Must start with $Event{} e.g. $Event{event}.
sampleRecord<string, unknown>YesA sample payload structure for testing and documentation.

Sample Payload Example​

{
"event": "new-transaction",
"transaction_id": "1229100110101-192920101",
"event_id": "119100101020201-1919010101",
"customer_email": "janedoe@company.com",
"amount": 5000,
"currency": "USD",
"metadata": {
"source": "mobile-app"
}
}

Updating Webhook Events​

To update a webhook event, use the update function from the app.webhook.event interface.

Example​

const updatedEvent = await ductape.app.webhook.event.update("new-webhook:new-event", {
sample: {
event: "new-transaction",
transaction_id: "1229100110101-192920101",
event_id: "119100101020201-1919010101",
username: "Jane Jameson"
}
});

Fetching Webhook Events​

To retrieve all events registered under a webhook, use the fetchAll function.

Example​

const events = await ductape.app.webhook.event.fetchAll("new-webhook");

Fetching a Single Webhook Event​

To retrieve a specific webhook event, use the fetch function, passing the event tag.

Example​

const event = await ductape.app.webhook.event.fetch("new-webhook:new-event");

See Also​