• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Roger Perkin

Network Automation Consultant

  • Network Automation
    • Network Automation Consultant
    • Network Automation Courses
    • What is NetDevOps?
    • Workflow Orchestration
    • Ansible Automation Platform
    • Ansible Workshop
    • What is Network Automation?
    • Network Automation Tools
    • ContainerLab
    • Ansible Training
      • What is Ansible?
      • Ansible Tutorial for Beginners
      • Ansible Network Automation
      • Ansible Inventory Example
    • Python Network Automation
      • Nornir
      • Python for Network Engineers
      • Python VENV / Virtual Environment Tutorial
      • Python Tutorial for Beginners
      • pyATS
    • Network Source of Truth, why you need a Single Source of Truth
      • NetBox Training
      • Infrahub
      • NautoBot Training
    • NetDevops
    • DevOps Tutorial
      • Git Training
      • Terraform Training
      • Linux Training
      • Kubernetes Training
      • Devops Training Course
      • Azure Devops Training
    • Terraform
    • GIT
      • Git Commands
      • What is GitHub?
    • Docker Training
    • Confluence
    • Microsoft Azure
  • Cisco
    • ISE
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • CCIE
  • Blog
  • About
    • My Red Special Guitar
  • Contact

Updating Devices in Nautobot Using the REST API

Home » Network Automation » Nautobot Training

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 information
  • POST – create new records
  • PATCH – update existing records
  • DELETE – 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

Finding the Device to Update

Updating Device Attributes with PATCH

PUT vs PATCH

Python Example Using Requests

Python Example Using Pynautobot

Verifying the Update

Using Postman

Common Errors and Troubleshooting

Best Practices

Conclusion

Category: NautoBot Training
ansible course for network engineers
Get Access to my Ansible Course NOW
Previous Post:AWX vs Semaphore

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Sidebar

Hi I'm Roger Perkin,
Based in the UK working as a Network Automation Architect, CCIE #50038
About Roger | Twitter | Linkedin

Python for Network Engineers Course

Topics

Network Automation
Ansible Network Automaton
Python for Network Automation
CCIE
BGP
OSPF
Network Automation Conferences

Git for Network Engineers

Ansible vs Nornir

Start learning today with my Network Automation Courses

Master Ansible, Python, Git, Nornir, Jenkins and more..


Buy me a coffeeBuy me a coffee

ansible network automation course

Have you seen my YouTube Channel?

YouTube Subscribe

Let’s get started

Take a look at my premium courses on Ansible, Nornir & Git or buy them all with the Network Automation Bundle!

Network Automation Courses

Navigation

Python VENV Tutorial
Python for Network Engineers Course

Network Automation
Network Automation Courses
Network Discovery Tools
Network Automation Conferences
Ansible Training
What is Ansible?
Devops Tutorial
Network Source of Truth
DevOps Glossary
Network Monitoring Software

Contact

Contact

Get in touch with me here

[email protected]

  • Twitter
  • LinkedIn
  • YouTube
Buy me a coffeeBuy me a coffee

Copyright © 2026 · Roger Perkin · All Rights Reserved · Privacy Policy – Terms