Move a unit to another place in the tree
Code Mode: praxis.studio.works.units.move
HTTP: POST /studio/v1/works/{work}/units/{unit}:move
Move a unit under another parent or after another sibling, without changing its number, its identifier, its intent or its body. A move that would put a unit inside its own descendant, or that would cross into another draft, is refused. Only the moved unit changes, so the revision to pass is its own.
Signature
praxis.studio.works.units.move(args:{path:{/** e.g. "wu-gang" */ work:string;/** e.g. "12" */ unit:string};body:{/** Unit revision the caller read; a mismatch is refused so a move never lands on a unit someone else just changed. e.g. 6 */ expected_revision?:number;/** Unit to move this one under, by number or identifier; null or omitted moves it to the top level. e.g. "2" */ parent?:string;/** Sibling to place this unit after, by number or identifier; null or omitted puts it first among its new siblings. e.g. "18" */ after?:string}}):Promise<{value:{/** Unit identifier, stable when units are moved or renamed. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Work this unit belongs to; it is the same value the work path segment carries. e.g. "wk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ work?:string;/** Draft this unit belongs to; units never move between drafts. e.g. "drf_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ draft?:string;/** In-work number assigned in creation order, never reused and unchanged by a move; it is what the unit path segment takes. e.g. 12 */ number:number;/** Unit this one sits under, or null at the top level of the tree. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ parent?:string;/** Sort key among siblings; it is opaque, and moving a unit rewrites only its own row. e.g. "0|hzzzzz:" */ position?:string;/** Structural kind of this unit, which must be one the genre allows at this position of the tree. e.g. "chapter" */ kind:string;/** Structure name used by people and agents to manage the tree, such as the second scene of a chapter; it is not the published heading. e.g. "第二章 · 排字房" */ name:string;/** Heading the finished piece shows for this unit, or null when it shows none; a genre may require it or forbid it. e.g. "第二章 排字房" */ heading?:string;intent:{/** What this unit has to accomplish, written as the story so far for later units; it is what a reader of the outline sees. e.g. "主角在排字房看到通缉令,第一次动摇了立场。" */ synopsis:string;/** Points this unit hits, called beats, arguments or selling points depending on the genre. */ points:Array<string>;/** Keys of the brief points this unit claims, which is how the requirement coverage check knows a point landed. */ brief_points:Array<string>;/** Intent revision, moved whenever the synopsis or the points change; a body written against an older value is behind. e.g. 4 */ revision:number;/** Whether the writer confirmed the synopsis matches what the body actually says, rather than what was planned. */ synopsis_from_body:boolean};/** How far this unit has come, moving forward as intent and body are written; a unit marked final refuses changes without confirmation. */ status:"idea"|"outlined"|"writing"|"drafted"|"revised"|"final";/** Intent revision the current body was written against, or null when there is no body; an older value means the intent moved on. e.g. 4 */ body_from_intent?:number;/** Unit of the upstream draft this one was written from, present when the draft derives from another; a serial of a novel records it per section. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ source_unit?:string;/** Reference entries this unit is tied to, including the mentions detected in its text. */ links?:Array<{/** Identifier of the reference entry this unit is tied to. e.g. "ent_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ entry?:string;/** How the tie came about, which decides whether the entry reaches the context pack for this unit. */ kind?:"mention"|"attached"|"excluded";/** Role of the entry inside this genre, such as point-of-view character or main product; it lifts the entry's priority in the pack. e.g. "视角人物" */ role?:string}>;/** Characters in the body with whitespace removed, which is what the length checks measure. e.g. 2680 */ chars:number;/** Duration in seconds for units of a video genre, or null for a written unit. e.g. 42 */ seconds?:number;/** Unit revision, moved by any change to the unit; pass it as expected_revision when writing the body. e.g. 6 */ revision:number;last_editor?:{/** Whether the change came from a person, an agent or the platform itself; an agent session through the API is recorded as an agent. */ kind?:"user"|"agent"|"system";/** Identifier of that actor, such as a user identifier or an agent session identifier. e.g. "usr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id?:string;/** Display name of the actor when one is known, shown beside the change. e.g. "张三" */ label?:string};/** Body blocks, present only when the unit was read with its content; writing block by block needs their identifiers. */ blocks?:Array<{/** Block identifier, carried inline in Markdown as an anchor comment so an edit can address one block without rewriting the body. e.g. "blk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** Unit revision at which this block was last changed; it decides whether an older precondition still allows a block edit. e.g. 6 */ revision:number;/** Element kind of this block, from the set the genre allows; it decides how the block is rendered in a rendition. */ type:"paragraph"|"heading"|"list"|"quote"|"code"|"image"|"video"|"divider"|"scene_break"|"callout"|"hashtags"|"link"|"cut"|"canvas";/** Markdown text of this block, empty for blocks that carry a reference instead of words. e.g. "排字房的铅字盘上,压着一张通缉令。" */ text:string;/** File this block shows, for image and video blocks, referenced by its file identifier. e.g. "file_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ file?:string;/** Caption shown with a media block and carried into renditions that keep captions. e.g. "1935 年的排字房" */ caption?:string;/** Heading depth for a heading block, one to four, which decides the outline level in the finished piece. e.g. 2 */ level?:number}>};/** Deterministic checks of the genre run against this write, such as a length bound or a banned word. */ checks?:Array<{/** Key of the check that produced this row, such as unit_chars or body_total_chars; the genre lists which ones it runs. e.g. "unit_chars" */ check:string;/** Whether the check passed; a failed hard check blocks publishing until the text changes. */ ok:boolean;/** What the check found, in words, including the measured value and the bound it broke. e.g. "本章 2680 字,低于 3000 字的目标。" */ text:string;/** Unit the finding is about, present when the check is per unit. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ unit?:string;/** Block the finding is about, present when the check is per block, such as a missing image or a banned word. e.g. "blk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ block?:string;/** How serious the finding is: an error fails the check, a warning is reported without failing it. */ severity:"error"|"warning";/** Whether this is a platform hard limit, which is the only kind a free-writing genre puts into its todo list. */ hard:boolean}>;/** First items of the draft todo list now, so the caller continues with the next unit instead of reading the status again. */ next?:Array<{/** What is outstanding, chosen from a closed set so a caller can branch on it instead of reading the text. */ kind:"goal_incomplete"|"brief_points_unplaced"|"no_structure"|"intent_missing"|"intent_ahead_of_body"|"body_missing"|"draft_stale"|"work_adaptation_stale"|"prop_missing"|"check_failed"|"review_unresolved"|"rendition_stale"|"rendition_missing"|"publish_blocked";/** Which of the seven layers this item belongs to, used to order the list; the layers are always in the same order. */ layer:"goal"|"frame"|"task"|"reference"|"body"|"coherence"|"rendition";/** Unit this item is about, present when the item points at one unit rather than the whole draft. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ unit?:string;/** In-work number of that unit, which is what the unit path segment of a call takes. e.g. 12 */ number?:number;/** The item in words, written to be shown to a person as is. e.g. "第 12 节还没有正文" */ text:string;/** For a check_failed item, the key of the failing check, so a program can act on it without parsing the text; a unit that already has an item for it gets no separ e.g. "body_total_chars" */ check?:string;/** Suggested next call for this item, offered as guidance rather than a fixed script. e.g. "praxis.studio.works.units.retrieveContext" */ call?:string}>}>;Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| work | path | string | yes | The work being addressed, either its organization-unique slug or its wk_ identifier; a slug case is what a person would say, and a renamed slug still resolves through its old value. |
| unit | path | string | yes | Unit being addressed, written as its in-work number such as 12, as #12, or as its unt_ identifier; the number never changes when the unit is moved. |
Request body
| Required | Content types | Description |
|---|---|---|
| yes | application/json | Where the unit should sit: a parent to move under, a sibling to move after, or both to place it precisely. |
Responses
| Status | Content types | Description |
|---|---|---|
| 200 | application/json | The moved unit with its new position, plus the checks and next todos of the draft. |
| 400 | application/json | INVALID_PARAMS means a field is missing, malformed or not allowed for this resource; correct the named field and repeat the call. |
| 401 | application/json | The API key is missing, invalid or carries no organization; send a valid organization key in the Authorization header. |
| 404 | application/json | WORK_NOT_FOUND, DRAFT_NOT_FOUND or UNIT_NOT_FOUND means one address in the path names nothing reachable; use the numbers and keys from the outline rather than a remembered one, since a unit that was deleted never returns. |
| 409 | application/json | REVISION_CONFLICT means the resource changed since the expected_revision you sent, so nothing was written; re-read it, merge the other change into yours and repeat the call with the revision you just read. |
| 422 | application/json | UNIT_MOVE_INVALID means the requested position would put a unit inside its own descendant or into another draft; choose a parent outside that unit’s subtree. |
| 500 | application/json | INTERNAL means the request could not complete; re-read the resource before retrying a write, because the write may already have landed. |