ALTER TABLE ADD CONSTRAINT `name` CHECK: `check` is a where filter every row must match,
const url = 'https://example.com/datanotes/operations/add_constraint/';const options = { method: 'POST', headers: { 'X-Datanotes-Actor': '{"harness":"my-script","model":"","session":"s-1"}', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"table":"example","name":"example","check":{},"dry_run":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/datanotes/operations/add_constraint/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'X-Datanotes-Actor: {"harness":"my-script","model":"","session":"s-1"}' \ --data '{ "table": "example", "name": "example", "check": {}, "dry_run": false }'ALTER TABLE ADD CONSTRAINT name CHECK: check is a where filter every row must match,
e.g. {"value": {"gte": 1, "lte": 5}}. A condition on a column the row leaves empty passes, like SQL;
inside or / and / not an empty value is tested as it is ({"exists": true} there fails).
A key may follow a link column to the row it names, as in queries: {"parent.kind": "project"}
(further dots follow further links). An empty link passes at the top level and fails inside or / and /
not; only the first link of a longer path is skipped when empty (parent.parent.kind fails for a row
whose parent has no parent). A link to a row that does not exist fails; on a list of links every linked
row must match. not turns that into a pass: {"not": {"parent.kind": "area"}} passes a link to a
missing row, so add "parent.kind": {"exists": true} to require a real one. Links resolve as in the
vault (by path, from the row’s note: same-named rows in two folders stay apart); renaming or moving a
linked row keeps them (they follow it).
Refused while existing rows violate it (they are listed); then enforced on every write, by the same rule.
A write that changes a linked row re-checks the rows that link to it and is refused, listing them, when
it breaks them, naming the changed row (in a batch, re-link them first: each step is checked on the vault
the earlier ones left); the inverse links a write adds, undo_migration and restore_table are checked too.
rename_column / rename_value follow into CHECKs; drop_column of a column a CHECK reads is refused.
The schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”JSON: on whose behalf the write is made, recorded in the journal (harness, model, session).
Example
{"harness":"my-script","model":"","session":"s-1"}Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Responses
Section titled “Responses”Done.
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
True when the operation was applied (or, on a dry run, would be).
The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).
True when nothing was written (preview).
Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.
Notes whose front matter or body were written.
Files created.
Files moved or renamed.
Files deleted or archived.
Links rewritten in other notes.
Reasons the operation was refused (empty on success).
object
Note or file path.
Why the operation cannot proceed.
Rows that would break the table’s rules (empty on success).
The violations of one row.
object
Row note path.
What is wrong with this row.
object
The column the violation is about (every code but check and unreadable).
The item of a list column that breaks the rule, from 0.
The CHECK’s name (code check).
Kind of violation.
Agent-readable explanation.
The offending value, when there is one.
Files that could not be written (empty on success).
object
Vault path.
What went wrong.
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).
Front matter edits per note (planned, or made).
object
Note path.
Front matter keys set, with their new values.
object
Front matter keys removed.
True when the note body changes too.
Paths of notes created.
Files moved: from → to.
object
Paths deleted (or archived).
Files rewritten whole, e.g. metastore.yaml for DDL.
Transaction-log commits written (tables with history on).
object
Qualified table.
New log version.
Log operation, e.g. WRITE.
Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.
A link the write added in place of a mention.
object
The note the link was written into.
The mention, as written.
Vault path of the note it links.
The link written in place of the mention.
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.
A mention left as text: more than one note could be meant.
object
The note the mention is in.
The mention, as written.
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.
Vault paths of the notes it may name.
The line around the mention.
What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.
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.
object
What went wrong, for a person or an agent.
Example generated
{ "error": "example"}Missing or wrong bearer token.
object
What went wrong, for a person or an agent.
Example generated
{ "error": "example"}A named token beyond its permissions (the engine’s administration, tables outside its write patterns, schema changes without ddl).
object
What went wrong, for a person or an agent.
Example generated
{ "error": "example"}Unknown table, view, migration, note or folder.
object
What went wrong, for a person or an agent.
Example generated
{ "error": "example"}Ambiguous table name: it matches several tables (paths or tables lists them).
object
The tables’ folders the name matches.
The qualified tables the name matches.
Example generated
{ "error": "example", "paths": [ "example" ], "tables": [ "example" ]}Refused (validation failures, conflicts, an unmet expect): nothing written. Same body as 200, with ok: false and the reasons.
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
True when the operation was applied (or, on a dry run, would be).
The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).
True when nothing was written (preview).
Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.
Notes whose front matter or body were written.
Files created.
Files moved or renamed.
Files deleted or archived.
Links rewritten in other notes.
Reasons the operation was refused (empty on success).
object
Note or file path.
Why the operation cannot proceed.
Rows that would break the table’s rules (empty on success).
The violations of one row.
object
Row note path.
What is wrong with this row.
object
The column the violation is about (every code but check and unreadable).
The item of a list column that breaks the rule, from 0.
The CHECK’s name (code check).
Kind of violation.
Agent-readable explanation.
The offending value, when there is one.
Files that could not be written (empty on success).
object
Vault path.
What went wrong.
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).
Front matter edits per note (planned, or made).
object
Note path.
Front matter keys set, with their new values.
object
Front matter keys removed.
True when the note body changes too.
Paths of notes created.
Files moved: from → to.
object
Paths deleted (or archived).
Files rewritten whole, e.g. metastore.yaml for DDL.
Transaction-log commits written (tables with history on).
object
Qualified table.
New log version.
Log operation, e.g. WRITE.
Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.
A link the write added in place of a mention.
object
The note the link was written into.
The mention, as written.
Vault path of the note it links.
The link written in place of the mention.
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.
A mention left as text: more than one note could be meant.
object
The note the mention is in.
The mention, as written.
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.
Vault paths of the notes it may name.
The line around the mention.
What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.
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).
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
True when the operation was applied (or, on a dry run, would be).
The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).
True when nothing was written (preview).
Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.
Notes whose front matter or body were written.
Files created.
Files moved or renamed.
Files deleted or archived.
Links rewritten in other notes.
Reasons the operation was refused (empty on success).
object
Note or file path.
Why the operation cannot proceed.
Rows that would break the table’s rules (empty on success).
The violations of one row.
object
Row note path.
What is wrong with this row.
object
The column the violation is about (every code but check and unreadable).
The item of a list column that breaks the rule, from 0.
The CHECK’s name (code check).
Kind of violation.
Agent-readable explanation.
The offending value, when there is one.
Files that could not be written (empty on success).
object
Vault path.
What went wrong.
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).
Front matter edits per note (planned, or made).
object
Note path.
Front matter keys set, with their new values.
object
Front matter keys removed.
True when the note body changes too.
Paths of notes created.
Files moved: from → to.
object
Paths deleted (or archived).
Files rewritten whole, e.g. metastore.yaml for DDL.
Transaction-log commits written (tables with history on).
object
Qualified table.
New log version.
Log operation, e.g. WRITE.
Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.
A link the write added in place of a mention.
object
The note the link was written into.
The mention, as written.
Vault path of the note it links.
The link written in place of the mention.
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.
A mention left as text: more than one note could be meant.
object
The note the mention is in.
The mention, as written.
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.
Vault paths of the notes it may name.
The line around the mention.
What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.
object
What went wrong, for a person or an agent.
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.
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
True when the operation was applied (or, on a dry run, would be).
The operation, by the name it was called with (e.g. insert_row, create_table, recompute_columns).
True when nothing was written (preview).
Journal id of the applied operation: pass it to undo_migration. Absent on a dry run.
Notes whose front matter or body were written.
Files created.
Files moved or renamed.
Files deleted or archived.
Links rewritten in other notes.
Reasons the operation was refused (empty on success).
object
Note or file path.
Why the operation cannot proceed.
Rows that would break the table’s rules (empty on success).
The violations of one row.
object
Row note path.
What is wrong with this row.
object
The column the violation is about (every code but check and unreadable).
The item of a list column that breaks the rule, from 0.
The CHECK’s name (code check).
Kind of violation.
Agent-readable explanation.
The offending value, when there is one.
Files that could not be written (empty on success).
object
Vault path.
What went wrong.
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).
Front matter edits per note (planned, or made).
object
Note path.
Front matter keys set, with their new values.
object
Front matter keys removed.
True when the note body changes too.
Paths of notes created.
Files moved: from → to.
object
Paths deleted (or archived).
Files rewritten whole, e.g. metastore.yaml for DDL.
Transaction-log commits written (tables with history on).
object
Qualified table.
New log version.
Log operation, e.g. WRITE.
Links the write added to the text it wrote: the notes the text mentions by name (automatic links). Present when there is one.
A link the write added in place of a mention.
object
The note the link was written into.
The mention, as written.
Vault path of the note it links.
The link written in place of the mention.
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.
A mention left as text: more than one note could be meant.
object
The note the mention is in.
The mention, as written.
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.
Vault paths of the notes it may name.
The line around the mention.
What to do: read the candidates, then link the right one with update_row and autolink: false, or leave the text.
Example
{ "violations": [ { "violations": [ { "code": "required" } ] } ], "ambiguous_mentions": [ { "reason": "same_name" } ]}