> ## Documentation Index
> Fetch the complete documentation index at: https://docs.optexity.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation Structure

> Understanding the structure of Optexity automations

Optexity uses a declarative model for browser automation. Define **what** actions to perform, and Optexity handles the **how** using AI-assisted element location.

## Overview

```
Automation
├── url                  # Starting point
├── browser_channel      # "chromium" or "chrome"
├── os_emulation         # OS to emulate: "windows", "linux", or null
├── max_retries          # Total run attempts on failure (default: 1)
├── expected_downloads   # Number of files to download
├── enable_browser_alerts   # Log native JS dialogs (alert/confirm/prompt) as they're auto-accepted
├── reuse_page_if_already_on_url   # Skip navigation when already on url (dedicated only)
├── parameters           # Input, secure, and generated variables
└── nodes[]              # Sequence of actions
    ├── action_node
    ├── for_loop_node
    ├── if_else_node
    └── private_node
```

## Complete Example

```json theme={null}
{
  "url": "https://example.com/login",
  "browser_channel": "chromium",
  "os_emulation": null,
  "max_retries": 1,
  "expected_downloads": 0,
  "parameters": {
    "input_parameters": {
      "email": ["user@example.com"]
    },
    "secure_parameters": {},
    "generated_parameters": {}
  },
  "nodes": [
    {
      "type": "action_node",
      "interaction_action": {
        "input_text": {
          "command": "get_by_label(\"Email\")",
          "input_text": "{email[0]}"
        }
      }
    }
  ]
}
```

## Properties

| Property | Type | Default | Description |
| - | - | - | - |
| `url` | `str` | — | Starting URL—use the URL closest to your target to reduce navigation steps |
| `browser_channel` | `"chromium" \| "chrome"` | `"chromium"` | Browser to use |
| `os_emulation` | `"windows" \| "linux" \| null` | `null` | OS user-agent to emulate; `null` uses the default system OS |
| `max_retries` | `int` | `0` | Total number of run attempts. `0` = no retry, `1` = one retry, etc. |
| `expected_downloads` | `int` | `0` | Number of expected downloads (automation waits for completion) |
| `enable_browser_alerts` | `bool` | `false` | Log native JS dialogs (`alert`, `confirm`, `prompt`) as they're encountered. See [Browser Alerts](#browser-alerts) |
| `reuse_page_if_already_on_url` | `bool` | `false` | Start on the existing page instead of navigating, when a dedicated browser is already on `url`. See [Reuse Page If Already On URL](#reuse-page-if-already-on-url) |
| `parameters` | `Parameters` | — | Input, secure, and generated variables |
| `nodes` | `list[action_node \| for_loop_node \| if_else_node \| private_node]` | — | Ordered list of actions |

## Parameters

Three types of parameters control data flow:

| Type | Purpose | Example |
| - | - | - |
| `input_parameters` | Values provided before execution | Username, search queries |
| `secure_parameters` | Sensitive data from secure storage | Passwords, API keys |
| `generated_parameters` | Values extracted during execution | Order IDs, confirmation numbers |

```json theme={null}
{
  "parameters": {
    "input_parameters": {
      "username": ["admin@example.com"]
    },
    "secure_parameters": {
      "password": [{
        "onepassword": {
          "vault_name": "vault",
          "item_name": "login",
          "field_name": "password"
        }
      }]
    },
    "generated_parameters": {
      "order_ids": []
    }
  }
}
```

> [!TIP]
>
> See [Parameters](https://docs.optexity.com/docs/building-automations/parameters.md) for detailed usage.

## Node Types

| Node | Purpose | Documentation |
| - | - | - |
| `action_node` | Single atomic action | [Action Node](https://docs.optexity.com/docs/building-automations/action-node.md) |
| `for_loop_node` | Iterate over list values or locator matches | [For Loop Node](https://docs.optexity.com/docs/building-automations/for-loop-node.md) |
| `if_else_node` | Conditional execution | [If Else Node](https://docs.optexity.com/docs/building-automations/if-else-node.md) |
| `private_node` | Closed-source handler, runs only on Optexity's servers | [Private Node](https://docs.optexity.com/docs/building-automations/private-node.md) |

## Browser Channel

| Channel | Use When |
| - | - |
| `"chromium"` | Default, works for most sites |
| `"chrome"` | Site requires Chrome specifically, or automation is unreliable with Chromium |

```json theme={null}
{
  "browser_channel": "chrome"
}
```

## Expected Downloads

Set this to wait for file downloads to complete:

```json theme={null}
{
  "expected_downloads": 3
}
```

The automation waits until all expected files are downloaded before completing.

## Browser Alerts

Native JS dialogs (`alert`, `confirm`, `prompt`) are always auto-accepted so they never block the automation. Set `enable_browser_alerts` to also log each dialog's type and message when one is triggered:

```json theme={null}
{
  "enable_browser_alerts": true
}
```

> [!TIP]
>
> Turn this on while building or debugging an automation against a site that pops native dialogs, so you can see in the logs when and why one fired. Leave it off otherwise.

## OS Emulation

Override the OS reported in the browser's user-agent string:

| Value | Use When |
| - | - |
| `null` | Default — uses the host system's OS (recommended for most sites) |
| `"windows"` | Site behaves differently on Windows (e.g. Windows-only portals) |
| `"linux"` | Site behaves differently on Linux |

```json theme={null}
{
  "os_emulation": "windows"
}
```

> [!TIP]
>
> Only set `os_emulation` when a site serves different content or layouts based on the OS. Leave it as `null` otherwise.

## Max Retries

Control how many times the full automation reruns when an unexpected error occurs:

```json theme={null}
{
  "max_retries": 3
}
```

| Value | Behavior |
| - | - |
| `1` (default) | Runs once; fails immediately on error |
| `2` | Runs up to twice (1 retry) |
| `3` | Runs up to three times (2 retries) |

> [!NOTE]
>
> `max_retries` is the **total number of attempts**, not the number of extra retries. `AssertionError` failures are never retried regardless of this value.

> [!TIP]
>
> See [Timing & Retries](https://docs.optexity.com/docs/advanced/timing-retries.md) for controlling per-element retry behavior (`max_tries`) vs. full-automation retries (`max_retries`).

## Reuse Page If Already On URL

Every run navigates to `url` before the first node executes, even on a warm [dedicated instance](https://docs.optexity.com/docs/inference/dedicated-instances.md). Set `reuse_page_if_already_on_url` to leave the existing page untouched when the reused browser is **already sitting on `url`**:

```json theme={null}
{
  "reuse_page_if_already_on_url": true
}
```

Use this only for portals that break when their page is reloaded — some session-bound portals throw an error or invalidate the session on any refresh, so the safest thing is not to navigate at all.

| Condition | Behavior |
| - | - |
| Dedicated run, browser already on `url` | Nodes start on the existing page; no navigation |
| URL differs, or the page is unresponsive | Normal navigation to `url` |
| Non-dedicated run | Normal navigation to `url` (flag has no effect) |

The URL comparison is exact on scheme, host, path, query string, and fragment — only a trailing slash on the path is ignored. A hash-routed portal on `#/dashboard` therefore does not match a `url` of `#/home`. Anything that doesn't match falls back to normal navigation, so enabling the flag can never leave a run stranded.

> [!WARNING]
>
> Your first node now runs against whatever the previous task left behind — an open modal, a filled form, a scrolled list. Make it tolerant of a mid-session page, or pair it with an [if-else node](https://docs.optexity.com/docs/building-automations/if-else-node.md) that resets the portal to a known state.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.