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

# extract

> Pull a value off the page with the AI agent and save it to `env`.

Reads a value from the page and writes it to the test's `env` map. When `schema`
is set, the returned value must validate against it or the step fails.

## Parameters

| Parameter | Type      | Required | Description                                                           |
| --------- | --------- | -------- | --------------------------------------------------------------------- |
| `goal`    | `string`  | Yes      | Natural-language description of the value to extract.                 |
| `schema`  | `object`  | No       | JSON Schema the extracted value must validate against.                |
| `iframe`  | `string`  | No       | URL or URL pattern of the iframe that contains the target element.    |
| `saveAs`  | `string`  | No       | Name of the variable to write this step's return value to.            |
| `retries` | `number`  | No       | Number of times to retry the step on failure before failing the test. |
| `skipped` | `boolean` | No       | Skip this step at execution time.                                     |

## Shorthand

Pair with `saveAs` to capture the value into `env`.

```yaml theme={null}
- extract: the order id shown in the confirmation banner
```

## Examples

```yaml theme={null}
- extract:
    goal: the main heading text shown on the page
    saveAs: EXTRACTED_HEADING
```

```yaml theme={null}
- extract:
    goal: The discounted subtotal in the order summary
    schema:
      type: object
      properties:
        amount:
          type: number
      required: [amount]
    saveAs: ORDER
```

```yaml theme={null}
- extract:
    goal: the company name shown on the YC profile page
    iframe: https://www.ycombinator.com/companies
    saveAs: COMPANY_NAME
```

## Related

* [Variables](/core-concepts/variables)
* [Agentic testing](/core-concepts/agentic-testing)
* [Test format](/core-concepts/test-format)
