Files
browser-use/docs/cloud/v1/webhooks.mdx
Magnus Müller de0488031d Squashed commit of the following:
commit 92d1732a40
Merge: fa4ff47a efcd2b33
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:18:35 2025 -0700

    Merge main

commit fa4ff47ae4
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:03:04 2025 -0700

    Laminar info mode

commit 8625aa9ba9
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:54 2025 -0700

    Default to flash for browser use llm

commit 69a517ad7c
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:44 2025 -0700

    Update example

commit c91467c51d
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:15 2025 -0700

    Update example

commit 4e2b3f1306
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:54:05 2025 -0700

    Linter

commit e8d6936a47
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:53:43 2025 -0700

    Example

commit 961d6fc451
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:52:23 2025 -0700

    Update default links

commit 0b2853859b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:44:59 2025 -0700

    Default fast fasle

commit 9d67594b63
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 22:01:24 2025 -0700

    Simplify

commit f5712bdec0
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:45:00 2025 -0700

    Parsing json

commit 503af624dd
Merge: ef7fa1e4 0d2522b1
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:04:31 2025 -0700

    Merge branch 'flat-output' of https://github.com/browser-use/browser-use into flat-output

commit ef7fa1e401
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:04:28 2025 -0700

    Add prompt description handling for browser-use cloud service

    - Enhanced the Agent class to generate and pass prompt descriptions to the LLM when using the browser-use provider.
    - Updated the ChatBrowserUse class to accept an optional prompt_description parameter in the ainvoke method.
    - Modified the tracked_ainvoke function in TokenCost to forward additional keyword arguments.
    - Adjusted example model to initialize Laminar for tracing.

commit 0d2522b1f9
Author: Gregor Žunič <36313686+gregpr07@users.noreply.github.com>
Date:   Tue Oct 7 20:23:39 2025 -0700

    updated default base url

commit 0a2e6d6520
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:50:56 2025 -0700

    Hide api key

commit 96bba9692b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:49:05 2025 -0700

    Add env var loading and validation to ChatBrowserUse, update example

commit c2e57a3bab
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:36:31 2025 -0700

    Linter

commit 3d4cc1dbec
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:28:10 2025 -0700

    Rename

commit 14ab0b75fe
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:21:52 2025 -0700

    Rename super_fast to fast parameter in ChatBrowserUse

commit 7fab3c47d3
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:08:10 2025 -0700

    Update system prompt

commit 2066e77b98
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:07:51 2025 -0700

    Del claude file

commit 297b767e91
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:01:50 2025 -0700

    Revert flash system prompt to JSON format

    - Reverted system_prompt_flash.md to main (JSON format)
    - Added examples/models/browser_use_cloud.py for llm-use cloud service
    - llm-use service will inject unstructured format on the server side

commit 99af55f8e9
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:58:40 2025 -0700

    Example

commit 657ff0d352
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:54:23 2025 -0700

    Remove unused

commit a42123d8e5
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:49:54 2025 -0700

    ignore

commit de4fe19020
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:48:01 2025 -0700

    Example

commit 27e5ab9947
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 14:29:01 2025 -0700

    Add llm-use cloud client example

    - ChatLLMUseCloud: Browser-use compatible client for llm-use service
    - Implements BaseChatModel protocol with proper typing
    - Includes credit checking before/after tasks
    - Error handling for 401/402/500 responses
    - Converts messages between browser-use and HTTP API formats
    - Returns ChatInvokeCompletion with usage stats

    Usage:
      export LLM_USE_URL='https://your-app.railway.app'
      export LLM_USE_API_KEY='your-key'
      python examples/llm_use_cloud_client.py

commit a47a448005
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 13:03:59 2025 -0700

    Enhance response parsing in ChatBrowserUse to handle structured data from the API, including debug logging for received data keys.

commit e79c7dc633
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 19:39:29 2025 -0700

    Include browser-use llm

commit 584d977154
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 17:55:31 2025 -0700

    Linter

commit b0ac87076a
Merge: 1183b8fe 0076775f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 15:01:37 2025 -0700

    merge main

commit 1183b8fe6b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:26:34 2025 -0700

    Fix done output action model

commit 852449b1bc
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:23:31 2025 -0700

    More debug info

commit a57ba25d36
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:07:15 2025 -0700

    Multiline parser

commit 2153dbe6aa
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:50:14 2025 -0700

    Fix custom output

commit ec5c08ba0f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:36:54 2025 -0700

    Fix files in output

commit 7444048e8f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:28:09 2025 -0700

    Update codebase with unstructured output

commit a8f05b4611
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 14:55:20 2025 -0700

    Save systemprompt

