Import data into branch
layerz_import_branchImport a stacked branch of values onto the model. Default mode creates a BranchDefinition (scenario branch) and writes the supplied entries as input rows tagged with the new dataset_id. Optionally set branch.actuals_through to mark its real/forecast cutover. Pass replace: true together with branch.id to atomically refresh an existing branch instead: its id and created_at are preserved, its mutable metadata is patched with any value you supply (display_name is optional here — omit it to keep the current name; supplying it is an explicit rename), the previous input rows are wiped and the new entries written — all in one persist call. Carry-forward: for a period the new entries do NOT cover, the prior value is retained (so a narrower re-sync never silently zeroes the uncovered tail). To actually clear a period, send it explicitly with value 0. The result warnings flag any line the import left all-zero though it had values before. Entries reference items by item_uid (existing) or item_label (matched by display_name, else created as assumption). Instead of entries, pass file_id (from layerz_create_upload_url) to import a spreadsheet server-side: the file is parsed, each row is classified with THIS model's mapping set (the same rules layerz_list_mappings shows — no need to copy them), aggregated per (item, period), and written. A rule targeting a LIST-MODE item resolves each row's list entry from its category/dimension column (cost center / BU — e.g. the DATEV Kostenstelle) matched against the list entries by label; a row whose dimension matches no entry is skipped per-row, never a whole-import failure. A raw DATEV EXTF/Buchungsstapel export is detected natively (metadata line skipped, Umsatz signed by the Soll/Haben mark, compact Belegdatum dated from the fiscal-year header) — pair it with the Germany (SKR03) or (SKR04) mapping template matching the ledger's chart. Add sheet_name for a multi-sheet workbook and structure_override to fix a misdetected ledger (e.g. a Débit/Crédit split, an S/H sign_column, or an account-code column taken as the label). Re-importing an existing source? Pass replace_source_id (id from layerz_list_integrations) to refresh that file source's staged transactions in place instead of creating a second one; a legacy empty file source bound to the branch is adopted automatically. Exactly one of entries or file_id is required; the result then also carries skipped (rows that produced no entry) and mapping_drift (rules whose target item no longer exists). Each entry's timeline_ref must match the target item's native grain exactly (or be constant, which broadcasts to any grain). Any other grain — finer or coarser — is rejected to avoid corrupting other periods, because rows resolve cell-by-cell by raw array index. Aggregate (or split) the source to the item's grain before importing. Targeting a formula or balance item writes a per-period override (actual): on covered periods the imported value replaces the computed one and feeds downstream periods (e.g. actuals-then-forecast). Compute resolves cells by branch priority at load time. Result: entries_written counts supplied entries; inputs_written counts persisted rows after per-period compaction (≤ entries_written) and mirrors delete_branch.inputs_removed. Pass dry_run: true to preview the impact WITHOUT persisting: the model is left untouched and the result carries would_persist:false, the same inputs_written/inputs_removed/created_items/matched_items counts, overridden_items (existing items whose value this branch would overlay), and validation_errors_new (errors the import would introduce). Audit it, then re-call without dry_run to commit. Deterministic. Prefer the file_id path for spreadsheets (server-side parse + classify); build entries by hand only for values you compute yourself. Not available for read-only API keys.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| merge | No | ||
| branch | Yes | ||
| dry_run | No | ||
| entries | No | ||
| file_id | No | Upload id from layerz_create_upload_url ('f_' + 16 hex chars). Alternative to entries[]. | |
| replace | No | ||
| summary | Yes | Required: short human-readable note (3–100 chars) summarising what this change does. Shown as the label in the model version history. Be specific (e.g. "Renamed Revenue to Net Revenue", "Imported 2024 OPEX from Excel"). | |
| model_id | No | Target model UUID. Required for user-scoped API keys; ignored (or validated against scope) for model-scoped keys. | |
| sheet_name | No | ||
| record_import | No | ||
| replace_scope | No | ||
| replace_source_id | No | file_id path only: refresh this existing file source in place (id from layerz_list_integrations) instead of creating a second one. | |
| structure_override | No | Override auto-detected columns for a long-format/ledger file (e.g. value_column chose "Débit" and dropped credit rows, or an account-code column won the label). Omitted fields stay auto-detected. |