Skip to main content
GET
/
costs
Get costs for cost report or VQL filter
curl --request GET \
  --url https://api.vantage.sh/v2/costs \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.vantage.sh/v2/costs"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.vantage.sh/v2/costs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vantage.sh/v2/costs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.vantage.sh/v2/costs"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.vantage.sh/v2/costs")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.vantage.sh/v2/costs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "links": {
    "self": "https://api.vantage.sh/v2/costs?cost_report_token=rprt_ea7dbb4f5783d677",
    "first": "https://api.vantage.sh/v2/costs?cost_report_token=rprt_ea7dbb4f5783d677&page=1",
    "next": null,
    "last": null,
    "prev": null
  },
  "total_cost": {
    "amount": "500.0",
    "currency": "USD"
  },
  "costs": [
    {
      "accrued_at": "2023-06-05",
      "amount": "100.0",
      "currency": "USD",
      "provider": "aws",
      "account_id": "mock_56789",
      "service": "AmazonSNS"
    },
    {
      "accrued_at": "2023-06-04",
      "amount": "100.0",
      "currency": "USD",
      "provider": "aws",
      "account_id": "mock_56789",
      "service": "AmazonSNS"
    },
    {
      "accrued_at": "2023-06-03",
      "amount": "100.0",
      "currency": "USD",
      "provider": "aws",
      "account_id": "mock_56789",
      "service": "AmazonSNS"
    },
    {
      "accrued_at": "2023-06-02",
      "amount": "100.0",
      "currency": "USD",
      "provider": "aws",
      "account_id": "mock_56789",
      "service": "AmazonSNS"
    },
    {
      "accrued_at": "2023-06-01",
      "amount": "100.0",
      "currency": "USD",
      "provider": "aws",
      "account_id": "mock_56789",
      "service": "AmazonSNS"
    }
  ]
}
{
"errors": [
"<string>"
],
"links": {
"self": "<string>",
"first": "<string>",
"next": "<string>",
"last": "<string>",
"prev": "<string>"
}
}
{
"errors": [
"<string>"
],
"links": {
"self": "<string>",
"first": "<string>",
"next": "<string>",
"last": "<string>",
"prev": "<string>"
}
}
{
"errors": [
"<string>"
],
"links": {
"self": "<string>",
"first": "<string>",
"next": "<string>",
"last": "<string>",
"prev": "<string>"
}
}

Authorizations

Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Query Parameters

cost_report_token
string

The CostReport token.

filter
string

The VQL filter to apply to the costs. If this is supplied you do not need cost_report_token.

workspace_token
string

The token of the Workspace to query costs from. Ignored if 'cost_report_token' is set. Required if the API token is associated with multiple Workspaces.

start_date
string

First date you would like to filter costs from. ISO 8601 formatted.

end_date
string

Last date you would like to filter costs to. ISO 8601 formatted.

groupings
string[]

Group the results by specific field(s). Defaults to provider, service, account_id. Valid groupings: account_id, billing_account_id, charge_type, cost_category, cost_subcategory, provider, region, resource_id, service, tagged, tag:<tag_value>. If providing multiple groupings, join as comma separated values: groupings=provider,service,region

order
enum<string>
default:desc

Whether to order costs by date in an ascending or descending manner.

Available options:
asc,
desc
limit
integer<int32>

The amount of results to return. The maximum is 5000.

page
integer<int32>

The page of results to return.

date_bin
enum<string>

The date bin of the costs. Defaults to the report's default or day.

Available options:
day,
week,
month,
quarter,
hour
settings[include_credits]
boolean
default:false

Results will include credits.

settings[include_refunds]
boolean
default:false

Results will include refunds.

settings[include_discounts]
boolean
default:true

Results will include discounts.

settings[include_tax]
boolean
default:true

Results will include tax.

settings[amortize]
boolean
default:true

Results will amortize.

settings[unallocated]
boolean
default:false

Results will show unallocated costs.

settings[aggregate_by]
string
default:cost

Results will aggregate by cost or usage.

settings[show_previous_period]
boolean
default:true

Results will show previous period costs or usage comparison.

Response

Costs model

total_cost
object
required
costs
object[]
required
total_usage
object[]

The sum of all usage for the CostReport for the requested period, rounded to 2 decimal places, grouped by usage unit.