# Update every row matching `where` (required: `{}` is every row). `where`: keys AND-ed; values are equality or operators

`POST /datanotes/operations/update_rows/` (operation `update_rows`)

Update every row matching `where` (required: `{}` is every row). `where`: keys AND-ed; values are equality or operators
eq, ne, gt, gte, lt, lte, in, contains, icontains (case/accent-insensitive, also inside lists —
use it for names and aliases), exists, within (a hierarchy link: that row and everything below);
combine with `or` / `and` / `not` (nestable); `path` is a pseudo-column. A dotted key follows a
link column: `{"project.area": "[[Work]]"}` matches rows whose `project` links a row with that `area`. `set` sets, `unset`
removes; all rows are validated first.
`expect_count`: refuse unless exactly that many match. One row, or its text: update_row.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Datanotes-Actor` | header | `string` | no | JSON: on whose behalf the write is made, recorded in the journal (`harness`, `model`, `session`). |

## Request body

`application/json`, required

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `table` | `string` | yes |  |  |
| `where` | `object` | yes |  | The rows to change; {} is every row of the table. |
| `set` | `object \| null` | no | `null` |  |
| `unset` | `string[] \| null` | no | `null` |  |
| `dry_run` | `boolean` | no | `false` |  |
| `expect_count` | `integer \| null` | no | `null` | Refuse (nothing written) unless `where` matches exactly this many rows. |

## Responses

| Status | Description | Body |
| --- | --- | --- |
| 200 | Done. | `OpResult` (application/json) |
| 400 | Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type. | `Error` (application/json) |
| 401 | Missing or wrong bearer token. | `Error` (application/json) |
| 403 | A named token beyond its permissions (the engine's administration, tables outside its `write` patterns, schema changes without `ddl`). | `Error` (application/json) |
| 404 | Unknown table, view, migration, note or folder. | `Error` (application/json) |
| 409 | Ambiguous table name: it matches several tables (`paths` or `tables` lists them). | `AmbiguousName` (application/json) |
| 422 | Refused (validation failures, conflicts, an unmet `expect`): nothing written. Same body as 200, with `ok: false` and the reasons. | `OpResult` (application/json) |
| 500 | Unexpected error (`{error}`), or a write that failed partway and could not be rolled back: `rolled_back: false`, `failed` lists the files left (undo_migration on `migration_id` retries the rollback). | `OpResult \| Error` (application/json) |
| 503 | A write that failed partway (a file another program holds) and was rolled back: `rolled_back: true`, nothing written. Send it again later. Same body as 200, with `ok: false` and `failed`. | `OpResult` (application/json) |

The schemas named here are in [openapi.json](https://datanotes.dev/openapi.json) (`components.schemas`).
