NetBox icon

NetBox

Consume NetBox API

Overview

This node interacts with the NetBox API, specifically targeting the "Device" resource within the "DCIM" domain to assign or remove tags on devices. It is useful for automating asset management tasks such as categorizing devices by tags for easier filtering, reporting, or applying policies in network infrastructure management.

Practical examples include:

  • Automatically tagging newly added devices with specific labels like "production" or "test".
  • Removing deprecated tags from devices during cleanup operations.
  • Managing device metadata programmatically to maintain consistent inventory classification.

Properties

Name Meaning
Domain The domain of the NetBox API to interact with. Options: DCIM, IPAM, Tenancy, Extras, Virtualization, Circuits, Core, Users, Plugins, VPN, Wireless, Status. For this operation, must be "DCIM".
Device ID The unique identifier of the device to which the tag will be assigned or removed.
Tag Name or ID The name or ID of the tag to assign or remove from the device.
Action Whether to add or remove the specified tag. Options: Add Tag, Remove Tag.

Output

The node outputs a JSON object representing the result of the tag assignment or removal operation on the device. This typically includes confirmation of the action performed and any relevant metadata returned by the NetBox API about the updated device or tag status.

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

No binary data output is involved in this operation.

Dependencies

  • Requires access to a NetBox instance with the appropriate API endpoint reachable.
  • Needs an API authentication token or key configured in n8n credentials to authorize requests to the NetBox API.
  • The node depends on an internal helper function (executeOperation) to perform the actual API call, which handles the HTTP request and response processing.

Troubleshooting

  • Common issues:

    • Invalid or missing device ID or tag ID/name can cause the operation to fail.
    • Insufficient permissions or invalid API credentials will result in authorization errors.
    • Network connectivity problems to the NetBox server will cause request failures.
  • Error messages:

    • Errors thrown by the node are logged and, if "Continue on Fail" is enabled, returned as part of the output JSON under the error key.
    • Typical error messages may include "Device not found", "Tag not found", or "Unauthorized".
  • Resolutions:

    • Verify that the device ID and tag ID/name are correct and exist in NetBox.
    • Ensure the API key or token has sufficient permissions to modify device tags.
    • Check network connectivity and NetBox server availability.

Links and References

Discussion