Skip to main content
Objects are the fundamental data entities in Infrahub. This guide shows you how to create, update, and delete objects using the UI, GraphQL API, or Python SDK.

Creating Objects

You can create objects in three ways: through the UI, GraphQL mutations, or the Python SDK.
  1. Navigate to the object type in the sidebar (e.g., Devices, Locations)
  2. Click Add [Object Type]
  3. Fill in the required attributes
  4. Set relationships by selecting existing objects
  5. Click Save
The UI validates required fields and shows errors before allowing you to save.

Updating Objects

Update existing objects by modifying their attributes or relationships.
  1. Navigate to the object’s detail page
  2. Click Edit or click directly on editable fields
  3. Modify the values
  4. Click Save
Changes are tracked in the activity feed and can be reverted using branches.

Deleting Objects

Delete objects when they are no longer needed. Deletion is subject to relationship constraints.
  1. Navigate to the object’s detail page
  2. Click the More actions menu (three dots)
  3. Select Delete
  4. Confirm the deletion
If the object has required relationships pointing to it, deletion will fail with an error message.

Working with Attributes

Attributes hold data values and support metadata like source tracking and validation.

Setting Attribute Sources

You can specify where attribute values come from (e.g., a Profile or template):
mutation {
  InfraDeviceUpdate(
    data: {
      id: "<device-uuid>"
      description: {
        value: "From template"
        source: "<template-uuid>"
        is_from_profile: false
      }
    }
  ) {
    ok
  }
}
The source field tracks provenance, while is_from_profile indicates if the value comes from a Profile.

Attribute Flags

  • is_default: True if using the schema’s default value
  • is_from_profile: True if value comes from a Profile
  • is_protected: Prevents modification
  • is_visible: Controls UI visibility

Working with Relationships

Cardinality ONE

For single-value relationships, use { id: "uuid" }:
device_type: { id: "<device-type-uuid>" }

Cardinality MANY

For multi-value relationships, provide an array:
tags: [
  { id: "<tag-1-uuid>" },
  { id: "<tag-2-uuid>" }
]

Using Human-Friendly Identifiers (HFID)

Instead of UUIDs, you can use HFIDs:
site: { hfid: ["atl1"] }
HFIDs are auto-generated from key attributes and are more readable than UUIDs.

Batch Operations

Create multiple objects efficiently using the SDK:
from infrahub_sdk import InfrahubClient

client = InfrahubClient()

devices = [
    {"name": "router-01", "site": "<site-uuid>"},
    {"name": "router-02", "site": "<site-uuid>"},
    {"name": "router-03", "site": "<site-uuid>"},
]

for device_data in devices:
    device = await client.create(kind="InfraDevice", **device_data)
    await device.save()
For larger datasets, consider using YAML import (see Data Import).

Validation and Constraints

Infrahub validates objects against schema constraints:
  • Required attributes: Must have a value
  • Unique attributes: Value must be unique across objects
  • Regex patterns: String values must match patterns
  • Min/max values: Numbers must be within range
  • Relationship cardinality: ONE relationships require exactly one peer
Validation errors are returned in the mutation response:
{
  "ok": false,
  "errors": [
    {
      "message": "name is required",
      "path": ["name"]
    }
  ]
}

Next Steps

Build docs developers (and LLMs) love