Skip to content

Put the rows of a table's closed periods into packs: one note per period (`<table> <key>.md` in the

POST
/datanotes/operations/pack_rows/
curl --request POST \
--url https://example.com/datanotes/operations/pack_rows/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Datanotes-Actor: {"harness":"my-script","model":"","session":"s-1"}' \
--data '{ "table": "example", "key": null, "dry_run": false }'

Put the rows of a table’s closed periods into packs: one note per period (<table> <key>.md in the table’s folder), a ## section per row, key:: value lines for its values. The table needs a pack option (create_table / alter_table, e.g. "{occurred_at:YYYY-MM}"). A period is closed pack_after_days days after it ends (default 7); key packs only that period. Nothing changes for the engine and its readers: select_rows, links, the graph and the change feed still see each row at its path, with its values, text and file_modified (no change event, no new version). Links from other notes to a packed row become [[pack#row]], which Obsidian follows too. A row stays a note of its own (excluded, with the reason) when it changed in the last 24 hours, has a # or ## heading in its text, is not at the path its values give, or its note is not in the form the engine writes. The engine also packs on its own once a day (setting autoPack). Needs the engine service. Journaled: undo_migration takes the rows out again. Use dry_run to see packs first.

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
table
required
string
key
Any of:
string
dry_run
boolean

Done.

Media typeapplication/json
PackRowsResult

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
hint

The CHECK’s own hint (code check), when the constraint has one: how to fix the row.

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
schema_references

Alter_table that moves or renames a table: the references to it in other definitions that it rewrites (on a dry run, would rewrite): the ref and vocabulary of the columns of other tables and of bases, and the tables the views’ queries read. Present when there is one.

Array<object>
SchemaReference

A name of the moved table in another definition, rewritten to the new name.

object
table

The table whose column names it (full name).

string
base

The base whose column names it.

string
view

The view whose query names it (full name).

string
column

The column of the table or base.

string
key
required

Where the name is: ref or vocabulary of the column, or table, union[N].table or join.table of the view’s query.

string
from
required

The name as written before.

string
to
required

The name written in its place.

string
packs

The packs written (or, on a dry run, to write): each pack’s file, its key and the rows that go in or come out.

Array<object>
object
pack
required

The pack’s file.

string
key
required

The period of its rows, as the table’s pack option writes it.

string
rows
required

The rows’ paths (each keeps its path in a pack).

Array<string>
excluded

Pack_rows: rows of closed periods that stay notes of their own, with the reason (changed in the last 24 hours, a # or ## heading in their text, not where their values put them, another YAML style).

Array<object>
object
path
required
string
reason
required
string
open_rows

Pack_rows: rows whose period is not over yet (or ended less than pack_after_days ago): not listed.

integer
warnings

What is unwise in a table’s layout, though allowed: a partition wider than the periods of the table’s packs (create_table, alter_table; check_table lists them for the tables it checks). Present when there is one.

Array<object>
object
code
required

Kind of warning.

string
Allowed values: pack_partition
table
required

The table, catalog.schema.table.

string
message
required

What is unwise, and why.

string
hint
required

How to fix it.

string
docs
required

Where to read more (a Markdown page of the docs, with its anchor).

string

Example

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

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"
}

Unknown table, view, migration, note or folder.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Ambiguous table name: it matches several tables (paths or tables lists them).

Media typeapplication/json
object
error
required
string
paths

The tables’ folders the name matches.

Array<string>
tables

The qualified tables the name matches.

Array<string>

Example generated

{
"error": "example",
"paths": [
"example"
],
"tables": [
"example"
]
}

Unexpected error.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}