Free tech learning for everyone, from basics to pro

Network AutomationProgramming and Application SecurityIntermediate

RESTCONF: managing network devices over HTTPS with YANG

In short: RESTCONF (RFC 8040) is an HTTPS-based protocol that exposes YANG data models as web resources. You use GET to read and PATCH, PUT, POST or DELETE to change configuration, with JSON or XML bodies. It brings familiar REST tools such as curl and Python requests to model-driven device management.

What RESTCONF is

RESTCONF, defined in RFC 8040, takes the same YANG data models used by NETCONF and makes them available through HTTPS. Every container and list item in a model gets a URL. Instead of XML RPCs over SSH you send ordinary HTTP requests, so any tool that speaks REST can manage the device. It is ideal for quick integrations, web applications and engineers who already know API basics.

NETCONF and RESTCONFNETCONFSSH, port 830XML onlyRPC operationsCandidate and locksRESTCONFHTTPS, port 443JSON or XMLHTTP methods on URLsSimpler, stateless
Figure 1. Both use YANG models; RESTCONF exposes them as web resources over HTTPS.

URLs and media types

Building a RESTCONF URLHosthttps://deviceRoot/restconfDatastore/dataModuleietf-interfaces:Pathinterface Gi2
Figure 2. A RESTCONF URL is built from the API root, the data resource and a YANG path.

The data resource normally sits under /restconf/data. After that comes the YANG path, with the module name as a prefix on the first node. List entries are selected with =key, and characters such as / in a key must be URL-encoded (%2F). Set the media type in headers:

  • Accept: application/yang-data+json to receive JSON.
  • Content-Type: application/yang-data+json when sending JSON.
  • Use application/yang-data+xml for XML instead.

Read with curl, prompting for the password (-u with only a username makes curl ask) and trusting your own CA (certificate authority) file:

curl -u netadmin --cacert ca.pem \
  -H "Accept: application/yang-data+json" \
  https://192.168.10.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet2

HTTP methods

MethodRESTCONF meaning
GETRead data
POSTCreate a new child resource (fails if it exists) or run an operation
PUTCreate or fully replace the target resource
PATCHMerge changes into the existing resource
DELETERemove the resource

PATCH is the safest choice for small changes because it only touches what you send. PUT replaces the whole target, so anything you leave out is removed.

RESTCONF from Python

import os
import requests

HOST = "192.168.10.1"
BASE = f"https://{HOST}/restconf/data"
AUTH = (os.environ["NET_USER"], os.environ["NET_PASS"])
HEADERS = {
    "Accept": "application/yang-data+json",
    "Content-Type": "application/yang-data+json",
}

url = f"{BASE}/ietf-interfaces:interfaces/interface=GigabitEthernet2"
r = requests.get(url, auth=AUTH, headers=HEADERS, verify="ca.pem", timeout=10)
r.raise_for_status()
print(r.json())

body = {"ietf-interfaces:interface": {"name": "GigabitEthernet2",
                                      "description": "Uplink to core-sw1"}}
r = requests.patch(url, json=body, auth=AUTH, headers=HEADERS, verify="ca.pem", timeout=10)
print(r.status_code)   # 204 No Content means success

Tip: do not use verify=False outside a throwaway lab. Install a proper certificate on the device, or point verify at your internal CA, so you know you are talking to the real switch.

Security and practical tips

  • Enable RESTCONF only on management interfaces and restrict access with ACLs (access control lists).
  • Use a dedicated, least-privilege account with AAA logging; HTTP Basic authentication is common, so TLS is essential.
  • Expect 401 for bad credentials, 404 for a wrong path and 400 for a body that does not match the model.
  • Explore paths with GET first and copy the structure you get back when building PATCH bodies.
  • RESTCONF has no candidate or locking; changes go straight to the running configuration (on most devices), so test in a lab.

Practice

Which method would you use to change just one interface description, and why?
PATCH, because it merges the change into the existing resource without removing other settings.
What Accept header asks for JSON from a RESTCONF server?
Accept: application/yang-data+json
What does an HTTP 204 response to a PATCH mean?
The change succeeded and the server returned no body.

Key takeaways

  • RESTCONF (RFC 8040) exposes YANG models over HTTPS.
  • URLs follow /restconf/data/module:container/list=key.
  • Use yang-data+json or yang-data+xml media types.
  • PATCH merges, PUT replaces, POST creates, DELETE removes.
  • Always verify TLS certificates and use least-privilege accounts.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.