A webhook is a method for sending event notifications from one application to another. When something happens in a source system indicated by an event, the webhook transmits an event notification through HTTPS to a specific URL.
You can set up webhooks to receive notifications for order status updates.View repository
A data class that represents a webhook in the system.
Attributes
Attribute | Description |
---|---|
url | str The URL of the webhook. |
name | str The name of the webhook. |
events | List[str] 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 | Optional[str] The secret used to generate webhook signatures. |
id | Optional[str] The webhook ID. |
created_at | Optional[str] The timestamp when the webhook was created. |
updated_at | Optional[str] The timestamp when the webhook was last updated. |
# Select a webhookwebhook_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch webhook infowebhook = up42.Webhook.get(webhook_id=webhook_id)
# Define outputprint(f"ID: {webhook.id}")print(f"Name: {webhook.name}")print(f"URL: {webhook.url}")print(f"Active: {webhook.active}")print(f"Events: {webhook.events}")print(f"Created at: {webhook.created_at}")print(f"Updated at: {webhook.updated_at}")
Methods
Registers a created or updated webhook in the system.
# Instantiate a new webhookwebhook = up42.Webhook( name="My order status Webhook", url="https://example.com/my-webhook-callback", events=["order.status"], active=True, secret="secret-to-validate-payloads")
# Save the webhookwebhook.save()
# The object is updated with the server responseprint("\nWebhook created successfully:")print(f"ID: {webhook.id}")print(f"Name: {webhook.name}")print(f"URL: {webhook.url}")print(f"Active: {webhook.active}")print(f"Created at: {webhook.created_at}")
# Select an existing webhook that you want to updatewebhook_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch webhook infowebhook = up42.Webhook.get(webhook_id=webhook_id)
# Modify its attributeswebhook.name = "Test webhook"webhook.url = "https://example.com/my-webhook-callback"webhook.events=["order.status"]webhook.active = Falsewebhook.secret="secret-to-validate-payloads"
# Save the webhookwebhook.save()
# The object is updated with the server responseprint("\nWebhook updated successfully:")print(f"Updated at: {webhook.updated_at}")
Retrieves a specific webhook by its ID. Returns Webhook
.
Parameter | Description |
---|---|
webhook_id | str The webhook ID. |
# Select a webhookwebhook_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch webhook infowebhook = up42.Webhook.get(webhook_id=webhook_id)
Triggers 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. Returns dict
.
# Select a webhookwebhook_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch webhook infowebhook = up42.Webhook.get(webhook_id=webhook_id)
# Trigger the test eventstest_event_info = webhook.trigger_test_events()
# Define outputprint(test_event_info)
Deletes a registered webhook. Returns None
.
# Select a webhookwebhook_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch webhook infowebhook = up42.Webhook.get(webhook_id=webhook_id)
# Delete the webhookwebhook.delete()
Retrieves all available webhook events. Returns list[dict]
.
# Search for event typesevents = up42.Webhook.get_webhook_events()
# Define outputfor event in events: print(f"- Name: {event['name']}") print(f" Description: {event['description']}\n")
Retrieves all webhooks in your workspace. Returns List["Webhook"]
.
# Search for webhookswebhooks = up42.Webhook.all()
# Define outputfor webhook in webhooks: print(f"- ID: {webhook.id}") print(f" Name: {webhook.name}") print(f" URL: {webhook.url}") print(f" Active: {webhook.active}") print(f" Events: {', '.join(webhook.events)}\n")