Skip to main content
On this page

Inventory import & export

Use Inventory → Transfer to export inventory to JSON or import it into the same or another instance. API endpoints: GET /api/v1/inventory/export and POST /api/v1/inventory/import. The covered resources are listed below.

File format

One self-contained JSON document:

{
  "version": "piping-inventory-v1",
  "resources": {
    "dcim.sites": [{ "name": "Berlin DC", "slug": "berlin-dc", "status": "active" }],
    "dcim.devices": [
      {
        "name": "edge-01",
        "site": "berlin-dc",
        "role": "router",
        "ip_addresses": ["192.0.2.10/24"],
        "primary_ip": "192.0.2.10"
      }
    ]
  }
}
  • version is always piping-inventory-v1.
  • resources maps a resource key to an array of records. Keys missing from the file are left untouched on import.
  • Records reference each other by slug or name (a device names its site by slug), never by database id, so the file is portable across instances. An omitted slug is derived from the name automatically.
  • The browser export downloads as piping-inventory-export-<date>.json, pretty-printed.

Covered resources

KeyContentsMatched on import by
dcim.regionsTop-level regionsslug
dcim.site-groupsTop-level site groupsslug
tenancy.tenantsTenantsslug
dcim.sitesSites with region/tenant/group refs, addresses, coordinatesslug
dcim.manufacturersManufacturersslug
dcim.device-typesDevice models per manufacturermanufacturer + slug
dcim.device-rolesRoles incl. colour, VM flag, custom-field bagslug
dcim.devicesDevices with site, type, role, status, tenant, IPs, primary IPname + site + tenant
virtualization.virtual-machinesVMs with site, role, status, IPsname + site
extras.config-contextsConfig contexts: weight, active flag, role/site bindings, dataname
secrets.variablesSecret metadata: key, masked/protected flagsid (UUID)
secrets.storeEncrypted secret valuessecret id
tenancy.contactsContacts (name, email, phone)name
tenancy.contact-rolesContact rolesslug
tenancy.contact-assignmentsSite-scoped assignments (object_type: "dcim.site")site + contact + role
automation.templatesAutomation template definitionsname
workspace.connection-target-layoutsSaved connection-target layoutsname

Exporting

  1. Open Inventory → Transfer, Export tab.
  2. Click Generate Export. The browser downloads a full snapshot — all records of every resource above, with no filtering.

Export requires the read action on the inventory resource; import requires create — see Access control.

Importing

  1. On the Import tab, click Choose File and pick a .json export file. The file shape (version + resources arrays) is checked in the browser before anything is uploaded.
  2. Tune the rule matrix. Each enabled resource has three independent flags:
FlagEffect
Create (createMissing)Insert records from the file that don't exist yet
Update (updateExisting)Overwrite existing records matched by the identity key above
Delete (deleteMissing)Remove existing records of that type that are absent from the file

Defaults: Create and Update on, Delete off. Resources you uncheck get no rule and are left untouched (their records are still counted in the summary).

  1. Click Execute Import.

The whole import runs in a single database transaction: any validation error — a malformed record, a non-UUID secret id, invalid connection parameters in a config context — rolls back everything.

The response is a per-resource summary:

{ "counts": { "dcim.sites": 4, "dcim.devices": 32 }, "applied": true, "skipped": [] }

If no resource has any active rule, nothing is applied: applied is false and skipped lists the resource keys from the file.

Tip: Delete turns the file into the desired full state for that resource — anything not listed is removed. Leave it off unless the file is meant as a complete mirror, e.g. when promoting a curated inventory from staging to production.

Secrets in transfer files

  • secrets.variables carries metadata only; the values travel in secrets.store as enc:v1: AES-GCM envelopes. Plaintext secret values never leave the instance.
  • On import, an encrypted_value that is already an enc:v1: envelope is stored as-is — restoring it on another instance requires the same cipher key (PIPING_SECRETS__CIPHER_KEY_B64). A plain string is encrypted at import time, so a hand-written seed file may contain plaintext values.
  • Secret records are matched by UUID and are never deleted by an import.
  • Config-context data may embed inline secrets as {"secret": true, "value": "..."}. On import they are extracted into managed secrets and replaced by a secret id inside the stored context. If a context references a secret id that has no value in secrets.store, the import fails with a validation error listing the missing ids.
  • Config contexts that define connection parameters under piping.connections are validated against the connection-parameter schema during import — see Connection configuration.

Transfer vs. sync

Transfer imports or exports a file once. Use inventory sync for ongoing updates from an external source. Both write to the same inventory.

REST API

MethodPathPurposePermission
GET/api/v1/inventory/exportDownload the full inventory snapshotinventory read
POST/api/v1/inventory/importApply a snapshot with per-resource rulesinventory create

Import request body:

{
  "payload": { "version": "piping-inventory-v1", "resources": { "dcim.sites": [] } },
  "rules": {
    "dcim.sites": { "createMissing": true, "updateExisting": true, "deleteMissing": false }
  }
}

The authoritative schemas live in the OpenAPI contract — see API reference.