Skip to content

Routers API reference

See https://docs.openstack.org/api-ref/network/.

In these methods, {router_id} is the ID of the router, "router_name" is the name of the router, "external_network_id" is the ID of the external network to be used as the router's gateway, "subnet_id" is the ID of the subnet to be added as an interface to the router, and "port_id" is the ID of the port to be added as an interface to the router. These methods allow you to list existing routers, show details of a specific router, create a new router, update an existing router, delete a router, add or remove interfaces to or from a router, and set or clear the external gateway for a router in the Network service.

List routers

Bash
GET /v2.0/routers

Show router details

Bash
GET /v2.0/routers/{router_id}

Create a router

Bash
POST /v2.0/routers

Request body

JSON
{
 "router": {
   "name": "router_name",
   "admin_state_up": true,
   "external_gateway_info": {
     "network_id": "external_network_id"
   }
 }
}

Update a router

Bash
PUT /v2.0/routers/{router_id}

Request body

JSON
{
 "router": {
   "name": "new_router_name",
   "admin_state_up": false
 }
}

Delete a router

Bash
DELETE /v2.0/routers/{router_id}

Add interface to router

Bash
PUT /v2.0/routers/{router_id}/add_router_interface

Request body (using a subnet ID)

JSON
{
 "subnet_id": "subnet_id"
}

Request body (using a port ID)

JSON
{
 "port_id": "port_id"
}

Remove interface from router

Bash
PUT /v2.0/routers/{router_id}/remove_router_interface

Request body (using a subnet ID)

JSON
{
 "subnet_id": "subnet_id"
}

Request body (using a port ID)

JSON
{
 "port_id": "port_id"
}

External gateway for router

Bash
PUT /v2.0/routers/{router_id}

Request body

JSON
{
 "router": {
 "external_gateway_info": {
     "network_id": "external_network_id"
   }
 }
}

Clear external gateway from router

Bash
PUT /v2.0/routers/{router_id}

Request Body:

JSON
{
 "router": {
   "external_gateway_info": null
 }
}