Save document as
save_document_asPersist the current working-copy state of an Inkscape document to a new file in the workspace, with support for relative paths and automatic subfolder creation.
Instructions
Save a document's current working-copy state to a NEW file in the workspace.
When to use: persisting the working copy to disk. To export a raster/PDF instead use
export_document; to snapshot in-server state (not a file) use create_snapshot. The original
and source files are never touched.
Key params: dest_path may be RELATIVE or absolute — relative anchors to the FIRST configured
workspace root (NOT the server CWD); absolute must resolve inside a configured root. A dest into
a not-yet-existing SUBFOLDER (e.g. "output/final.svg") is supported: missing parents are
created only after proving they resolve INSIDE the workspace (a ..-escaping / out-of-sandbox
dest creates nothing and is rejected with path rejected: outside workspace). The dest is
sandbox- and symlink-checked (incl. a pre-existing symlink at the final name) and the copy never
follows a symlinked dest (sec.12). Overwriting an existing file requires overwrite=True PLUS a
non-empty approval_token.
Return shape: SaveResult — saved_path (workspace-relative POSIX), operation_id,
overwritten, and pre_validation / post_validation (the validate_document reports from
before and after the write).
Example: save_document_as(doc_id, "output/final.svg")
Risk class: medium for a new-file save; high (approval-gated) when overwriting an existing file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| dest_path | Yes | ||
| overwrite | No | ||
| approval_token | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| saved_path | Yes | ||
| overwritten | Yes | ||
| operation_id | Yes | ||
| pre_validation | Yes | Structured, machine-readable validation result for one document. `ok` is True iff there are no `error`-severity findings. `error_count` / `warning_count` are convenience tallies over `findings`. | |
| post_validation | Yes | Structured, machine-readable validation result for one document. `ok` is True iff there are no `error`-severity findings. `error_count` / `warning_count` are convenience tallies over `findings`. |