Stop a unit
Code Mode: praxis.devops.units.stop
HTTP: POST /devops/v1/units/{id}:stop
Stop a running unit: the sandbox pauses its machine and the unit moves from available to shutting_down and then shutdown. A stopped unit is kept, not destroyed — start it again to resume the same machine — and it is destroyed only when its retention expires or it is deleted. Stopping a unit that is not available, or one with another transition in flight, is refused with 409 UNIT_INVALID_STATE; read the unit to see its phase first.
签名
praxis.devops.units.stop(args:{path:{/** e.g. "wsu_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string}}):Promise<{/** The unit identifier, used by every other unit operation and never reused once the unit is deleted. e.g. "wsu_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string;/** The resource type of this answer, always unit. */ object:"unit";/** RFC 3339 UTC time the unit was opened; the unit list is ordered by it, newest first. e.g. "2026-11-11T10:00:00Z" */ createTime:string;/** RFC 3339 UTC time the unit's own fields last changed. e.g. "2026-11-11T10:05:00Z" */ updateTime:string;/** Canonical Console link for this unit; use it in a message so a person can open the same machine. e.g. "https://console.deepraxis.com/devops/dvp_01m6j8swzteapw2j5sh4/units/wsu_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ viewerUrl:string;/** The project this unit belongs to, from the project list. e.g. "dvp_01m6j8swzteapw2j5sh4" */ project:string;/** The workspace configuration this unit was created from, from the project's workspace list. e.g. "wks_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ workspace:string;stage:"development"|"integration"|"release";/** What sort of work the unit carries, which is the subject's kind with the run kinds spelled out. e.g. "change" */ kind:"change"|"environment_run"|"test_run"|"prebuild_build";subject:{/** Which kind of subject this unit serves. e.g. "change" */ kind:"change"|"environment"|"test"|"prebuild";/** The change this unit develops, present when kind is change; the id is the change's branch name, such as feat/run-page-v2. e.g. "feat/run-page-v2" */ change?:string|null;/** The environment the run belongs to, present when kind is environment; from the project's environment list. e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment?:string|null;/** The promotion that opened the run, present when kind is environment. e.g. "prm_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ promotion?:string|null;/** The test run this unit serves, present when kind is test. e.g. "trn_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ run?:string|null;/** The commit being prebuilt, present when kind is prebuild; a full 40-character commit. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ commit?:string|null};spec:{/** The state the unit was last asked to be in; it does not change when the machine fails, so a failed unit can still read running here. e.g. "running" */ desired:"running"|"stopped"|"deleted";/** How many times the unit's spec has been written; it rises with each verb, so an observation can be matched against the spec it saw. e.g. 2 */ specVersion:number;size:"small"|"medium"|"large"|"xlarge";source:{/** Which source the unit's machine was created from. e.g. "template" */ kind:"template"|"prebuild";/** The template the machine was built from, present when kind is template. e.g. "base" */ template?:string|null;/** The prebuild the machine started from, present when kind is prebuild. e.g. "pbd_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ prebuild?:string|null;/** The commit the prebuild was built at, present when kind is prebuild. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ commit?:string|null}};status:{phase:"queued"|"provisioning"|"available"|"shutting_down"|"shutdown"|"starting"|"failed"|"deleted";/** RFC 3339 UTC time the phase was last observed, or null before the first observation; a phase older than expected means the machine has not been read recently. e.g. "2026-11-11T10:05:00Z" */ observedAt:string|null;/** Why the unit stopped, or null while it is not stopped. */ stopReason:null|"user"|"idle"|"max_running"|"change_closed"|"lost"|"completed";/** The sandbox's own words for why the machine ended, quoted verbatim and never rewritten; null while the unit has not ended. e.g. "The instance was terminated by the provider." */ terminationReason:string|null;/** The sandbox handle for this unit's machine, or null before the sandbox has placed one and after it is gone; it never carries a vendor name. */ sandbox:null|{/** The sandbox's id for this machine; treat it as opaque and never parse it. e.g. "sbx_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ instance:string;/** Opaque route to the running machine, used by the platform to reach it; never build one from an instance id. e.g. "rt-a1b2c3d4e5f6" */ route:string}};/** What the unit's checkout last showed, or null before any observation has been recorded. */ git:null|{/** The branch checked out on the machine, which is the change's branch name. e.g. "feat/run-page-v2" */ branch:string;/** The commit the branch was last observed at, or null before any observation. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ head:string|null;/** How many commits the branch is ahead of the base the checkout was compared with; 0 before any observation. e.g. 0 */ ahead:number;/** How many commits the branch is behind that base; 0 before any observation. e.g. 0 */ behind:number;/** Whether the checkout has changes that were not committed; a unit with this true is refused by delete unless force is sent. e.g. false */ uncommitted:boolean;/** Whether the branch has commits that were not pushed; a unit with this true is refused by delete unless force is sent. e.g. false */ unpushed:boolean;/** The ref holding the unit's work in progress, or null when none was recorded. e.g. null */ wipRef:string|null;/** The branch's head on the remote as of the last fetch: the value units push wants as expectedHead. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ remoteHead?:string;/** RFC 3339 UTC time these facts were observed, or null before the first observation. e.g. "2026-11-11T10:04:00Z" */ observedAt:string|null};/** Whether the unit started from a prebuild that is no longer the current one, so it should be opened again to pick up the latest; false for template units. e.g. false */ stale:boolean;/** RFC 3339 UTC time after which a stopped unit is destroyed, or null while it is running or has no retention. e.g. "2026-11-18T10:05:00Z" */ retainUntil:string|null;/** RFC 3339 UTC time the unit was last seen doing something, used to decide idleness, or null before any activity was observed. e.g. "2026-11-11T10:05:00Z" */ lastActiveTime:string|null;/** The unit's most recent transition records, present only when the retrieve asked for expand=transitions. */ transitions?:Array<{/** Position in the unit's record, starting at 1 and rising by one; read the records in this order. e.g. 1 */ seq:number;/** The unit this record belongs to. e.g. "wsu_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ unit:string;/** The verb this record is about. e.g. "create" */ transition:"create"|"start"|"stop"|"delete"|"fetch"|"push"|"wip"|"observe"|"exec";/** What moved the unit: a caller, or something the platform noticed. e.g. "user" */ reason:"user"|"agent"|"idle"|"change_merged"|"change_abandoned"|"retention"|"lost"|"system";/** Who asked, written as human:<user id>, agent:<agent id> or system, so the record reads the way it did when it was written. e.g. "human:usr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ actor:string;/** The unit spec version this verb was applied to, matching the specVersion on the unit at that time. e.g. 1 */ specVersion:number;/** RFC 3339 UTC time the verb was accepted. e.g. "2026-11-11T10:00:00Z" */ startedAt:string;/** RFC 3339 UTC time the verb finished, or null while it is still pending. e.g. "2026-11-11T10:00:20Z" */ finishedAt:string|null;/** How the verb ended: pending while it is in flight, then succeeded or failed. e.g. "succeeded" */ outcome:"pending"|"succeeded"|"failed";/** Why the verb failed, or null when it did not. */ error:null|{/** The refusal's code, the sandbox's own when it came from there; treat it as text to show, not as a platform error code to branch on. e.g. "instance_creation_failed" */ code:string;/** The refusal's message, the sandbox's own words when it came from there. e.g. "no instance available in the requested region" */ message:string}}>}>;参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| id | path | string | 是 | The unit identifier returned by the unit create answer or a unit list, such as wsu_…; not the id of the change it was opened for. |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 200 | application/json | The unit after the stop was accepted, moving from available towards shutdown. |
| 401 | application/json | The API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying. |
| 403 | application/json | The credential carries no organization, or that organization cannot reach this project; use a key belonging to the project’s organization. No cross-organization read is possible. |
| 404 | application/json | UNIT_NOT_FOUND means no unit with that id is visible to this organization — a unit belonging to another organization answers the same way, so its existence is not revealed; list the project’s units and use an id from that answer. |
| 409 | application/json | UNIT_INVALID_STATE means the unit is not in a phase where this verb applies — starting one that is already available, for example, or acting while another transition is still in flight; read the unit to see its phase, and retry once it has settled. Nothing changed. |
| 500 | application/json | INTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again. |