Skip to main content
This quickstart guide will walk you through building a complete cost management workflow using the Vantage API. You’ll learn to create folders, generate Cost Reports, and analyze spending data programmatically.

Prerequisites

Base URL

All Vantage API v2 requests use the following base URL:
https://api.vantage.sh/v2
In this quickstart, we’ll cover the following steps:
1

Discover Workspaces

First, we’ll retrieve all workspaces your API token has access to.
2

Create Organization

Set up a folder structure to organize your Cost Reports.
3

Generate Cost Report

Create a VQL-powered Cost Report with specific filters.
4

Analyze Data

Retrieve and analyze cost and usage data from your report.

Step 1: Discover Your Workspaces

GET /workspaces

Retrieve all workspaces your API token has access to. This endpoint returns workspace tokens and metadata that you’ll use in subsequent API calls.
curl --request GET \
     --url https://api.vantage.sh/v2/workspaces \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ACCESS_TOKEN'

Step 2: Create an Organized Folder Structure

POST /folders

Create a folder to organize your Cost Reports. This helps maintain a clean structure for your cost management workflows.
curl --request POST \
     --url https://api.vantage.sh/v2/folders \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ACCESS_TOKEN' \
     --header 'content-type: application/json' \
     --data '{
  "title": "Team Reports",
  "workspace_token": "wrkspc_123445abcde"
}'
Use the workspace token from Step 1. You can also specify a parent_folder_token to create nested folder structures.

Step 3: Create an Intelligent Cost Report

VQL

This step demonstrates the power of Vantage Query Language (VQL), a flexible query system that lets you filter costs by provider, tags, services, and more. Learn more about VQL syntax.

POST /cost_reports

Create a VQL-powered Cost Report that automatically filters AWS production costs.
curl --request POST \
     --url https://api.vantage.sh/v2/cost_reports \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <ACCESS_TOKEN>' \
     --header 'content-type: application/json' \
     --data '{
  "settings": {
    "include_credits": false,
    "include_refunds": false,
    "include_discounts": true,
    "include_tax": true,
    "amortize": true,
    "unallocated": false,
    "aggregate_by": "cost",
    "show_previous_period": true
  },
  "chart_type": "line",
  "date_bin": "cumulative",
  "title": "AWS Production Costs",
  "folder_token": "fldr_123456abcde123",
  "filter": "costs.provider = 'aws' AND tags.name = 'environment' AND tags.value = 'production'"
}'
The VQL filter costs.provider = 'aws' AND tags.name = 'environment' AND tags.value = 'production' does the following:
  • costs.provider = 'aws' - Only includes AWS costs
  • tags.name = 'environment' - Filters for resources with an environment tag
  • tags.value = 'production' - Only includes resources tagged as production
This creates a focused report showing only your production AWS spending.

Step 4: Analyze Your Cost Data

GET /costs

Retrieve detailed cost data from your report with flexible filtering and grouping options. This demonstrates how to extract actionable insights from your cost data.
curl --request GET \
     --url 'https://api.vantage.sh/v2/costs?cost_report_token=rprt_1234a5678b1ab234&start_date=2023-12-01&end_date=2023-12-31&groupings=service&order=desc' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <ACCESS_TOKEN>'
  • cost_report_token - Uses the report token from Step 3
  • start_date & end_date - ISO 8601 date range for filtering
  • groupings=service - Groups costs by AWS service (EC2, RDS, etc.)
  • order=desc - Sorts by date in descending order (newest first)

Bonus: Retrieve Usage Analytics

Usage Data Insights

Beyond cost data, the Vantage API provides detailed usage analytics. This is perfect for understanding resource utilization patterns and optimizing your infrastructure.

GET /costs with Usage Data

Retrieve both cost and usage data by setting aggregate_by=usage. This provides comprehensive resource utilization insights.
curl --request GET \
     --url 'https://api.vantage.sh/v2/costs?cost_report_token=rprt_1234a5678b1ab234&order=desc&settings%5Binclude_credits%5D=false&settings%5Binclude_refunds%5D=false&settings%5Binclude_discounts%5D=true&settings%5Binclude_tax%5D=true&settings%5Bamortize%5D=true&settings%5Bunallocated%5D=false&settings%5Baggregate_by%5D=usage' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer TOKEN'
The key parameter here is settings[aggregate_by]=usage which switches from cost aggregation to usage aggregation.

What You've Accomplished

You’ve successfully built a complete cost management workflow using the Vantage API:
  • Discovered workspaces and retrieved access tokens
  • Created organized folders for Cost Report management
  • Generated intelligent Cost Reports using VQL filtering
  • Analyzed cost data with flexible grouping and filtering
  • Retrieved usage analytics for resource optimization