Observe
POST/workstations/:workstation_id/browser/operator/observe
Observe the current page and provide a detailed description of the page content. This endpoint can be used to make assertions about the page state or get detailed information about what is currently visible.
Key Features
- Natural language assertions about page content
- Detailed page state descriptions
- Visual element verification
- Content validation
- State checking
Example Usage
// Make assertions about page content
const id = 'HvcqZjmeoPtP';
const url = `https://api.agentstation.ai/v1/workstations/${id}/browser/operator/observe`;
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify({
observation: 'The price of "Sauce Labs Onesie" is 7.99',
})
});
Best Practices
- Use specific assertions to verify exact values or states
- Include clear error messages for failed assertions
- Consider using extract endpoint for structured data validation
- Use observation mode for general page state analysis
- For critical assertions, combine with structured data extraction to prevent AI hallucinations:
// Instead of simple assertion:
const response = await fetch(url, \{
method: 'POST',
body: JSON.stringify(\{
assertion: 'The price of "Sauce Labs Onesie" is 7.99'
\})
\});
// Response: \{ observation: true, message: "Found product 'Sauce Labs Onesie' with price $7.99 as expected" \}
// More reliable approach using extract + JavaScript assertions:
const url = `https://api.agentstation.ai/v1/workstations/${id}/browser/operator/extract`;
const extractResponse = await fetch(url, \{
method: 'POST',
body: JSON.stringify(\{
object: \{
products: "product list with name and price, \{name: string, price: number\}[]"
\}
\})
\}
);
const data = await extractResponse.json();
// Response: \{ products: [\{ name: "Sauce Labs Onesie", price: 7.99 \}, ...] \}
const onesieItem = data.products.find(item => item.name === 'Sauce Labs Onesie');
if (!onesieItem) \{
throw new Error('Sauce Labs Onesie not found');
\}
if (onesieItem.price !== 7.99) \{
throw new Error(`Expected price 7.99 but got ${onesieItem.price}`);
\}
Request
Responses
- 200
- 400
- 401
- 402
- 422
- 429
- 500
- 503
Successfully observed page content or validated assertion
Invalid Request Format - check API documentation for proper syntax.
Unauthorized - missing or invalid API key.
Payment Required - you have run out of trial credits or your payment method has expired. Please add payment details to your account.
Unprocessable Entity - cannot find requested asset associated with your API key.
Too Many Requests - you have exceeded the rate limit for your account. Please wait before making additional requests.
Internal Server Error - please retry your request.
Service Unavailable - our servers have dropped the request due to high load - please retry.