diff --git a/examples/webhook_navigation_blocked.py b/examples/webhook_navigation_blocked.py new file mode 100644 index 00000000..96014f09 --- /dev/null +++ b/examples/webhook_navigation_blocked.py @@ -0,0 +1,24 @@ +import os + +from examples import bb + +# An HTTPS endpoint you control, for example https://example.com/browserbase/events +WEBHOOK_ENDPOINT = os.environ["WEBHOOK_ENDPOINT"] + + +def run() -> None: + # Browserbase sends one event for each navigation a session's navigation policy blocks, + # with the session, the URL and when it was decided. Allowed navigations send none. + webhook = bb.webhooks.create( + endpoint=WEBHOOK_ENDPOINT, + event_types=["sessions.navigations.blocked"], + ) + print(f"Webhook {webhook.id} receives {', '.join(webhook.event_types)}") + + # The signing secret is returned only here and when it is rotated. Store it to verify + # the signature on every delivery. + print(f"Signing secret starts with {webhook.secret[:6]}") + + +if __name__ == "__main__": + run()