RESTCONF
RESTful API interface for IOS-XE device configuration and operational state retrieval.
Enable RESTCONF on IOS-XE
Switch(config)# ip http secure-server
Switch(config)# ip http authentication local
Switch(config)# restconf
RESTCONF runs over HTTPS (port 443). Unlike NETCONF (SSH on 830), it uses standard HTTP methods: GET, PUT, POST, PATCH, DELETE.
Switch# show running-config | section restconf
Switch# show platform software yang-management process
YANG-to-URL Mapping
RESTCONF URLs map directly to YANG model paths:
https://<host>/restconf/data/<module>:<container>/<node>
Example:
https://10.50.1.10/restconf/data/ietf-interfaces:interfaces
https://10.50.1.10/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1
https://10.50.1.10/restconf/data/Cisco-IOS-XE-native:native/hostname
List keys use = syntax: interface=GigabitEthernet1 selects one interface by its key.
Content-Type Headers
| Format | Header |
|---|---|
JSON |
|
XML |
|
Both Content-Type (request body) and Accept (response format) must be set. JSON is more readable; XML matches NETCONF payloads for consistency.
GET — Read Configuration
curl -s -k -u admin:<PASSWORD> \
-H "Accept: application/yang-data+json" \
https://10.50.1.10/restconf/data/ietf-interfaces:interfaces \
| jq '.'
curl -s -k -u admin:<PASSWORD> \
-H "Accept: application/yang-data+json" \
"https://10.50.1.10/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1" \
| jq '.'
Expected response:
{
"ietf-interfaces:interface": {
"name": "GigabitEthernet1",
"description": "Uplink to Core",
"type": "iana-if-type:ethernetCsmacd",
"enabled": true,
"ietf-ip:ipv4": {
"address": [
{
"ip": "10.50.1.10",
"netmask": "255.255.255.0"
}
]
}
}
}
PATCH — Modify Configuration
curl -s -k -u admin:<PASSWORD> \
-X PATCH \
-H "Content-Type: application/yang-data+json" \
-H "Accept: application/yang-data+json" \
"https://10.50.1.10/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1" \
-d '{
"ietf-interfaces:interface": {
"name": "GigabitEthernet1",
"description": "Updated via RESTCONF"
}
}'
HTTP 204 (No Content) means success. PATCH is idempotent and non-destructive — it only changes the fields you specify.
PUT — Replace Configuration
curl -s -k -u admin:<PASSWORD> \
-X PUT \
-H "Content-Type: application/yang-data+json" \
-H "Accept: application/yang-data+json" \
"https://10.50.1.10/restconf/data/ietf-interfaces:interfaces/interface=Loopback0" \
-d '{
"ietf-interfaces:interface": {
"name": "Loopback0",
"type": "iana-if-type:softwareLoopback",
"enabled": true,
"ietf-ip:ipv4": {
"address": [
{
"ip": "10.50.255.1",
"netmask": "255.255.255.255"
}
]
}
}
}'
| PUT replaces the entire resource. If you omit the IP address, it gets removed. Use PATCH for partial updates. |
POST — Create New Resources
curl -s -k -u admin:<PASSWORD> \
-X POST \
-H "Content-Type: application/yang-data+json" \
-H "Accept: application/yang-data+json" \
"https://10.50.1.10/restconf/data/ietf-interfaces:interfaces" \
-d '{
"ietf-interfaces:interface": {
"name": "Loopback99",
"type": "iana-if-type:softwareLoopback",
"enabled": true
}
}'
HTTP 201 (Created) means success. HTTP 409 (Conflict) means the resource already exists — use PUT or PATCH instead.
DELETE — Remove Configuration
curl -s -k -u admin:<PASSWORD> \
-X DELETE \
"https://10.50.1.10/restconf/data/ietf-interfaces:interfaces/interface=Loopback99"
Operational Data
/restconf/data with the -oper modelscurl -s -k -u admin:<PASSWORD> \
-H "Accept: application/yang-data+json" \
"https://10.50.1.10/restconf/data/Cisco-IOS-XE-interfaces-oper:interfaces/interface=GigabitEthernet1" \
| jq '.["Cisco-IOS-XE-interfaces-oper:interface"]'
This returns counters, oper-status, speed, and statistics — the equivalent of show interface GigabitEthernet1.
Common Endpoints
| Endpoint | Description |
|---|---|
|
All interfaces (config) |
|
Full native IOS-XE config tree |
|
Device hostname |
|
Static routes |
|
Interfaces via OpenConfig model |
|
Interface operational data |
|
Available RPC operations |
|
RESTCONF root discovery |
Discovery
curl -s -k -u admin:<PASSWORD> \
https://10.50.1.10/.well-known/host-meta \
| grep restconf
Expected output:
<Link rel="restconf" href="/restconf"/>
HTTP Methods Summary
| Method | Action | Idempotent? |
|---|---|---|
GET |
Read config or operational data |
Yes |
POST |
Create a new resource |
No (409 if exists) |
PUT |
Create or replace entire resource |
Yes |
PATCH |
Merge partial update into resource |
Yes |
DELETE |
Remove a resource |
Yes |
For automation scripts, prefer PATCH over PUT. PATCH is safer because it only touches what you specify — no risk of accidentally wiping fields you forgot to include.