Skip to content

Create a table: `name`, in `catalog` and `schema` (default: the database's defaults); the definition

POST
/datanotes/operations/create_table/
curl --request POST \
--url https://example.com/datanotes/operations/create_table/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Datanotes-Actor: {"harness":"my-script","model":"","session":"s-1"}' \
--data '{ "name": "example", "description": null, "columns": [ {} ], "catalog": null, "schema": null, "time_column": null, "filename": null, "partition": null, "exclude": null, "archive": null, "aliases": null, "history": null, "autolink_target": null, "row_template": null, "fields": null, "tags": null, "dry_run": false }'

Create a table: name, in catalog and schema (default: the database’s defaults); the definition goes in metastore.yaml, the rows in <root>/<catalog>/<schema>/<name>/. Names: lowercase letters, digits, _ (no dots: pass the catalog and the schema as their own arguments).

  • description (required): what a row of the table records. Every column needs its own description too, what it holds: the table is refused otherwise, with every missing one listed. Descriptions are how agents and people understand the schema, so write them for a reader who never saw the notes. The engine writes those of id and of identity “uuid” / “created” columns.
  • columns: specs like {"name": "kind", "type": "enum", "values": ["a","b"], "required": true, "description": "What kind of entry the row is"}. Types: string, integer, number, boolean, date, datetime, enum, link, list (+ items), json. Attributes: required, default ("{now}"/"{today}"), min, max, step, values, ordered (enum in order: filters/avg use the position), ref (link target, full catalog.schema.table or “self”), unique, label, description, aliases, generated (e.g. "date(occurred_at)", "{name} {surname}"), identity (“filename” | “created”), vocabulary (allowed values = names of another table’s rows), hierarchy: true (one parent link to its own table), dense (written on every row), inverse on a link column: the column of the ref table that links back (friends ↔ friends, children ↔ parents, partner ↔ partner); writes keep both sides in step.
  • time_column: rows named by that date/datetime; otherwise filename (e.g. "{name}").
  • The table’s options, as alter_table names them: aliases (how agents find it, with the description), partition, exclude, archive, history (keep its versions; default: the database’s setting), autolink_target (true / false: may automatic links link its rows? default: yes, unless its rows are named by a date or a time, as with time_column).
  • row_template: markdown body of new rows. Shared columns come from bases: set_table_bases.
  • tags: key/value labels of the table, strings ({"domain": "health"}); list_tables and describe_table return them, alter_table changes them. Enum columns: values and, for each, its meaning in value_descriptions ({"stated": "the user said it", …}): describe_table shows them and a refused value lists them. Generated link columns: generated: "link({occurred_at:YYYY-MM-DD})" with ref = the days table links each row to the row of ref named by the template (its folder read from the schema; the target may not exist yet). Filtered link targets (link columns): ref_where (a where every target must match) and ref_by (a column of the row picks the target level: {"column": "kind", "levels": ["area", "project", "workstream"]} or {"column": "kind", "map": {"area": null, "project": ["area"]}}; null = top level, no link; target_column when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; list_link_targets lists the valid targets of a row.

The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).

X-Datanotes-Actor
string

JSON: on whose behalf the write is made, recorded in the journal (harness, model, session).

Example

{"harness":"my-script","model":"","session":"s-1"}
Media typeapplication/json
object
name
required
string
description
Any of:
string
columns
required
Array<object>
object
key
additional properties
any
catalog
Any of:
string
schema
Any of:
string
time_column
Any of:
string
filename
Any of:
string
partition
Any of:
string
exclude
Any of:
Array<string>
archive
Any of:
string
aliases
Any of:
Array<string>
history
Any of:
boolean
autolink_target
Any of:
boolean
row_template
Any of:
string
fields
Any of:
object
key
additional properties
any
tags
Any of:
object
key
additional properties
string
dry_run
boolean

Done.

Media typeapplication/json
OpResult

Result of a write operation. A refusal (ok false) is answered with HTTP 422, a failed write with 500, so a 2xx body has ok true.

object
ok
required

True when the operation was applied (or, on a dry run, would be).

boolean
op
required

The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).

string
dry_run
required

True when nothing was written (preview).

boolean
migration_id

Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.

string
notes_changed
required

Notes whose front matter or body were written.

integer
files_created
required

Files created.

integer
files_moved
required

Files moved or renamed.

integer
files_deleted
required

Files deleted or archived.

integer
references_updated
required

Links rewritten in other notes.

integer
conflicts
required

