# Observe

**Observe Actions on a Given URL**

**POST /env/observe**

This endpoint observes the actions available on a given URL within the session’s environment. If a session ID is not provided, a new session is created.

**Request Example:**

```bash
bashCopyEditcurl --location \
--request POST 'https://api.cros.one/env/observe' \
--header 'Authorization: Bearer your-api-key' \
--header 'Content-Type: application/json' \
--data '{
  "session_id": "1234567890abcdef",
  "url": "https://example.com",
  "max_nb_actions": 50,
  "min_nb_actions": 10,
  "keep_alive": true,
  "screenshot": true,
  "session_timeout_minutes": 10
}'
```

**Response Example:**

```json
jsonCopyEdit{
  "metadata": {
    "url": "https://example.com",
    "page_title": "Example Website",
    "timestamp": "2025-02-06T14:00:00.000Z"
  },
  "session": {
    "session_id": "1234567890abcdef",
    "status": "active",
    "last_accessed_at": "2025-02-06T14:05:00.000Z",
    "timeout_minutes": 10
  },
  "data": {
    "extracted_information": "..."
  },
  "screenshot": "base64_encoded_image_data_here",
  "space": {
    "description": "Available actions on the current page",
    "actions": [
      {
        "id": "I1",
        "description": "Click on the login button",
        "category": "User Interaction"
      },
      {
        "id": "I2",
        "description": "Submit the form",
        "category": "Form Submission"
      }
    ]
  }
}
```

**Fields in the Request Body:**

* **session\_id** (string | null): The ID of the session. If not provided, a new session will be created.
* **url** (string | null): The URL to observe. If not provided, uses the current page URL.
* **keep\_alive** (boolean, default: `false`): If true, the session will not be closed after the operation is completed.
* **max\_nb\_actions** (integer, default: `100`): The maximum number of actions to list. The listing will stop after this number is reached.
* **min\_nb\_actions** (integer | null): The minimum number of actions to list before stopping. If not provided, the listing will continue until the maximum number of actions is reached.
* **screenshot** (boolean | null): Whether to include a screenshot in the response.
* **session\_timeout\_minutes** (integer, default: `5`): Session timeout in minutes. Cannot exceed the global timeout. Required range: `0 < x < 30`.

**Fields in the Response:**

* **metadata** (object): Metadata of the current page (e.g., URL, page title, and timestamp).
* **session** (object): Browser session information, including the session ID, status, last accessed time, and timeout.
* **data** (object | null): Extracted data from the page, such as relevant information captured during the observation.
* **screenshot** (file | null): A base64-encoded screenshot of the current page, if requested.
* **space** (object | null): Available actions on the current page, such as clickable elements or form submissions.
