# Read-only schema inference from notes' front matter.

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

Read-only schema inference from notes' front matter.
- `folder` (recursive; "" = whole vault) and/or `paths`: notes not yet in a table. Returns
  `columns` (type, enum `values`, link `ref` to the table most targets belong to, `required`,
  `unique`, `dense`, `from` when the front matter key is not a valid column name, `stats`),
  `proposal`, the create_table arguments (`name`, `description`, `filename` or
  `time_column`, `columns`), and `adopt` ready for adopt_rows (`paths`, `rename`,
  `relocate: false`), plus `hints` to read.
  The notes cannot say what the table and its columns mean: `description` is null on the proposal
  and on every column. Write each one (ask the user when unsure), and review the names, enums and
  required columns, before you pass the proposal to create_table, which refuses null descriptions.
- `table`: keys the table's rows use but the table does not declare (candidates for add_column,
  each with a description to write, or keys to drop from rows).
A string column becomes an enum when its values repeat: at least 3 notes, at most `max_enum_values`
distinct values (default 12), each used twice on average, short texts.

## Request body

`application/json`

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `folder` | `string \| null` | no | `null` |  |
| `paths` | `string[] \| null` | no | `null` |  |
| `table` | `string \| null` | no | `null` |  |
| `name` | `string \| null` | no | `null` |  |
| `max_enum_values` | `integer \| null` | no | `null` |  |

## Responses

| Status | Description | Body |
| --- | --- | --- |
| 200 | Done. | `object` (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) |
| 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) |
| 500 | Unexpected error. | `Error` (application/json) |

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