API

API Access

This is the entire API for the Civo cloud platform. All resources may not be available to your API key, though if you believe this to be an error, please contact info@absolutedevops.io.

Our API wraps OpenStack's APIs and makes managing your instances and related resources much easier.


Authentication

After signing up for a Civo account, your API key will be shown on this page. This should be sent with every request in an Authorization header. For example, if your API key was "12345" you should send an Authorization header using the bearer type like this

Authorization: bearer 12345

Parameters and responses

If you are sending information to the API such as the details of an instance to create, these should be sent as normal form encoded variables. JSON request bodies aren't accepted.

The response of an API will be a JSON-encoded object for all 2xx statuses. 4xx/5xx status may not be JSON, unless it's obvious that the response should be parsed for a specific reason. So, for example, 404 Not Found pages are a standard page of text but 403 Unauthorized requests may have a reason attribute available in the JSON object.

Below are some code samples showing a simple request in each of Curl, Javascript and Ruby - all using 123456 as the API key.

Example of creating an instance

curl -H "Authorization: bearer 12345" https://api.civo.com/v2/instances -d hostname=test.example.com
var request = require('request');

request.post(
  'https://api.civo.com/v2/instances',
  {
    form: {
      hostname: 'test.example.com'
    }
  },
  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/instances', 'hostname=test.example.com', headers)

Raw OpenStack APIs

If you prefer, you can also directly use the OpenStack APIs using the endpoints listed by our Keystone server at https://auth.civo.com and the username and password specified here after you signup/login. There's more information on the OpenStack APIs available at the OpenStack Developer Site.

This is the end of the documentation provided here on using the OpenStack APIs. They are generally unsupported by us (except for if the API doesn't work at all, but misunderstandings and issues with knowing what API calls to make are a matter for the OpenStack team).

Example of Keystone Authentication using cURL

curl -i \
-H "Content-Type: application/json" \
-d '
{
"auth": {
"identity": {
  "methods": ["password"],
  "password": {
    "user": {
      "name": "YOUR_USERNAME",
      "domain": { "id": "default" },
      "password": "YOUR_PASSWORD"
    }
  }
}
}
}' \
https://auth.civo.com/v3/auth/tokens