Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/webhook-navigation-blocked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Browserbase from '@browserbasehq/sdk';

const BROWSERBASE_API_KEY = process.env['BROWSERBASE_API_KEY']!;
// An HTTPS endpoint you control, for example https://example.com/browserbase/events
const WEBHOOK_ENDPOINT = process.env['WEBHOOK_ENDPOINT']!;

const bb = new Browserbase({
apiKey: BROWSERBASE_API_KEY,
});

(async () => {
// 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.
const webhook = await bb.webhooks.create({
endpoint: WEBHOOK_ENDPOINT,
eventTypes: ['sessions.navigations.blocked'],
});
console.log(`Webhook ${webhook.id} receives ${webhook.eventTypes.join(', ')}`);

// The signing secret is returned only here and when it is rotated. Store it to verify
// the signature on every delivery.
console.log(`Signing secret starts with ${webhook.secret.slice(0, 6)}`);
})().catch((error) => console.error(error.message));
Loading