Introduction
Nautobot is a powerful network source of truth, helping organisations manage device inventory, IP addressing, circuits, locations, and other critical infrastructure data from a centralised platform. While the web interface is ideal for day-to-day administration, network automation workflows often require a faster and more scalable method for modifying device records.
Nautobot’s REST API provides exactly that capability, enabling engineers to programmatically create, retrieve, update, and delete objects using standard HTTP methods and JSON-formatted data. Updates can be performed using PUT or PATCH requests, allowing changes to individual device attributes without manual intervention.
In this guide, I will explore how to update devices in Nautobot using the REST API.
You’ll learn how to authenticate with an API token, identify the correct device endpoint, submit update requests, and verify that your changes have been successfully applied.
Whether you’re integrating Nautobot with automation tools, synchronising asset data from external systems, or building custom network management workflows, mastering device updates through the API is an essential skill for modern network engineers.
Why Use the API to Update Devices?
If you’re new to network automation, the term API can sound intimidating. In simple terms, an API (Application Programming Interface) is a way for one application to communicate with another. Think of it as a messenger that allows a script, automation platform, or third-party tool to send information to Nautobot and ask it to perform tasks on your behalf.
Nautobot’s REST API supports common actions such as retrieving information, creating new records, updating existing data, and deleting objects.
So why would you use the API instead of simply logging into Nautobot and editing devices through the web interface?
The answer comes down to speed, consistency, and automation.
Imagine that you need to update the status of a single device. Opening the device record in Nautobot and making the change manually is quick and easy. However, what if you need to update 50 devices, 500 devices, or every device at a particular site? Performing those changes manually becomes time-consuming and increases the risk of mistakes.
Using the API, you can automate these updates with a script that performs the same task in seconds. The script can make a change once or run regularly as part of a larger automation workflow. This ensures that Nautobot remains an accurate source of truth without requiring constant manual updates.
Another benefit is integration with other systems. For example, you might have a monitoring platform, asset management system, or deployment tool that knows when a device has been installed, moved, or decommissioned. Through the API, these systems can automatically update Nautobot whenever changes occur, keeping all your data synchronized.
In short, the API allows you to treat Nautobot as more than just a web application. It becomes a platform that can exchange information with other tools, automate repetitive tasks, and help maintain accurate network data at scale. Once you understand the basics, you’ll find that updating devices through the API is often faster, more reliable, and more efficient than making changes manually through the user interface.
REST API vs Pynautobot
The easiest way to think about it is:
- REST API = the actual interface that Nautobot exposes.
- Pynautobot = a Python library that makes it easier to use the REST API.
REST API
The REST API is built directly into Nautobot and allows applications to communicate with Nautobot using HTTP requests such as:
GET– retrieve informationPOST– create new recordsPATCH– update existing recordsDELETE– remove records
For example, updating a device using the REST API might look like this:
PATCH /api/dcim/devices/<device-id>/
{
"status": "active"
}
When using the REST API directly, you are responsible for:
- Building the HTTP requests
- Setting authentication headers
- Formatting JSON data
- Processing the responses returned by Nautobot
Nautobot’s REST API supports standard CRUD operations using HTTP methods and JSON payloads.
Pynautobot
Pynautobot is a Python client library designed specifically for Nautobot.
Instead of manually creating HTTP requests, Pynautobot provides Python objects and methods that handle the REST API communication for you.
Rather than writing:
requests.patch(
"https://nautobot.example.com/api/dcim/devices/device-id/",
headers=headers,
json={"status": "active"}
)
You can write:
import pynautobot
nb = pynautobot.api(
"https://nautobot.example.com",
token="your-token"
)
device = nb.dcim.devices.get(name="R1")
device.status = "active"
device.save()
Behind the scenes, Pynautobot is still using the Nautobot REST API—it simply hides much of the complexity.
Analogy
A useful analogy is ordering food in a restaurant:
- REST API = speaking directly to the kitchen and providing all the details yourself.
- Pynautobot = giving your order to a waiter who handles the communication with the kitchen.
The result is the same, but the waiter makes the process easier and less error-prone.
Which Should You Use?
Use the REST API when:
- You are learning how Nautobot communicates.
- You are integrating with non-Python tools.
- You need complete control over API requests.
- You are using automation platforms such as Postman, PowerShell, Ansible, or curl.
Use Pynautobot when:
- You are writing Python automation.
- You want simpler, more readable code.
- You don’t want to manually build HTTP requests.
- You need to interact with Nautobot frequently in scripts.
Summary
The REST API is the underlying interface that allows applications to communicate with Nautobot, while Pynautobot is a Python library that acts as a wrapper around the REST API. Both ultimately perform the same operations, but Pynautobot simplifies the process by handling authentication, request formatting, and API interactions on behalf of the developer, making it an excellent choice for Python-based network automation workflows.
Prerequisites
Before we start this tutorial I will assume that you have the following
- Nautobot installed
- A few devices added
- Something to fire the request – Python or Postman
Nautobot API authentication
To enable this all to work you will also need an API token.
To generate a Token go into your user account

Leave a Reply