# redactWell

> Returns a copy of well with hidden sections and fields cleared: array fields become [] and optional fields become undefined, so the result stays a schema-valid Well. Never mutates well.

> **redactWell**(`well`, `visibility`): [`Well`](/core/api/type-aliases/Well)

Returns a copy of `well` with hidden sections and fields cleared: array
fields become `[]` and optional fields become `undefined`, so the result
stays a schema-valid [Well](/core/api/type-aliases/Well). Never mutates `well`.

A field is hidden when its key or its section's key is `false` in
`visibility` (see [VISIBILITY\_TREE](/core/api/variables/VISIBILITY_TREE)); missing keys are visible.
`well_depth` is dropped only when the whole `constructive` section is
hidden. Hiding a record type does not rewrite references to it held by
visible records (e.g. a production entry's `meter_id`).

Root members the spec does not define (`x-` fields and blocks) can hold
anything, so they are kept only when nothing is hidden. Unknown members
nested in a record follow that record.

## Parameters

### well

[`Well`](/core/api/type-aliases/Well)

The well profile to redact.

### visibility

`Partial`\<`Record`\<[`VisibilityKey`](/core/api/type-aliases/VisibilityKey), `boolean`\>\> \| [`SectionVisibility`](/core/api/type-aliases/SectionVisibility)

Section and/or field visibility. A [SectionVisibility](/core/api/type-aliases/SectionVisibility) works as-is.

## Returns

[`Well`](/core/api/type-aliases/Well)

A new [Well](/core/api/type-aliases/Well) with hidden parts emptied.

## Example

```ts
redactWell(well, { operation: false });              // whole section
redactWell(well, { meters: false, permits: false }); // single fields
```
