Skip to content

Full-lab build API

POST /api/labs/build accepts a complete design for a new lab in one request. Use mode=validate to check the design, then submit the same body with mode=apply to create it. Both calls require an authenticated user with access to the destination folder. Applying a design leaves its nodes stopped.

Build a two-router lab

Choose an installed template and matching image in nova-ve. The example uses a QEMU template named router with the image router-1.0. Substitute values from your own catalog. Save this JSON as design.json.

{
  "lab": {
    "name": "Routing exercise",
    "description": "Two routers on a shared LAN",
    "body": "Assign addresses to the connected interfaces and verify reachability."
  },
  "nodes": [
    {"ref": "west", "type": "qemu", "template": "router", "image": "router-1.0", "name": "West", "ethernet": 2, "left": 80, "top": 120},
    {"ref": "east", "type": "qemu", "template": "router", "image": "router-1.0", "name": "East", "ethernet": 2, "left": 480, "top": 120}
  ],
  "networks": [
    {"ref": "lan", "name": "LAN", "type": "linux_bridge", "left": 280, "top": 120}
  ],
  "links": [
    {"ref": "west_lan", "from": {"node": "west", "interface_index": 0}, "to": {"network": "lan"}},
    {"ref": "east_lan", "from": {"node": "east", "interface_index": 0}, "to": {"network": "lan"}}
  ],
  "viewport": {"x": 0, "y": 0, "zoom": 1},
  "defaults": {"link_style": "orthogonal"},
  "tasks": [{"title": "Check reachability", "nodes": ["west", "east"]}],
  "configsets": {}
}

Set NOVA_URL to your nova-ve base URL and NOVA_TOKEN to the access_token returned by POST /api/auth/login. Validate the design first. Omitting mode also validates it.

curl --fail-with-body -sS "$NOVA_URL/api/labs/build?mode=validate" \
  -H "Authorization: Bearer $NOVA_TOKEN" \
  -H 'Content-Type: application/json' --data-binary @design.json

Choose a fresh Idempotency-Key for this creation (1–128 printable ASCII characters, excluding spaces). On a retry, resend the same key and the same fields. Adding a previously omitted field counts as a change even when you set it to its default. Apply the same JSON, then open the returned lab in the canvas.

curl --fail-with-body -sS "$NOVA_URL/api/labs/build?mode=apply" \
  -H "Authorization: Bearer $NOVA_TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: routing-exercise-01' --data-binary @design.json

Design fields

Field Meaning
lab Lab name, destination, author, description, and instructions (body). Omitting the destination uses the caller’s default lab folder.
nodes Node references, template and installed image, names, device settings, and initial canvas positions. Use a distinct reference for each node you want to wire.
networks Named network references, types, configuration, and canvas positions.
links Refer to a node port with a node reference and zero-based interface_index, or to a network with its network reference. A direct node-to-node link uses a node port at each end.
viewport, defaults Initial pan, zoom, and default link style for the canvas.
textobjects, lineobjects, pictures, tasks Arrays of JSON values preserved with the lab.
configsets JSON object preserved with the lab.

The request body limit is 1 MiB (1,048,576 bytes), including the optional JSON collections. Send up to 200 node, network, and link definitions combined. A paired appliance takes type: "paired", its template key and a reference. Address children as pairRef.childId. Single nodes support per-interface planned MAC, port position, and validated numeric or selectable template options. Links can carry labels, styles and metrics. The API schema lists the supported fields and types for each object.

When compute hosts are enrolled, a build follows the same placement rules as creating nodes and networks one at a time. A node, or a paired appliance, accepts placement_host_id: omit it to keep the node on the controller's host, set it to null for automatic placement, or set a host ID to pin it. A network with managed DHCP or NAT accepts config.service_host_id to choose the host that serves it; when omitted, the controller's host serves it. A host that is not enrolled, is draining, or cannot carry the network is reported like any other invalid field: status 422 with a message naming the node or network, and nothing is created. This differs from creating a single node or network, which uses 400 or 409 for these cases. If a service host does not accept the network, or cannot be reached, the build returns that host's own status (409 or 503). A retry with the same Idempotency-Key replays the original result without contacting the host again. Without enrolled hosts these fields are not needed.

Use lab.body for exercise instructions. The five optional JSON collections retain nested data from authored lab files. The build operation stores those values without executing tasks, applying config sets, or rendering drawings and pictures. Device images must already be installed. Start nodes and run guest configuration steps separately.

Results and retries

HTTP status Meaning
200 Validated, or replayed an earlier successful apply with the same key and design. Check data.mode and data.replayed.
201 Created. data.lab contains the saved ID, filename and path. data.revision identifies the initial authored revision.
401 / 403 Sign in again or choose a destination accessible to the account.
409 The destination already exists or the idempotency key conflicts with a previous build. Reuse the original key and original design to recover a lost response.
413 The request exceeds 1 MiB. Reduce the design or embedded JSON data.
422 Correct the indicated field or object, such as an unavailable image, unknown reference, or occupied interface. Invalid designs leave no partially built lab.
503 nova-ve could not verify host networking. Retry once the host networking service is available.

data.refs.nodes and data.refs.networks map authored references to numeric IDs. Each data.refs.links entry is a list. A direct node-to-node connection uses two links through an implicit network. Use the IDs returned by apply for subsequent edits. Validation returns a null revision and reserves neither the path nor resources. data.resources estimates total vCPUs and RAM in MB. The normal quota checks run when nodes start.

data.provisioning is deferred. Creation saves the design with nodes stopped. To inspect it, use GET /api/labs/{lab} for metadata and the /nodes, /networks and /links subroutes for the authored topology. Edit existing labs through the individual node, network, link, metadata and layout operations. See Adding nodes and Connecting nodes for the corresponding canvas actions.