commit d7d112c569
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 14:51:24 2025 -0700

    new parser
2025-10-08 08:39:24 -07:00

146 lines
5.1 KiB
Plaintext

---
title: "Webhooks"
description: "Learn how to integrate webhooks with Browser Use Cloud API"
icon: "code"
mode: "wide"
---
Webhooks allow you to receive real-time notifications about events in your Browser Use tasks. This guide will show you how to set up and verify webhook endpoints.
## Prerequisites
<Note>
You need an active subscription to create webhooks. See your billing page
[cloud.browser-use.com/dashboard/billing](https://cloud.browser-use.com/dashboard/billing)
</Note>
## Setting Up Webhooks
To receive webhook notifications, you need to:
1. Create an endpoint that can receive HTTPS POST requests
2. Configure your webhook URL in the Browser Use dashboard
3. Implement signature verification to ensure webhook authenticity
<Note>
When adding a webhook URL in the dashboard, it must be a valid HTTPS URL that can receive POST requests.
On creation, we will send a test payload `{"type": "test", "timestamp": "2024-03-21T12:00:00Z", "payload": {"test": "ok"}}` to verify the endpoint is working correctly before creating the actual webhook!
</Note>
## Webhook Events
Browser Use sends various types of events. Each event has a specific type and payload structure.
### Event Types
Currently supported events:
| Event Type | Description |
| -------------------------- | -------------------------------- |
| `agent.task.status_update` | Status updates for running tasks |
### Task Status Updates
The `agent.task.status_update` event includes the following statuses:
| Status | Description |
| -------------- | -------------------------------------- |
| `initializing` | A task is initializing |
| `started` | A Task has started (browser available) |
| `paused` | A task has been paused mid execution |
| `stopped` | A task has been stopped mid execution |
| `finished` | A task has finished |
## Webhook Payload Structure
Each webhook call includes:
- A JSON payload with event details
- `X-Browser-Use-Timestamp` header with the current timestamp
- `X-Browser-Use-Signature` header for verification
The payload follows this structure:
```json
{
"type": "agent.task.status_update",
"timestamp": "2025-05-25T09:22:22.269116+00:00",
"payload": {
"session_id": "cd9cc7bf-e3af-4181-80a2-73f083bc94b4",
"task_id": "5b73fb3f-a3cb-4912-be40-17ce9e9e1a45",
"status": "finished",
"metadata": {
"campaign": "q4-automation",
"team": "marketing"
}
}
}
```
The webhook payload now includes a `metadata` field containing any custom key-value pairs that were provided when the task was created. This allows you to correlate webhook events with your internal tracking systems.
## Implementing Webhook Verification
To ensure webhook authenticity, you must verify the signature. Here's an example implementation in Python using FastAPI:
```python
import uvicorn
import hmac
import hashlib
import json
import os
from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
SECRET_KEY = os.environ['SECRET_KEY']
def verify_signature(payload: dict, timestamp: str, received_signature: str) -> bool:
message = f'{timestamp}.{json.dumps(payload, separators=(",", ":"), sort_keys=True)}'
expected_signature = hmac.new(SECRET_KEY.encode(), message.encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(expected_signature, received_signature)
@app.post('/webhook')
async def webhook(request: Request):
body = await request.json()
timestamp = request.headers.get('X-Browser-Use-Timestamp')
signature = request.headers.get('X-Browser-Use-Signature')
if not timestamp or not signature:
raise HTTPException(status_code=400, detail='Missing timestamp or signature')
if not verify_signature(body, timestamp, signature):
raise HTTPException(status_code=403, detail='Invalid signature')
# Handle different event types
event_type = body.get('type')
if event_type == 'agent.task.status_update':
# Handle task status update
print('Task status update received:', body['payload'])
elif event_type == 'test':
# Handle test webhook
print('Test webhook received:', body['payload'])
else:
print('Unknown event type:', event_type)
return {'status': 'success', 'message': 'Webhook received'}
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8080)
```
## Best Practices
1. **Always verify signatures**: Never process webhook payloads without verifying the signature
2. **Handle retries**: Browser Use will retry failed webhook deliveries up to 5 times
3. **Respond quickly**: Return a 200 response as soon as you've verified the signature
4. **Process asynchronously**: Handle the webhook payload processing in a background task
5. **Monitor failures**: Set up monitoring for webhook delivery failures
6. **Handle unknown events**: Implement graceful handling of new event types that may be added in the future
<Note>
Need help? Contact our support team at support@browser-use.com or join our
[Discord community](https://link.browser-use.com/discord)
</Note>