Skip to content
Fuse
Esc
↑↓navigate↵open⌘Jpreview

Create build

Runs a Fusefile’s setup phase on the orchestrator: resolves the setup layer cache, boots a builder (seeded from the deepest stored layer), runs each remaining setup step (snapshotting each cacheable one as a layer), snapshots the result as the build artifact and destroys the builder. A failure destroys the builder too; layers already snapshotted stay, so a retry resumes from the last good one.

The client plans the setup: it renders the scripts and derives each step’s layer key, since only it can read the files a step’s inputs name. fuse build does this from a Fusefile.

Answers 202 with the build at once and keeps running when the caller goes away; follow it with GET /v1/builds/{buildId}. The build runs as the restate Build/{build_id} workflow (secrets sealed with TOKEN_ENCRYPTION_KEY) and resumes at the step it was on after an orchestrator restart.

setup.prelude and setup.files are each ended with a newline if they lack one, so the next fragment starts a command of its own.

An Idempotency-Key names the build: a retry with the same key and body returns it (with Idempotent-Replayed: true) instead of starting another, and the same key with a different body is a 409.

POST/v1/builds
Authorization
AuthorizationBearer token · headerrequired
`Authorization: Bearer <token>` — either the static master token (`ORCH_AUTH_TOKEN`) or a revocable API key issued via /v1/api-keys (API keys require Postgres; without a database only the master token is accepted). Master-only surfaces (exec, attach, API key management) refuse API keys with 403. An expired key is refused with 401 like an unknown one. A key minted with `scopes` reaches only the hitl routes (`/v1/interventions`, `/v1/hitl/*`, and POST /v1/api-keys to mint a narrower key). Any other route is 403 code `forbidden`, reason `env_scope`, except an `/v1/environments/{vmId}` route for an environment the key does not cover, which is 404 so the key cannot probe which environments exist. **Authentication can be disabled entirely.** When neither `ORCH_AUTH_TOKEN` nor an API key store (`DATABASE_URL`) is configured — the default local-development posture — the bearer middleware becomes a pass-through: every operation this document marks as secured is reachable with no credentials, requests carry no principal, and master-only surfaces therefore admit everyone. Never run that configuration on a reachable network; set `ORCH_REQUIRE_AUTH=true` to make the orchestrator refuse to start without a master token.
or
fuse_sessionAPI key · cookierequired
HttpOnly session cookie set by POST /login for browser callers. Consulted only when no Authorization header is present.
Header parameters
Idempotency-Keystring
1 to 255 visible ascii characters naming the build.
Request body
requiredapplication/json
namestringrequired
Labels the build artifact and its layers.
specResourceSpec
Hardware requirements for a VM. cpus, ram_mb and storage_gb left at 0 (or omitted) get a default before scheduling: 1 vCPU, 1024 MB and 4 GB, and the VM is scheduled and booted at that size. A negative value is a 400.
Show properties
cpusinteger<int32>
vCPU count. 0 or omitted means the default, 1.
min 0
ram_mbinteger<int32>
Memory in MB. 0 or omitted means the default, 1024.
min 0
storage_gbinteger<int32>
Storage in GB. 0 or omitted means the default, 4, the size of the baked base rootfs.
min 0
gpusinteger<int32>
Count of GPU devices requested. Zero means no GPU. With gpu_profile unset, this is whole devices; with gpu_profile set, this is the count of MIG instances of that profile (decision D5).
min 0
gpu_kindstring
Optional GPU model to match (e.g. "a100"). Empty matches any kind on a host that has GPUs.
gpu_profilestring
Optional MIG profile in mig-parted vocabulary (e.g. "1g.10gb"). When set, gpus counts MIG instances of this profile rather than whole devices, and the qemu host agent attaches them via vfio-pci sysfsdev (decision D5).
imagestring
Optional named base rootfs for the provider to boot from (resolved by the host agent against its named-rootfs directory). Empty means the provider's default base image.
image_digeststring
Boots an oci image converted with POST /v1/images (the `digest` it returned). The create is pinned to a host where the image is ready; a digest that is not ready on any host the environment could land on is a 409. Mutually exclusive with `image` and `seed_snapshot_id`; not allowed with `gpus` or a `desktop`.
matches ^[0-9a-f]{64}$
regionstring
host_idstring
Pins the environment to an exact host id (the Fusefile's placement.host). A pin is a hard gate, not an override: the host must still be active, run the right backend, and fit the request. An unknown host id is rejected with 404 before any VM is created.
labelsobject
Placement label selectors (the Fusefile's placement.labels). Every pair must match the target host's operator-declared labels. A selector that matches no host is rejected with 503, never queued.
huge_pagesboolean
Back guest memory with 2M pages. The host must have that much memory reserved as hugepages, or the create answers 409. Fixed for the life of the environment, and required for a lazy migrate.
max_runtime_secondsinteger<int64>
Leak-detection ceiling for this task. Zero means "use the fleet default". The orchestrator tears down tasks that exceed this age with no state transitions.
idle_timeout_secondsinteger<int64>
Destroys the environment once it has gone this long with no exec and no attach session. Zero means "use the fleet default", which is no idle expiry unless the operator configured one. Measured from the last exec or attach, not from create, and must be at least 60 (idle detection runs on the reconcile loop). In-guest CPU use and traffic on exposed ports are not observed.
manifest_inlinestring
The builder's base64 manifest, as on create.
secretsobject
The builder's secrets. Sealed before restate journals the build; redacted from its error and output.
archstring
The arch layers are looked up and filed under. Empty derives it from the spec's host or arch, or the one arch every host shares; a fleet of mixed arches then builds without the cache.
keepboolean
Leave the builder running instead of destroying it.
setupBuildSetuprequired
The setup phase cut into what the builder execs. Each exec runs the prelude, then (on a cold build's first exec) the file block, then its steps' scripts, each followed by a newline.
Show properties
preludestringrequired
filesstring
stepsBuildStep[]required
min items 1
Show properties
Array of BuildStep
scriptstringrequired
keystring
The step's layer cache key. A step without one, and every step after it, is not cached.
Responses
202The build, just started or replayed.
idstringrequired
namestringrequired
statestringrequired
Allowed:runningsucceededfailed
stepstring
queued, resolve_cache, create_builder, layer_<i>, tail, snapshot, destroy_builder or done.
builder_idstring
The builder environment, once created.
archstring
cache_hitsintegerrequired
How many setup steps the seed artifact covered.
seed_snapshot_idstring
The layer the builder booted from, on a cache hit.
layersBuildLayer[]required
Show properties
Array of BuildLayer
indexintegerrequired
keystring
statusstringrequired
hit is covered by the seed and does not run, miss runs and is snapshotted, skip cannot be cached.
Allowed:hitmissskip
snapshot_idstring
The layer this build snapshotted for the step.
snapshot_idstring
The build artifact. Boot it with `seed_snapshot_id` on create, or `fuse up --from-build`.
errorstring
outputstring
The redacted tail of the setup exec that failed.
created_atstring<date-time>required
updated_atstring<date-time>required
finished_atstring<date-time>
400Malformed request.
errorobjectrequired
Show properties
codestringrequired
Stable machine-readable code. `route_not_found` (404) means the URL matches no route this server exposes — usually a wrong host, port, or path prefix — as opposed to `not_found`, where the route exists but the resource does not. `forbidden` is emitted by CIDR-allowlist rejections and by hitl access checks, which set `details.reason` (see the Forbidden response); master-only refusals (exec, attach, listing and revoking API keys) return 403 with code `unauthorized`.
Allowed:not_foundroute_not_foundconflictinvalid_argumentunauthorizedforbiddenunavailableinternalunimplementedlocked
messagestringrequired
Human-readable description.
detailsobject
Optional stable, non-sensitive metadata (e.g. ids, counts). Omitted when empty. A 403 `forbidden` from a hitl access check carries `reason` (`missing_scope`, `env_scope`, `self_approval`, `actor_required`, `actor_mismatch`, `actor_not_allowed`, `mint_escalation`, `hitl_denied`), plus `scope` for `missing_scope`, and `gate` and `intervention_id` for `hitl_denied`. A 423 `locked` carries `intervention_id` and `kind` (`takeover` or `stall`).
404Resource does not exist. Note the distinct code `route_not_found`, returned when the URL matches no registered route at all (wrong host, port, or path prefix) rather than a known route with a missing resource.
errorobjectrequired
Show properties
codestringrequired
Stable machine-readable code. `route_not_found` (404) means the URL matches no route this server exposes — usually a wrong host, port, or path prefix — as opposed to `not_found`, where the route exists but the resource does not. `forbidden` is emitted by CIDR-allowlist rejections and by hitl access checks, which set `details.reason` (see the Forbidden response); master-only refusals (exec, attach, listing and revoking API keys) return 403 with code `unauthorized`.
Allowed:not_foundroute_not_foundconflictinvalid_argumentunauthorizedforbiddenunavailableinternalunimplementedlocked
messagestringrequired
Human-readable description.
detailsobject
Optional stable, non-sensitive metadata (e.g. ids, counts). Omitted when empty. A 403 `forbidden` from a hitl access check carries `reason` (`missing_scope`, `env_scope`, `self_approval`, `actor_required`, `actor_mismatch`, `actor_not_allowed`, `mint_escalation`, `hitl_denied`), plus `scope` for `missing_scope`, and `gate` and `intervention_id` for `hitl_denied`. A 423 `locked` carries `intervention_id` and `kind` (`takeover` or `stall`).
409Conflicts with current state (e.g. duplicate task assignment).
errorobjectrequired
Show properties
codestringrequired
Stable machine-readable code. `route_not_found` (404) means the URL matches no route this server exposes — usually a wrong host, port, or path prefix — as opposed to `not_found`, where the route exists but the resource does not. `forbidden` is emitted by CIDR-allowlist rejections and by hitl access checks, which set `details.reason` (see the Forbidden response); master-only refusals (exec, attach, listing and revoking API keys) return 403 with code `unauthorized`.
Allowed:not_foundroute_not_foundconflictinvalid_argumentunauthorizedforbiddenunavailableinternalunimplementedlocked
messagestringrequired
Human-readable description.
detailsobject
Optional stable, non-sensitive metadata (e.g. ids, counts). Omitted when empty. A 403 `forbidden` from a hitl access check carries `reason` (`missing_scope`, `env_scope`, `self_approval`, `actor_required`, `actor_mismatch`, `actor_not_allowed`, `mint_escalation`, `hitl_denied`), plus `scope` for `missing_scope`, and `gate` and `intervention_id` for `hitl_denied`. A 423 `locked` carries `intervention_id` and `kind` (`takeover` or `stall`).
503No registered host has room for this spec — the scheduler found no capacity, or no hosts are registered at all (code `unavailable`). This includes the GPU case: a spec asking for GPUs a host cannot satisfy lands here. It is also the answer when the orchestrator could not reach restate, which runs every mutating operation: nothing was started. Either way it is worth retrying, once capacity frees up or restate is back: these 503s carry `Retry-After` (seconds), and the SDKs retry create, fork and the other operation calls with jittered backoff that waits at least that long, under the same `Idempotency-Key`. A 503 from the guest (a computer action with no display) carries no `Retry-After` and is not retried.
errorobjectrequired
Show properties
codestringrequired
Stable machine-readable code. `route_not_found` (404) means the URL matches no route this server exposes — usually a wrong host, port, or path prefix — as opposed to `not_found`, where the route exists but the resource does not. `forbidden` is emitted by CIDR-allowlist rejections and by hitl access checks, which set `details.reason` (see the Forbidden response); master-only refusals (exec, attach, listing and revoking API keys) return 403 with code `unauthorized`.
Allowed:not_foundroute_not_foundconflictinvalid_argumentunauthorizedforbiddenunavailableinternalunimplementedlocked
messagestringrequired
Human-readable description.
detailsobject
Optional stable, non-sensitive metadata (e.g. ids, counts). Omitted when empty. A 403 `forbidden` from a hitl access check carries `reason` (`missing_scope`, `env_scope`, `self_approval`, `actor_required`, `actor_mismatch`, `actor_not_allowed`, `mint_escalation`, `hitl_denied`), plus `scope` for `missing_scope`, and `gate` and `intervention_id` for `hitl_denied`. A 423 `locked` carries `intervention_id` and `kind` (`takeover` or `stall`).
Request
curl -X POST "http://localhost:8080/v1/builds" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "spec": {
    "cpus": 0,
    "ram_mb": 0,
    "storage_gb": 0,
    "gpus": 0,
    "gpu_kind": "string",
    "gpu_profile": "string",
    "image": "string",
    "image_digest": "string",
    "region": "string",
    "host_id": "string",
    "labels": {},
    "huge_pages": true,
    "max_runtime_seconds": 0,
    "idle_timeout_seconds": 0
  },
  "manifest_inline": "string",
  "secrets": {},
  "arch": "string",
  "keep": true,
  "setup": {
    "prelude": "string",
    "files": "string",
    "steps": [
      {
        "script": "string",
        "key": "string"
      }
    ]
  }
}'
Response
{
  "id": "string",
  "name": "string",
  "state": "running",
  "step": "string",
  "builder_id": "string",
  "arch": "string",
  "cache_hits": 0,
  "seed_snapshot_id": "string",
  "layers": [
    {
      "index": 0,
      "key": "string",
      "status": "hit",
      "snapshot_id": "string"
    }
  ],
  "snapshot_id": "string",
  "error": "string",
  "output": "string",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z",
  "finished_at": "2024-01-01T00:00:00Z"
}