Skip to content

API Blueprints

kandji-trent edited this page Jun 23, 2026 · 1 revision

Blueprints Resource

Methods

The resource wraps the /api/v1/blueprints endpoint and exposes two methods:

Method Description Returns
list() All Blueprints PayloadList[BlueprintPayload]
assign(blueprint, *, library_item_id, node=None) Assign a library item to a Blueprint list[str]

Payload model

Each BlueprintPayload has:

Attribute Type Description
id str The Blueprint ID (UUID)
name str Display name
type str The Blueprint type

List Blueprints

Listed Blueprints are returned in a PayloadList with count and results properties.

with BlueprintsResource(config) as blueprints:
    for blueprint in blueprints.list().results:
        print(f"{blueprint.id}  {blueprint.name}  ({blueprint.type})")

Assign a library item

assign() adds a library item to a Blueprint. library_item_id and node are keyword-only. Omit node to assign at the Blueprint's root; pass an Assignment Map node ID to target a specific node.

The method returns the IDs of every library item assigned to the Blueprint after the operation.

with BlueprintsResource(config) as blueprints:
    assigned = blueprints.assign(
        "11111111-1111-1111-1111-111111111111",          # Blueprint ID
        library_item_id="54bef6b3-b25e-44b4-89fd-d528d73939e4",
    )
    print(f"Blueprint now has {len(assigned)} item(s).")

Note

A Blueprint ID can be obtained by using the list() method or by navigating to a Blueprint in the Web UI and copying the ID from the URL.

A Node ID can only be obtained by navigating to the Blueprint in the Web UI. While on the page, you can view the node IDs by holding the OPT key.

Idempotent assignment

Assigning an item that is already on the Blueprint returns an HTTP 400, which surfaces as a requests.HTTPError. Use the is_duplicate_assignment helper to recognize that case and treat it as a no-op instead of an error:

with BlueprintsResource(config) as blueprints:
    try:
        blueprints.assign(
            "11111111-1111-1111-1111-111111111111",
            library_item_id="54bef6b3-b25e-44b4-89fd-d528d73939e4",
        )
    except requests.HTTPError as error:
        if is_duplicate_assignment(error.response):
            print("Already assigned; nothing to do.")
        else:
            raise

See also

Clone this wiki locally