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

# Web Simulator Quickstart

> Spin up a RadMD web portal sandbox and log in from a browser.

By the end of this walkthrough you will have a live RadMD sandbox, a username and password minted for it, and a Playwright script that logs in and lands on the authenticated dashboard. No environment or benchmark required.

## Prerequisites

* An organization API key. Create one in your organization's dashboard under **API Keys**. Keys are prefixed `vrl_` and sent as `Authorization: Bearer <key>`.
* Node.js 20+ (for the Playwright example). Python users can adapt the snippet to `playwright` for Python.

```bash theme={null}
export VERIAL_API_KEY=vrl_xxx
```

## 1. Create a Web Simulator

Create a simulator with `type: "Payer"` and pick a portal slug from the [catalog](/guides/simulators/web-portal#portal-catalog) (`radmd` or `covermymeds`).

```bash theme={null}
curl -X POST https://api.verial.ai/simulators \
  -H "Authorization: Bearer $VERIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "Payer",
    "name": "RadMD Sandbox",
    "config": {
      "portal": "radmd",
      "default_determination": { "status": "approved" }
    }
  }'
```

Response:

```json theme={null}
{
  "id": "sim_01H...",
  "type": "Payer",
  "name": "RadMD Sandbox",
  "config": { "portal": "radmd", "default_determination": { "status": "approved" } },
  "created_at": "2026-04-23T17:00:00.000Z"
}
```

```bash theme={null}
export SIMULATOR_ID=sim_01H...
```

## 2. Create a Sandbox

Provision a live instance from the simulator. Verial mints a fresh username + password bound to this sandbox.

```bash theme={null}
curl -X POST https://api.verial.ai/sandboxes \
  -H "Authorization: Bearer $VERIAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"simulator_id\": \"$SIMULATOR_ID\" }"
```

## 3. Read the Credentials

Fetch the sandbox to pull the portal URL and login.

```bash theme={null}
curl "https://api.verial.ai/sandboxes/$SANDBOX_ID" \
  -H "Authorization: Bearer $VERIAL_API_KEY"
```

Response (truncated):

```json theme={null}
{
  "id": "sbx_01H...",
  "simulator_id": "sim_01H...",
  "status": "active",
  "credentials": {
    "portal_url": "https://radmd.sim.verial.ai",
    "username": "provider_a1b2c3",
    "password": "Kq7!mZxP9vRnT2wL",
    "api_url": "https://api.verial.ai/sandboxes/sbx_01H.../web-sim/payer"
  }
}
```

```bash theme={null}
export SANDBOX_ID=sbx_01H...
export PORTAL_URL=https://radmd.sim.verial.ai
export PORTAL_USERNAME=provider_a1b2c3
export PORTAL_PASSWORD='Kq7!mZxP9vRnT2wL'
```

## 4. Log In with Playwright

```bash theme={null}
npm install playwright
npx playwright install chromium
```

```typescript theme={null}
// login.ts
import { chromium } from 'playwright'

const portalUrl = process.env.PORTAL_URL!
const username = process.env.PORTAL_USERNAME!
const password = process.env.PORTAL_PASSWORD!

const browser = await chromium.launch({ headless: false })
const page = await browser.newPage()

await page.goto(portalUrl)
await page.getByLabel(/username/i).fill(username)
await page.getByLabel(/password/i).fill(password)
await page.getByRole('button', { name: /sign ?in|log ?in/i }).click()
await page.waitForURL((url) => !url.pathname.endsWith('/login'))

console.log('logged in, url:', page.url())
// await browser.close()
```

Run it:

```bash theme={null}
npx tsx login.ts
```

The page will land on the portal's authenticated landing route. From here your agent can drive the rest of the workflow (patient search, prior auth submission, etc.) using the same DOM selectors as the real vendor portal.

## 5. Verify State via the API

Any action taken in the browser updates sandbox state. Read it back through the REST API at the `api_url` from step 3, using your organization API key:

```bash theme={null}
curl "$API_URL/patients?name=Smith" \
  -H "Authorization: Bearer $VERIAL_API_KEY"
```

## 6. Tear Down

```bash theme={null}
curl -X POST "https://api.verial.ai/sandboxes/$SANDBOX_ID/teardown" \
  -H "Authorization: Bearer $VERIAL_API_KEY"
```

The username and password are invalidated immediately; interaction events persist.

## Next Steps

<CardGroup cols={2}>
  <Card title="Web Portal Catalog" icon="browser" href="/guides/simulators/web-portal">
    The supported portals and their config options.
  </Card>

  <Card title="Benchmarks" icon="list-check" href="/guides/concepts/benchmarks">
    Compose web simulators into scored benchmarks.
  </Card>
</CardGroup>
