API

Charges

The system tracks usage of paid service on an hourly basis. It doesn't track how much to charge for any particular product, but it will report for each instance, IP address and snapshot the amount of hours it's in use for.


Listing charges

Listing the charges for an Account must be done either with an administrator API key and specifying the account_id in question or using an API key from a user with admin/billing-view permission. The request should be a GET request to the https://api.civo.com/v2/charges resource.

Request

This request doesn't require any parameters, but you can specify a time range (maximum of 31 days) with:

Name Description
from The from date in RFC 3339 format (default to the start of the current month)
to The to date in RFC 3339 format (defaults to the current time)

Response

The response from the server will be a list of chargeable resources.

[
  {
    "code": "instance-g1.small",
    "label": "furry-apple.example.com",
    "from": "2016-03-18T10:46:06Z",
    "to": "2016-03-25T10:46:06Z",
    "num_hours": 168
  },
]

Example of listing the charges

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

request.get(
  'https://api.civo.com/v2/charges',
  {},
  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/charges', '', headers)