Reasons the operation was refused (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
violations
required

Rows that would break the table’s rules (empty on success).

Array<object>
RowViolations

The violations of one row.

object
path
required

Row note path.

string
violations
required

What is wrong with this row.

Array<object>
Violation
object
column

The column the violation is about (every code but check and unreadable).

string
index

The item of a list column that breaks the rule, from 0.

integer
constraint

The CHECK’s name (code check).

string
code
required

Kind of violation.

string
Allowed values: required inverse type min max step enum broken_link ref unique unknown_column check generated cycle vocabulary unreadable
message
required

Agent-readable explanation.

string
value

The offending value, when there is one.

failed
required

Files that could not be written (empty on success).

Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string
rolled_back

Set when a write failed partway (failed): true when the engine put back what it had written, so nothing is left written; false when that rollback failed too (failed names the files left, and undo_migration on migration_id retries it).

boolean
planned_edits
required

Front matter edits per note (planned, or made).

Array<object>
object
path
required

Note path.

string
set
required

Front matter keys set, with their new values.

object
key
additional properties
any
remove
required

Front matter keys removed.

Array<string>
body

True when the note body changes too.

boolean
planned_creates
required

Paths of notes created.

Array<string>
planned_moves
required

Files moved: from → to.

Array<object>
object
from
required
string
to
required
string
planned_deletes
required

Paths deleted (or archived).

Array<string>
planned_texts
required

Files rewritten whole, e.g. metastore.yaml for DDL.

Array<string>
commits

Transaction-log commits written (tables with history on).

Array<object>
object
table
required

Qualified table.

string
version
required

New log version.

integer
operation
required

Log operation, e.g. WRITE.

string
links_added

Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.

Array<object>
LinkAdded

A link the write added in place of a mention.

object
path
required

The note the link was written into.

string
text
required

The mention, as written.

string
target
required

Vault path of the note it links.

string
link
required

The link written in place of the mention.

string
ambiguous_mentions

Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text.

Array<object>
LinkAmbiguous

A mention left as text: more than one note could be meant.

object
path
required

The note the mention is in.

string
text
required

The mention, as written.

string
reason
required

Same_name: several notes have this name; adjacent: names of different notes side by side, which may be one name; overlap: names of notes overlap; part_of_name: a capitalized word next to it suggests a longer name; sentence_start: a one-word name at the start of a sentence, a line, a list item or a label, where its capital says nothing.

string
Allowed values: same_name adjacent overlap part_of_name sentence_start
candidates
required

Vault paths of the notes it may name.

Array<string>
context
required

The line around the mention.

string
hint
required

What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.

string

Example

{
"violations": [
{
"violations": [
{
"code": "required"
}
]
}
],
"ambiguous_mentions": [
{
"reason": "same_name"
}
]
}

Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Missing or wrong bearer token.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

A named token beyond its permissions (the engine’s administration, tables outside its write patterns, schema changes without ddl).

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Refused (validation failures, conflicts, an unmet expect): nothing written. Same body as 200, with ok: false and the reasons.

Media typeapplication/json
OpResult

Result of a write operation. A refusal (ok false) is answered with HTTP 422, a failed write with 500, so a 2xx body has ok true.

object
ok
required

True when the operation was applied (or, on a dry run, would be).

boolean
op
required

The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).

string
dry_run
required

True when nothing was written (preview).

boolean
migration_id

Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.

string
notes_changed
required

Notes whose front matter or body were written.

integer
files_created
required

Files created.

integer
files_moved
required

Files moved or renamed.

integer
files_deleted
required

Files deleted or archived.

integer
references_updated
required

Links rewritten in other notes.

integer
conflicts
required

