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

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# Connect your agent to the carrier portal mock

> Test browser agents on Larchmont Mutual's fictional agency website. Search policies, submit underwriting requests, download PDFs and check results.

Use a browser to sign in to Larchmont Mutual's agency website, search policies, submit underwriting requests, download PDFs and contact an underwriter. The carrier, agencies and policies are fictional.

The [carrier portal mock page](https://ancha.io/tools/carrier-portal) has a scene and checks you can copy.

Select this tool with `twins: [carrier-portal]` in a scene or `--tools carrier-portal` when creating a world. Inspect its pages and connection code:

```bash theme={null}
ancha twins coverage carrier-portal
ancha connect carrier-portal --lang ts
```

## Connect

Ancha sets the portal URL and fake sign-in credentials before it starts your agent.

| Variable | Value |
| - | - |
| `CARRIER_PORTAL_URL` | Base URL of the agency website. Open it in your browser. |
| `CARRIER_PORTAL_AGENCY_CODE` | Agency code for the agent's user. |
| `CARRIER_PORTAL_USERNAME` | Username for sign-in. |
| `CARRIER_PORTAL_PASSWORD` | Fake password for sign-in. |

```ts Playwright theme={null}
// With an existing Playwright page:
await page.goto(process.env.CARRIER_PORTAL_URL!);
await page.getByLabel('Agency code').fill(process.env.CARRIER_PORTAL_AGENCY_CODE!);
await page.getByLabel('Username').fill(process.env.CARRIER_PORTAL_USERNAME!);
await page.getByLabel('Password', { exact: true }).fill(process.env.CARRIER_PORTAL_PASSWORD!);
await page.getByRole('button', { name: 'Sign in', exact: true }).click();
```

Use the page's labeled forms and links to search policies and submit requests. Each user sees their agency's policies, requests, messages and documents.

## Pages and forms

Paths below are relative to `CARRIER_PORTAL_URL`.

| Method | Path | Notes |
| - | - | - |
| `GET` | `/` | Open policy search or sign-in. |
| `GET`, `POST` | `/sign-in` | Agency code, username and password. |
| `POST` | `/sign-out` | End the browser session. |
| `GET` | `/policies` | Search with `by=number`, `insured`, `agency` or `all`, and `q`. |
| `GET` | `/policies/:number` | Insured, address, term, status, coverages, forms, vehicles, additional insureds and documents. |
| `GET`, `POST` | `/policies/:number/requests/loss-runs` | `years`, `valuation_date`. |
| `GET`, `POST` | `/policies/:number/requests/mailing-address` | `mailing_address`. |
| `GET`, `POST` | `/policies/:number/requests/add-vehicle` | `year`, `make`, `model`, `vin`. |
| `GET`, `POST` | `/policies/:number/requests/remove-vehicle` | Select a vehicle's `vin`. |
| `GET`, `POST` | `/policies/:number/requests/additional-insured` | `name`, `address`. |
| `GET`, `POST` | `/policies/:number/requests/certificate` | `holder`, `holder_address`, `operations`, `additional_insured`, `waiver`. |
| `GET` | `/requests` | Request references and statuses. |
| `GET` | `/requests/:reference` | Submitted fields, status and document link. |
| `GET` | `/documents/:id/download` | Download a PDF and record the download. |
| `GET`, `POST` | `/messages` | Underwriter inbox and outgoing messages: `policy`, optional `request`, `subject`, `body`. |

Forms submit `application/x-www-form-urlencoded`. Authenticated forms include a hidden `csrf` value. Submit the page's form to carry it with the request. Checked certificate boxes send `on`. A successful submission redirects to its request page. Validation errors redisplay the form with its values and an inline message.

## Starter data

Inspect the starter records and the fields you can use in a scene:

```bash theme={null}
ancha sandbox configuration --tools carrier-portal --json
ancha twins seed carrier-portal
```

The starter data has Pike Street Insurance Agency and Lake Road Brokerage. It includes policies for Pike Street Dental (`LM-10042`), Harbor Foods (`LM-10043`) and Summit Freight (`LM-20001`), with claims, declarations, an endorsement, a binder and prior underwriting correspondence.

This scene seed gives Rachel Brooks access to Pike Street Dental's policy:

```yaml theme={null}
twins:
  - carrier-portal
seed:
  carrier-portal:
    agencies:
      - code: A104
        name: Pike Street Insurance Agency
    users:
      - username: rachel
        agency_code: A104
        name: Rachel Brooks
    policies:
      - number: LM-10042
        agency_code: A104
        insured: Pike Street Dental
        mailing_address: 142 Pike Street, Portland, OR 97204
        term_start: 2026-01-01
        term_end: 2027-01-01
        status: in force
        coverages:
          - name: General liability - each occurrence
            limit: $1,000,000
        forms:
          - number: LM-GL-01
            title: Commercial General Liability
        vehicles:
          - year: 2003
            make: Honda
            model: Accord
            vin: 1HGCM82633A004352
    claims:
      - number: CL-10042-01
        policy: LM-10042
        date_of_loss: 2025-07-12
        date_reported: 2025-07-14
        claimant: José Núñez
        description: Slip and fall in reception
        status: closed
        paid_loss: 4500
        paid_expense: 750
        outstanding_reserve: 0
    documents:
      - id: dec-10042
        policy: LM-10042
        title: 2026 Declarations
        type: declarations
        text: "Named insured: Pike Street Dental. General liability: $1,000,000 each occurrence; $2,000,000 aggregate."
    prior_requests:
      - reference: LMR-PRIOR-01
        policy: LM-10042
        status: Approved
        type: mailing-address
        fields:
          mailing_address: 142 Pike Street, Portland, OR 97204
    messages:
      - id: welcome
        policy: LM-10042
        request: LMR-PRIOR-01
        subject: Mailing address confirmed
        body: The requested mailing address has been approved.
```

A scene uses the data you put in its `seed` field. Ancha generates a fake password for each user. Set `users[].password` to choose a specific fake sign-in value.

## Checks

Check a mailing address submission, a declarations download and a message to the underwriter:

```yaml theme={null}
checks:
  - id: address_submitted
    state:
      carrier-portal.request:
        policy: LM-10042
        type: mailing-address
        status: Submitted - underwriter review
        fields:
          mailing_address: 12 Cedar Street
  - id: declarations_downloaded
    state:
      carrier-portal.downloaded:
        policy: LM-10042
        document: dec-10042
  - id: underwriter_contacted
    state:
      carrier-portal.message:
        policy: LM-10042
        text_contains: Please review
```

| Check | Selectors |
| - | - |
| `carrier-portal.request` | Required `policy`; optional `type`, `status`, `fields` and `count_gte`. Fields compare exactly, including numbers and booleans. |
| `carrier-portal.downloaded` | Required `policy`; optional `document`, document `type` and `count_gte`. |
| `carrier-portal.message` | Required `policy`; optional `request`, `text_contains` and `count_gte`. Matches messages sent by the agent. Body text matching is case-sensitive. |

`count_gte` defaults to `1`.

## Behavior

* Endorsement and certificate submissions receive an `LMR-` reference and status `Submitted - underwriter review`. An endorsement updates the policy when an underwriter approves it.
* Use `carrier-portal.approve` and `carrier-portal.reply` in `world_rules.actors` to schedule underwriting approval and replies on the scene clock. See [World rules](https://docs.ancha.io/reference/test-file.md#world-rules).
* Loss runs are `Ready` immediately when the policy's `loss_runs_delay_ms` is zero. A positive value schedules readiness on the scene clock; the request stays `Pending` until then. Ready requests show claims and totals on the request page and in a downloadable PDF.
* VINs use the 17-character North American check-digit rule. A certificate waiver requires a policy form with `waiver: true`.
* `carrier.session_timeout_minutes` sets the idle session timeout on the scene clock. After it expires, the next authenticated page returns to sign-in.


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