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

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 (optional) The from date in RFC 3339 format (default to the start of the current month)
to (optional) 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. The size_gb attribute currently only returns a value for volume related charges as they as charged on a per GB basis as opposed to hourly.

[
    {
        "code": "instance-g3.small",
        "product_id": "3cd8e85f-259f-4e57-86e0-941ff75320c9",
        "label": "foo.com-9cdd7e2f",
        "from": "2021-09-01T03:59:57+01:00",
        "to": "2021-09-01T04:03:00+01:00",
        "num_hours": 1,
        "size_gb": null,
        "region": "NYC1"
    },
    {
        "code": "volume",
        "product_id": "b4a2b8d0-15ef-4dfe-8230-1b09c0d682ed",
        "label": "Volume pvc-15775bd7-f4c0-4343-b756-d6511a7e0c3b (10GB)",
        "from": "2021-09-01T09:54:09+01:00",
        "to": "2021-09-02T04:01:01+01:00",
        "num_hours": 18,
        "size_gb": 10,
        "region": "LON1"
    }
    // ...
]

Example of listing the charges

curl -H "Authorization: bearer 12345" \
  https://api.civo.com/v2/charges
// At a shell prompt run:
// npm init -y
// npm i --save request

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');
require 'net/http'

http = Net::HTTP.new('api.civo.com', 443)
http.use_ssl = true

headers = {
  'Authorization' => 'bearer 12345',
  'Content-Type' => 'application/x-www-form-urlencoded'
}

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