The Webhook data class allows you to create, view, test, and modify webhooks to create custom event notifications.
Webhook class attributes
Attribute | Description |
---|---|
url | str | required The URL of the webhook. |
name | str | required The name of the webhook. |
events | list[str] | required A list of events that trigger the webhook. To view the list of possible values, use get_webhook_events . |
active | bool Whether this webhook should be active after the update:
False . |
secret | str The secret used to generate webhook signatures. |
id | str The webhook ID. |
created_at | str The timestamp when the webhook was created. |
updated_at | str The timestamp when the webhook was last updated. |
Webhook class properties
Property | Description |
---|---|
info | dict | deprecated A dictionary representation of webhook attributes. |
webhook_id | str | deprecated The webhook ID. Use the id attribute instead. |
The all
class method allows you to view all webhooks in your workspace.
The returned data type is List["Webhook"]
.
An example with all
Python
up42.Webhook.all()
The delete
instance method allows you to delete a registered webhook.
An example with delete
Python
webhook = up42.Webhook.get(webhook_id="d290f1ee-6c54-4b01-90e6-d701748f0851")
webhook.delete()
The get
class method allows you to retrieve a specific webhook by its ID.
The returned data type is Webhook
.
An example with get
Python
up42.Webhook.get(webhook_id="d290f1ee-6c54-4b01-90e6-d701748f0851")
The get_webhook_events
class method returns all available webhook events.
The returned data type is list[dict]
.
An example with get_webhook_events
Python
up42.Webhook.get_webhook_events()
The save
instance method allows you to register a created or updated webhook in the system.
An example with save
Python
webhook = up42.Webhook(
name="A webhook for order updates",
url="https://receiving-url.com",
events=["order.status"],
active=True
)
webhook.save()
The trigger_test_events
instance method allows you to trigger a webhook test event to test your receiving side. The UP42 server will send test messages for each subscribed event to the specified webhook URL.
The returned data type is dict
.
An example with trigger_test_events
Python
webhook = up42.Webhook.get(webhook_id="d290f1ee-6c54-4b01-90e6-d701748f0851")
webhook.trigger_test_events()
The update
instance method allows you to modify a specific webhook.
The returned data type is dict
.
An example with update
Python
webhook = up42.Webhook.get(webhook_id="d290f1ee-6c54-4b01-90e6-d701748f0851")
webhook.update(
name="new-name",
url="https://new-receiving-url.com",
events=["order.status"],
active=True,
secret="RFZTJnNAChqZKNmo",
)