API

Networks

To manage the private networks for an account, there are a set of APIs for listing them, as well as adding, renaming and removing them by ID.


Create a private network

Creating a private network is done by sending a POST request to the https://api.civo.com/v2/networks resource.

Request

The following parameter should be sent along with the request:

Name Description
label a string that will be the displayed name/reference for the network.

Response

The response from the server will just be a confirmation of success.

{
  "result": "success"
}

Example of creating a private network

curl -H "Authorization: bearer 12345" \
https://api.civo.com/v2/networks -d label=development
var request = require('request');

request.post(
  'https://api.civo.com/v2/networks',
  {
    form: {
      label: 'development'
    }
  },
  function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body)
    }
  }
).auth(null, null, true, '12345');
http = Net::HTTPS.new('api.civo.com', 443)
headers = {
  'Authorization' => 'bearer 123456',
  'Content-Type' => 'application/x-www-form-urlencoded'
}

resp, data = http.post('/v2/networks', 'label=development', headers)

Listing the private networks

Listing the labels of the private networks is done by sending a GET request to the https://api.civo.com/v2/networks resource.

Request

This request doesn't take any parameters.

Response

The response from the server will be a list of the SSH keys known for the current account holder.

[
  {
    "id": "50f2fffa-f81e-4e96-830f-e78f7e565e6f",
    "label": "default",
    "region": "lon1",
    "default": false
  }
]

Example of listing the networks

curl -H "Authorization: bearer 12345" \
  https://api.civo.com/v2/networks
var request = require('request');

request.get(
  'https://api.civo.com/v2/networks',
  {},
  function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body)
    }
  }
).auth(null, null, true, '12345');
http = Net::HTTPS.new('api.civo.com', 443)
headers = {
  'Authorization' => 'bearer 123456',
  'Content-Type' => 'application/x-www-form-urlencoded'
}

resp, data = http.get('/v2/networks', '', headers)

Renaming a network

The account holder can rename a private network at any time, by sending a PUT request to https://api.civo.com/v2/networks/:id

Request

This request takes a body parameter of label which is the new label to use.

Response

The response from the server will be a JSON block. The response will include a result field and the HTTP status will be 202 Accepted.

{
  "label": "development",
  "result": "success"
}

Example of renaming a private network

curl -H "Authorization: bearer 12345" \
  -X PUT https://api.civo.com/v2/networks/12345 -d label=development
var request = require('request');

request.put(
  'https://api.civo.com/v2/networks/12345',
  {
    "label": "development"
  }
  function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body)
    }
  }
).auth(null, null, true, '12345');
http = Net::HTTPS.new('api.civo.com', 443)
headers = {
  'Authorization' => 'bearer 123456',
  'Content-Type' => 'application/x-www-form-urlencoded'
}

resp, data = http.put('/v2/networks/12345', "label=development" headers)

Removing a private network

The account holder can remove a private network, providing there are no instances using it. This action is performed by sending a DELETE request to https://api.civo.com/v2/networks/:id

Request

This request doesn't take any parameters other than the ID in the URL.

Response

The response from the server will be a JSON block. The response will include a result field and the HTTP status will be 202 Accepted.

{
  "result": "success"
}

Example of removing a private network

curl -H "Authorization: bearer 12345" \
  -X DELETE https://api.civo.com/v2/networks/12345
var request = require('request');

request.del(
  'https://api.civo.com/v2/networks/12345',
  function (error, response, body) {
    if (!error && response.statusCode == 200) {
      console.log(body)
    }
  }
).auth(null, null, true, '12345');
http = Net::HTTPS.new('api.civo.com', 443)
headers = {
  'Authorization' => 'bearer 123456',
  'Content-Type' => 'application/x-www-form-urlencoded'
}

resp, data = http.delete('/v2/networks/12345', headers)