NetBox icon

NetBox

Consume NetBox API

Overview

This node integrates with the NetBox API, specifically allowing users to create a new Device Role within the DCIM domain. Device Roles in NetBox categorize devices by their function or purpose (e.g., server, router, switch), helping organize and manage network infrastructure effectively.

Typical use cases include:

  • Automating the addition of new device roles during network provisioning workflows.
  • Standardizing device role definitions across multiple sites or teams.
  • Enriching asset management systems by programmatically updating device metadata.

For example, you might use this node to create a new device role called "Edge Router" with a specific color code and description, which can then be assigned to devices in your inventory.

Properties

Name Meaning
Domain The NetBox API domain to target. Options: DCIM, IPAM, Tenancy, Extras, Virtualization, Circuits, Core, Users, Plugins, VPN, Wireless, Status. For this operation, must be DCIM.
Name The name of the device role to create.
Additional Fields Optional extra fields for the device role:
- Slug URL-friendly slug; if left blank, it will be generated automatically.
- Color Hexadecimal color code representing the device role (e.g., ff0000 for red).
- VM Role Boolean indicating if this role applies to virtual machines.
- Description Text description of the device role.
- Tags Comma-separated list of tags associated with the device role.
- Custom Fields JSON object containing any custom fields defined for the device role.

Output

The node outputs a JSON object representing the newly created device role as returned by the NetBox API. This typically includes all properties of the device role such as its ID, name, slug, color, description, tags, and any custom fields.

If an error occurs and "Continue on Fail" is enabled, the output will contain a JSON object with an error field describing the issue.

The node does not output binary data.

Dependencies

  • Requires access to a NetBox instance with API enabled.
  • Needs an API authentication token credential configured in n8n to authorize requests.
  • The node depends on internal helper functions to execute the API operation but no external npm packages beyond those bundled.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Providing invalid values for fields like color (non-hex format) or malformed JSON in custom fields may result in API errors.
    • Attempting to create a device role in a domain other than DCIM will not work for this resource-operation combination.
  • Error messages:

    • Authentication errors: Check that the API token is valid and has sufficient permissions.
    • Validation errors from NetBox API: Review the field values for correctness, especially required fields like "Name".
    • Network errors: Ensure the NetBox server URL is reachable from the n8n environment.
  • Enable "Continue on Fail" to handle errors gracefully and inspect error messages in the output.

Links and References

Discussion