Reasons the operation was refused (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
violations
required

Rows that would break the table’s rules (empty on success).

Array<object>
RowViolations

The violations of one row.

object
path
required

Row note path.

string
violations
required

What is wrong with this row.

Array<object>
Violation
object
column

The column the violation is about (every code but check and unreadable).

string
index

The item of a list column that breaks the rule, from 0.

integer
constraint

The CHECK’s name (code check).

string
code
required

Kind of violation.

string
Allowed values: required inverse type min max step enum broken_link ref unique unknown_column check generated cycle vocabulary unreadable
message
required

Agent-readable explanation.

string
value

The offending value, when there is one.

failed
required

Files that could not be written (empty on success).

Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string
rolled_back

Set when a write failed partway (failed): true when the engine put back what it had written, so nothing is left written; false when that rollback failed too (failed names the files left, and undo_migration on migration_id retries it).

boolean
planned_edits
required

Front matter edits per note (planned, or made).

Array<object>
object
path
required

Note path.

string
set
required

Front matter keys set, with their new values.

object
key
additional properties
any
remove
required

Front matter keys removed.

Array<string>
body

True when the note body changes too.

boolean
planned_creates
required

Paths of notes created.

Array<string>
planned_moves
required

Files moved: from → to.

Array<object>
object
from
required
string
to
required
string
planned_deletes
required

Paths deleted (or archived).

Array<string>
planned_texts
required

Files rewritten whole, e.g. metastore.yaml for DDL.

Array<string>
commits

Transaction-log commits written (tables with history on).

Array<object>
object
table
required

Qualified table.

string
version
required

New log version.

integer
operation
required

Log operation, e.g. WRITE.

string
links_added

Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.

Array<object>
LinkAdded

A link the write added in place of a mention.

object
path
required

The note the link was written into.

string
text
required

The mention, as written.

string
target
required

Vault path of the note it links.

string
link
required

The link written in place of the mention.

string
ambiguous_mentions

Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text.

Array<object>
LinkAmbiguous

A mention left as text: more than one note could be meant.

object
path
required

The note the mention is in.

string
text
required

The mention, as written.

string
reason
required

Same_name: several notes have this name; adjacent: names of different notes side by side, which may be one name; overlap: names of notes overlap; part_of_name: a capitalized word next to it suggests a longer name; sentence_start: a one-word name at the start of a sentence, a line, a list item or a label, where its capital says nothing.

string
Allowed values: same_name adjacent overlap part_of_name sentence_start
candidates
required

Vault paths of the notes it may name.

Array<string>
context
required

The line around the mention.

string
hint
required

What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.

string

Example

{
"violations": [
{
"violations": [
{
"code": "required"
}
]
}
],
"ambiguous_mentions": [
{
"reason": "same_name"
}
]
}

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).

Media typeapplication/json
Any of:
OpResult

Result of a write operation. A refusal (ok false) is answered with HTTP 422, a failed write with 500, so a 2xx body has ok true.

object
ok
required

True when the operation was applied (or, on a dry run, would be).

boolean
op
required

The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).

string
dry_run
required

True when nothing was written (preview).

boolean
migration_id

Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.

string
notes_changed
required

Notes whose front matter or body were written.

integer
files_created
required

Files created.

integer
files_moved
required

Files moved or renamed.

integer
files_deleted
required

Files deleted or archived.

integer
references_updated
required

Links rewritten in other notes.

integer
conflicts
required

Reasons the operation was refused (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
violations
required

Rows that would break the table’s rules (empty on success).

Array<object>
RowViolations

The violations of one row.

object
path
required

Row note path.

string
violations
required

What is wrong with this row.

Array<object>
Violation
object
column

The column the violation is about (every code but check and unreadable).

string
index

The item of a list column that breaks the rule, from 0.

integer
constraint

The CHECK’s name (code check).

string
code
required

Kind of violation.

string
Allowed values: required inverse type min max step enum broken_link ref unique unknown_column check generated cycle vocabulary unreadable
message
required

Agent-readable explanation.

string
value

The offending value, when there is one.

failed
required

Files that could not be written (empty on success).

Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string
rolled_back

Set when a write failed partway (failed): true when the engine put back what it had written, so nothing is left written; false when that rollback failed too (failed names the files left, and undo_migration on migration_id retries it).

boolean
planned_edits
required

Front matter edits per note (planned, or made).

Array<object>
object
path
required

Note path.

string
set
required

Front matter keys set, with their new values.

object
key
additional properties
any
remove
required

Front matter keys removed.

Array<string>
body

True when the note body changes too.

boolean
planned_creates
required

Paths of notes created.

Array<string>
planned_moves
required

Files moved: from → to.

Array<object>
object
from
required
string
to
required
string
planned_deletes
required

Paths deleted (or archived).

Array<string>
planned_texts
required

Files rewritten whole, e.g. metastore.yaml for DDL.

Array<string>
commits

Transaction-log commits written (tables with history on).

Array<object>
object
table
required

Qualified table.

string
version
required

New log version.

integer
operation
required

Log operation, e.g. WRITE.

string
links_added

Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.

Array<object>
LinkAdded

A link the write added in place of a mention.

object
path
required

The note the link was written into.

string
text
required

The mention, as written.

string
target
required

Vault path of the note it links.

string
link
required

The link written in place of the mention.

string
ambiguous_mentions

Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text.

Array<object>
LinkAmbiguous

A mention left as text: more than one note could be meant.

object
path
required

The note the mention is in.

string
text
required

The mention, as written.

string
reason
required

Same_name: several notes have this name; adjacent: names of different notes side by side, which may be one name; overlap: names of notes overlap; part_of_name: a capitalized word next to it suggests a longer name; sentence_start: a one-word name at the start of a sentence, a line, a list item or a label, where its capital says nothing.

string
Allowed values: same_name adjacent overlap part_of_name sentence_start
candidates
required

Vault paths of the notes it may name.

Array<string>
context
required

The line around the mention.

string
hint
required

What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.

string

Example

{
"violations": [
{
"violations": [
{
"code": "required"
}
]
}
],
"ambiguous_mentions": [
{
"reason": "same_name"
}
]
}

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.

Media typeapplication/json
OpResult

Result of a write operation. A refusal (ok false) is answered with HTTP 422, a failed write with 500, so a 2xx body has ok true.

object
ok
required

True when the operation was applied (or, on a dry run, would be).

boolean
op
required

The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).

