The NetBox Data Provider connects NetBox and Matrix42 in both directions. Computers and network devices, including manufacturers and SKUs, are imported from NetBox into Matrix42 asset management – controlled by a role mapping that defines which devices are created as which asset type. In the other direction, the export transfers regions, sites, locations, device types and assets from Matrix42 to NetBox, with freely definable filters, field and status mappings. Both directions run on a schedule, so asset management and network documentation stay consistent.
The NetBox Data Provider connects a NetBox instance with Matrix42 – in both directions:
| Component | Requirement |
|---|---|
| Matrix42 | version 26.1.0 or later |
| Worker | On-premise worker (data provider pool) with network access to NetBox – required for the import |
| NetBox | NetBox instance reachable via HTTP(S) with an API token; NetBox 4.x for the export |
| Export | additional prerequisites, see 3.2 Prerequisites |
The NetBox Data Provider extension is installed via the Extension Gallery (Administration > Extension Gallery).
The installation provides, among other things:
The NetBox Configuration dialog has four tabs:
| Tab | Content |
|---|---|
| General | Activation of the configuration and connection to NetBox |
| Import | Settings for the import NetBox → Matrix42, role configuration (chapter 2) |
| Import History | Jobs, workflows and logs of the import runs |
| Export | Settings for the export Matrix42 → NetBox (chapter 3) |
General tab
| Field | Description |
|---|---|
| Enable Configuration | Activates the configuration. Without this, the configuration is used neither for the import nor for the export. |
| Netbox Url | URL at which NetBox can be reached, e.g. https://netbox.example.com. |
| Token | NetBox API token. It must be a v1 token. Read permissions are required for the import. If the export is started from Matrix42 (see 3.8.3), the token must also be allowed to run NetBox scripts. |
| Json Dll Path | Full path to the Matrix42 System.Json.dll on the worker server, e.g. C:\Program Files (x86)\Matrix42\Matrix42 Workplace Management\bin\System.Json.dll. |
The import reads devices and device roles via the NetBox REST API (/api/dcim/devices, /api/dcim/device-roles/) and creates or updates computers, network devices, manufacturers, SKUs and roles in Matrix42. It is run by the generic connector on the selected data provider pool.
The import settings are on the Import tab of the NetBox Configuration.
General
| Field | Description |
|---|---|
| Enable Import | Activates the data import. |
| Data Provider Pool | Select the on-premise worker that has access to NetBox. |
| Data Provider | Select the NetBox data provider. |
| Description | Optional description of the configuration. |
| Last Result, Last Run | Result and time of the last import run (display only). |
Import settings (inventory)
| Field | Description |
|---|---|
| Status for New Computer | Status for newly imported devices. |
| Status for Deleted Computer | Status for deleted computers. |
| Create computers | Activate this option if computers are to be created. |
| Update computers | Activate this option if computers are to be updated. |
| Create network devices | Activate this option if network devices are to be created. |
| Update network devices | Activate this option if network devices are to be updated. |
The Configure Roles area defines which NetBox roles are mapped to which asset types in Matrix42. The list shows Name, Slug and Asset Type for each role.
Importing NetBox roles
Before configuring the roles, run the data provider once with a valid basic configuration and without role mapping. This imports the roles from NetBox into Matrix42.
Assigning NetBox roles
Once the roles have been imported, assign the matching Asset Type to the required roles in the Configure Roles area. The next data provider run imports all devices whose NetBox role has an asset type assigned.
The engine activation supplied with the extension is preconfigured as follows:
| Tab | Preconfiguration |
|---|---|
| General | Name Netbox - Import, the whole activation is disabled |
| Activated Engines | Engine Generic Connector, engine activation parameters: Connectors: NetBox |
| Schedules | no schedule |
Setup:
The following tables show which NetBox attributes are imported into which Matrix42 fields. Fields marked (matching) are used to identify existing objects.
API call: GET https://{NetBoxUrl}/api/dcim/devices
| NetBox | Source column | Target in Matrix42 |
|---|---|---|
| constant / set in import | ManagementTypeNetbox | SPSAssetClassBase.ManagementType |
| SKUManufacturer + SKUModel | [Transform] | SPSAssetClassBase.SKU |
primary_ip.address | ip | SPSComputerClassBase.IPAddress |
site.name | location | SPSCommonClassBase.Location |
device_type.manufacturer.name | manufacturer | [Source] SKUManufacturer |
device_type.model | model | [Source] SKUModel |
name | name | SPSComputerClassBase.Name |
configured in the extension ($NewDeviceState) | newDeviceState | SPSCommonClassBase.State |
serial | serial | SPSAssetClassBase.SerialNumber (matching) |
API call: GET https://{NetBoxUrl}/api/dcim/devices
| NetBox | Source column | Target in Matrix42 |
|---|---|---|
| constant / set in import | ManagementTypeNetbox | SPSAssetClassBase.ManagementType |
| SKUManufacturer + SKUModel | [Transform] | SPSAssetClassBase.SKU |
primary_ip.address | ip | SPSPeripheralClassBase.IPAddress |
site.name | location | SPSCommonClassBase.Location |
device_type.manufacturer.name | manufacturer | [Source] SKUManufacturer |
device_type.model | model | [Source] SKUModel |
name | name | SPSAssetClassBase.Name |
configured in the extension ($NewDeviceState) | newDeviceState | SPSCommonClassBase.State |
serial | serial | SPSAssetClassBase.SerialNumber (matching) |
The manufacturers are the distinct values of device_type.manufacturer.name.
| NetBox | Source column | Target in Matrix42 |
|---|---|---|
| constant / set in import | IsManufacturer | SPSSupplierClassBase.IsManufacturer |
device_type.manufacturer.name | manufacturer | SPSSupplierClassBase.Name (matching) |
device_type.manufacturer.name | manufacturer | SPSSupplierClassBase.ShortName |
API call: GET https://{NetBoxUrl}/api/dcim/device-roles/
| NetBox | Source column | Target in Matrix42 |
|---|---|---|
name | name | MTX_NetboxDeviceRolesClassBase.MTX_Name |
slug | slug | MTX_NetboxDeviceRolesClassBase.MTX_Slug (matching) |
The SKUs are the distinct combinations of device_type.model and device_type.manufacturer.name.
| NetBox | Source column | Target in Matrix42 |
|---|---|---|
| constant / set in import | StateActive | SPSCommonClassBase.State |
| configured per role in the extension (asset type) | assetType | SPSStockKeepingUnitClassBase.Type |
device_type.manufacturer.name | manufacturer | SPSStockKeepingUnitClassBase.Manufacturer (matching) |
device_type.model | model | SPSStockKeepingUnitClassBase.Model (matching) |
The export creates and updates regions, sites, locations, SKUs and assets from Matrix42 in NetBox. The Export tab of the NetBox Configuration defines which objects are transferred with which fields. The transfer into NetBox is performed by the NetBox script Matrix42 Sync, which retrieves the configuration and data from the extension’s web service.
| Component | Location | Purpose |
|---|---|---|
| Export tab of the NetBox Configuration | Matrix42 | Selection of entities, filters, status and field mappings |
Web service MountX.NetBoxDataProvider | Matrix42, /m42Services/api/mountx/netbox | Provides the configuration and data per entity and the sync script for download |
Script module netbox_sync.py | NetBox (custom scripts) | Contains the scripts Matrix42 Sync and Matrix42 Link Existing Objects |
| Workflow Netbox - Trigger Export and engine activation Netbox - Export | Matrix42 | Start the sync on a schedule from Matrix42 and store the result on the Export tab |
Flow of an export started from Matrix42:
requests must be available in NetBox (included in the official NetBox Docker image). M42_BASE_URL and M42_API_TOKEN in NetBox (see 3.3). role in the field mapping must exist as device roles in NetBox. cf_<name>, they must be created in NetBox and assigned to the respective object type. The script creates the custom field matrix42_eoid itself. netbox_sync.py always matches the installed version of the web service. environment:
M42_BASE_URL: 'https://matrix42.example.com' # base URL without /m42Services
M42_API_TOKEN: '<Matrix42 API token>' netbox_sync.py. The scripts Matrix42 Sync and Matrix42 Link Existing Objects then appear. /extras/scripts/<ID>/ or via GET /api/extras/scripts/) and enter it on the Export tab under Netbox Script Id. | Field | Description |
|---|---|
| Enable Export | Enables the export for this configuration. If the export is not enabled or the configuration is disabled on the General tab, the web service rejects all requests. |
| Configuration ID | Unique ID (GUID) of this configuration (display only). It is entered as Configuration ID when starting the NetBox scripts. |
| Netbox Script Id | Numeric ID of the Matrix42 Sync script in NetBox. Required for starting the export from Matrix42. |
| DOWNLOAD SCRIPT | Downloads the script module netbox_sync.py. |
| Last Export Status | Status of the last NetBox job started from Matrix42, e.g. completed. |
| Last Export Date | Time of the last export started from Matrix42. |
| Last Export Result | Summary of the run per entity (created, updated, unchanged, failed, disappeared). |
| Last Export Log | Log of the NetBox job. |
The Export tab contains a separate area for each entity. The entities are processed in the following order so that references to objects that have already been transferred can be resolved:
| Order | Area on the Export tab | NetBox object | Data definition | Status mapping |
|---|---|---|---|---|
| 1 | Region | Region | selectable: SPSOrgUnitClassBase, SPSLocationClassBase, SPSCostCenterClassBase | – |
| 2 | Site | Site | selectable: SPSOrgUnitClassBase, SPSLocationClassBase, SPSCostCenterClassBase | yes |
| 3 | Location | Location | selectable: SPSOrgUnitClassBase, SPSLocationClassBase, SPSCostCenterClassBase | yes |
| 4 | SKUs | Device Type | SPSStockKeepingUnitClassBase | – |
| 5 | Assets | Device | SPSAssetClassBase | yes |
Each area contains the following fields:
| Field | Description |
|---|---|
| Export Regions / Sites / Locations / Skus / Assets | Export the entity. If the checkbox is cleared, the web service returns no data and the script skips the entity. |
| … Data Definition | Matrix42 data definition from which the objects are read. |
| … Filter | Optional ASQL condition that restricts the exported objects, e.g. SerialNumber IS NOT NULL. Without a filter, all objects of the data definition are exported. |
| Status Mapping | Mapping of Matrix42 statuses to NetBox statuses (site, location and assets only), see 3.7. |
| Field Mapping | Mapping of Matrix42 values to NetBox fields, see 3.6. |
Each row of the field mapping assigns a Matrix42 value to a NetBox field.
| Column | Description |
|---|---|
| Columns Expression | ASQL expression evaluated on the data definition: an attribute (Name), a path across relations (Manufacturer.Name), a function (ISNULL(…)) or a constant ('default-role', 1). |
| Netbox Target | Name of the NetBox field, e.g. name, serial or cf_<name> for custom fields. |
| Field Policy | Defines when the value is written to NetBox (see below). |
Rows without a columns expression or NetBox target are ignored. Each exported entity needs at least one complete row.
Required row: Every entity needs the row
[Expression-ObjectID]→cf_matrix42_eoid. It links the Matrix42 object to the NetBox object. Records without this value are not transferred.
Field policy
| Field Policy | The value is written … |
|---|---|
| Always | on every run as soon as it differs from the value in NetBox |
| On Create | only when the object is created in NetBox |
| If Empty | only if the field in NetBox is empty |
| Never | never (the value is only delivered, e.g. as match field for linking) |
If no field policy is specified, Always applies.
NetBox fields with special handling
| Netbox Target | Entities | Expected value | Behavior |
|---|---|---|---|
cf_matrix42_eoid | all | [Expression-ObjectID] | Link between Matrix42 and NetBox (required) |
status | Site, Location, Assets | Matrix42 status, e.g. State.Value | Translated via the status mapping |
region | Site | ID ([Expression-ObjectID]) of an exported region | Reference to the region transferred to NetBox |
site | Location, Assets | ID of an exported site | Reference to the site transferred to NetBox |
device_type | Assets | ID of an exported SKU | Reference to the device type transferred to NetBox |
manufacturer | SKUs | Manufacturer name | The manufacturer is created in NetBox if it is missing |
role | Assets | Slug of a NetBox device role | The role must exist in NetBox |
tenant | Site, Location, Assets | Tenant name | The tenant is created in NetBox if it is missing |
tags | all | comma-separated tag names | Missing tags are created and added; existing tags are kept |
cf_<name> | all | any | Written to the custom field <name> |
All other NetBox targets are written directly to the NetBox field of the same name (e.g. name, serial, asset_tag, description, comments, model, u_height, part_number, facility). Other reference fields such as location, parent or platform are not supported.
Which fields NetBox requires when creating an object depends on the object. The slug of regions, sites, locations and device types is set automatically to m42-<ID>.
| NetBox object | Minimum mapping (in addition to cf_matrix42_eoid) |
|---|---|
| Region | name |
| Site | name |
| Location | name, site |
| Device Type | manufacturer, model |
| Device | device_type, role, site |
Example: field mapping of the assets
| Columns Expression | Netbox Target | Field Policy |
|---|---|---|
ISNULL(T(SPSComputerClassBase).Name, Name) | name | Always |
SerialNumber | serial | Always |
[Expression-ObjectID] | cf_matrix42_eoid | On Create |
SKU.[Expression-ObjectID] | device_type | Always |
'default-role' | role | On Create |
T(SPSCommonClassBase).Location.[Expression-ObjectID] | site | Always |
T(SPSCommonClassBase).State.Value | status | Always |
Example: field mapping of the SKUs
| Columns Expression | Netbox Target | Field Policy |
|---|---|---|
Model | model | Always |
Manufacturer.Name | manufacturer | Always |
[Expression-ObjectID] | cf_matrix42_eoid | On Create |
1 | u_height | On Create |
The status mapping assigns a NetBox status to each Matrix42 status. It is available for site, location and assets and is used when the field mapping delivers the status field.
| NetBox object | Valid statuses |
|---|---|
| Device | Offline, Active, Planned, Staged, Failed, Inventory, Decommissioning |
| Site, Location | Planned, Staging, Active, Decommissioning, Retired |
If NetBox already contains regions, sites, locations, device types or devices that are to be maintained from Matrix42 in the future, they must be linked before the first sync. Otherwise the sync creates duplicates or fails because names are already taken.
The Matrix42 Link Existing Objects script assigns the records delivered by Matrix42 to NetBox objects that are not yet linked. For each entity it compares a selectable field and, if the values match, writes the custom field matrix42_eoid and the tag m42-managed. It does not create objects and does not change any other fields.
| Section | Field | Default | Description |
|---|---|---|---|
| Matrix42 connection | Configuration ID | – | Configuration ID from the Export tab |
| Matrix42 connection | Verify TLS | enabled | Verify the Matrix42 TLS certificate. Disable only for test systems with self-signed certificates. |
| Regions, Sites, Locations, Device types, Devices | Enabled | enabled | Link the entity in this run |
| Regions, Sites, Locations, Device types, Devices | Match field | name, name, name, model, serial | NetBox field used for the comparison, e.g. serial, asset_tag, name or cf_<custom field> |
| – | Commit | disabled | Without commit, all changes are rolled back at the end (simulation). |
Rules:
Recommended procedure:
In NetBox, open the Matrix42 Sync script under Customization > Scripts, enter the parameters and run it:
| Field | Default | Description |
|---|---|---|
| Configuration ID | – | Configuration ID from the Export tab |
| Verify TLS | enabled | Verify the Matrix42 TLS certificate. Disable only for test systems with self-signed certificates. |
| Commit | disabled | Without commit, all changes are rolled back at the end (simulation). |
The result contains, per entity, the number of created, updated, unchanged, failed and no longer delivered (disappeared) objects, e.g.:
regions: 0 created, 0 updated, 1 unchanged, 0 failed, 0 disappeared | sites: … | assets: 0 created, 0 updated, 1 unchanged, 0 failed, 0 disappearedAlternatively, Matrix42 Sync can be scheduled directly in NetBox (options Schedule at and Recurs every when running the script).
The extension supplies the engine activation Netbox - Export. It starts the workflow Netbox - Trigger Export, which starts the script stored under Netbox Script Id in NetBox for this configuration, waits for the NetBox job to finish and stores the status, time, result and log in the Last Export … fields on the Export tab.
| Tab | Preconfiguration |
|---|---|
| General | Name Netbox - Export, the whole activation is disabled |
| Activated Engines | Engine Start Workflow, engine activation parameters: Workflow ID: Netbox - Trigger Export |
| Schedules | no schedule |
Setup is the same as for the import (see 2.3): add a schedule on the Schedules tab, clear the option that disables the whole activation on the General tab and save.
Prerequisites for starting from Matrix42:
matrix42_eoid (label “Matrix42 EOID”). The script creates the custom field on the first run and assigns it to Region, Site, Location, Device Type and Device. m42-managed. Automatically created manufacturers, tenants and tags are tagged as well. matrix42_eoid are created. Regions, sites, locations and device types get the slug m42-<ID>. SIMULATION - nothing was saved. Base URL: https://<Matrix42 server>/m42Services/api/mountx/netbox
Authentication
POST /m42Services/api/ApiToken/GenerateAccessTokenFromApiToken with the header Authorization: Bearer <Matrix42 API token>. The response contains an access token in the RawToken field. Authorization: Bearer <RawToken>. Endpoints
| Method | Path | Parameter | Response |
|---|---|---|---|
| GET | /config | configurationId | Export configuration: export checkboxes, data definitions, filters, field mappings and status mappings |
| GET | /regions | configurationId | { "Regions": [ … ] } |
| GET | /sites | configurationId | { "Sites": [ … ] } |
| GET | /locations | configurationId | { "Locations": [ … ] } |
| GET | /skus | configurationId | { "Skus": [ … ] } |
| GET | /assets | configurationId | { "Assets": [ … ] } |
| GET | /script | – | Download of the script module netbox_sync.py |
Each record contains the NetBox targets defined in the field mapping as keys. If an entity is not enabled for export, the list is empty.
Example:
GET https://matrix42.example.com/m42Services/api/mountx/netbox/skus?configurationId=<Configuration ID>
Authorization: Bearer <RawToken>
Accept: application/json{
"Skus": [
{
"model": "Catalyst 9300",
"manufacturer": "Cisco",
"cf_matrix42_eoid": "<ID of the SKU>",
"u_height": 1
}
]
}Web service error messages
| Message | Cause |
|---|---|
NetBox sync configuration '<ID>' not found | The configuration ID does not exist. |
NetBox sync configuration '<ID>' is disabled | Enable Configuration is not selected on the General tab. |
NetBox sync configuration '<ID>': export is not enabled | Enable Export is not selected on the Export tab. |
NetBox sync configuration '<ID>': no <entity> field mappings configured | A complete field mapping is missing for an exported entity. |
… MTX_StatusMapping is not valid JSON / … MTX_FieldMappingPolicy is not valid JSON | The stored mappings are corrupt; check the mappings in the dialog and save them again. |
The following messages appear in the log of the NetBox job or in the Last Export Log field.
| Message | Cause | Solution |
|---|---|---|
environment variable M42_API_TOKEN is not set on the NetBox container (likewise M42_BASE_URL) | Environment variable missing | Set the variable and restart NetBox including the worker |
configuration ID is not a valid GUID | Configuration ID missing or wrong | Copy the configuration ID from the Export tab |
…/GenerateAccessTokenFromApiToken: 401 … or response contains no RawToken | Matrix42 API token invalid or expired | Create a new API token and update M42_API_TOKEN |
… CERTIFICATE_VERIFY_FAILED … | The Matrix42 certificate is not trusted | Add the certificate chain in NetBox; disable Verify TLS only in test environments |
<entity>: export disabled in configuration, skipped | Entity not enabled for export | Information; select Export … on the Export tab if required |
record has no cf_matrix42_eoid | Required row missing | Add the row [Expression-ObjectID] → cf_matrix42_eoid |
duplicate EOID in payload | Object delivered more than once | Check the columns expressions and filter |
status: no mapping for Matrix42 status <value> | Status not mapped | Complete the status mapping |
role: no device role with slug '<slug>' in NetBox - create it first | Device role missing in NetBox | Create the device role in NetBox |
<field>: no synced <entity> entry for EOID '<ID>' | Referenced object was not transferred to NetBox | Enable the parent entity for export, check its filter and errors |
<field>: cannot be applied to <object> | NetBox target does not exist | Correct the field name in the field mapping |
unknown field policy '<policy>' | Invalid field policy | Correct the field policy |
validation failed: … | NetBox validation, e.g. required field missing or name already taken | Complete the field mapping; link existing objects first (see 3.8.1) |
… no longer delivered by Matrix42 (left untouched) | Object is no longer delivered | Information; the object is not changed in NetBox |
the field mappings deliver no '<field>' column, add a mapping row for it first | Match field missing in the field mapping (Link Existing Objects) | Add a mapping row for the match field |