string
dry_run
required

True when nothing was written (preview).

boolean
migration_id

Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.

string
notes_changed
required

Notes whose front matter or body were written.

integer
files_created
required

Files created.

integer
files_moved
required

Files moved or renamed.

integer
files_deleted
required

Files deleted or archived.

integer
references_updated
required

Links rewritten in other notes.

integer
conflicts
required

Reasons the operation was refused (empty on success).

Array<object>
object
path
required

Note or file path.

string
message
required

Why the operation cannot proceed.

string
violations
required

Rows that would break the table’s rules (empty on success).

Array<object>
RowViolations

The violations of one row.

object
path
required

Row note path.

string
violations
required

What is wrong with this row.

Array<object>
Violation
object
column

The column the violation is about (every code but check and unreadable).

string
index

The item of a list column that breaks the rule, from 0.

integer
constraint

The CHECK’s name (code check).

string
code
required

Kind of violation.

string
Allowed values: required inverse type min max step enum broken_link ref unique unknown_column check generated cycle vocabulary unreadable
message
required

Agent-readable explanation.

string
value

The offending value, when there is one.

failed
required

Files that could not be written (empty on success).

Array<object>
object
path
required

Vault path.

string
error
required

What went wrong.

string
rolled_back

Set when a write failed partway (failed): true when the engine put back what it had written, so nothing is left written; false when that rollback failed too (failed names the files left, and undo_migration on migration_id retries it).

boolean
planned_edits
required

Front matter edits per note (planned, or made).

Array<object>
object
path
required

Note path.

string
set
required

Front matter keys set, with their new values.

object
key
additional properties
any
remove
required

Front matter keys removed.

Array<string>
body

True when the note body changes too.

boolean
planned_creates
required

Paths of notes created.

Array<string>
planned_moves
required

Files moved: from → to.

Array<object>
object
from
required
string
to
required
string
planned_deletes
required

Paths deleted (or archived).

Array<string>
planned_texts
required

Files rewritten whole, e.g. metastore.yaml for DDL.

Array<string>
commits

Transaction-log commits written (tables with history on).

Array<object>
object
table
required

Qualified table.

string
version
required

New log version.

integer
operation
required

Log operation, e.g. WRITE.

string
links_added

Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.

Array<object>
LinkAdded

A link the write added in place of a mention.

object
path
required

The note the link was written into.

string
text
required

The mention, as written.

string
target
required

Vault path of the note it links.

string
link
required

The link written in place of the mention.

string
ambiguous_mentions

Mentions left as text because the engine is not sure which note they name. Present when there is one: read the candidates and the context, then link the right one with update_row and autolink: false, or leave the text.

Array<object>
LinkAmbiguous

A mention left as text: more than one note could be meant.

object
path
required

The note the mention is in.

string
text
required

The mention, as written.

string
reason
required

Same_name: several notes have this name; adjacent: names of different notes side by side, which may be one name; overlap: names of notes overlap; part_of_name: a capitalized word next to it suggests a longer name; sentence_start: a one-word name at the start of a sentence, a line, a list item or a label, where its capital says nothing.

string
Allowed values: same_name adjacent overlap part_of_name sentence_start
candidates
required

Vault paths of the notes it may name.

Array<string>
context
required

The line around the mention.

string
hint
required

What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.

string

Example

{
"violations": [
{
"violations": [
{
"code": "required"
}
]
}
],
"ambiguous_mentions": [
{
"reason": "same_name"
}
]
}