> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vantage.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Get costs for cost report or VQL filter

> Return all Costs for a CostReport or VQL filter.



## OpenAPI

````yaml https://api.vantage.sh/v2/oas_v3.json get /costs
openapi: 3.0.1
info:
  title: Vantage
  description: Vantage API
  termsOfService: https://www.vantage.sh/terms-of-use
  contact:
    name: Vantage Support
    url: https://www.vantage.sh
    email: support@vantage.sh
  version: 2.0.0
servers:
  - url: https://api.vantage.sh/v2
security:
  - oauth2:
      - read
tags:
  - name: AccessGrants
    description: Operations about AccessGrants
  - name: AnomalyAlerts
    description: Operations about AnomalyAlerts
  - name: AnomalyNotifications
    description: Operations about AnomalyNotifications
  - name: AuditLogs
    description: Operations about AuditLogs
  - name: BillingProfiles
    description: Operations about BillingProfiles
  - name: BillingRules
    description: Operations about BillingRules
  - name: BudgetAlerts
    description: Operations about BudgetAlerts
  - name: Budgets
    description: Operations about Budgets
  - name: BusinessMetrics
    description: Operations about BusinessMetrics
  - name: Canvases
    description: Operations about Canvases
  - name: CostAlertEvents
    description: Operations about CostAlertEvents
  - name: CostAlerts
    description: Operations about CostAlerts
  - name: CostProvider
    description: Operations about CostProviders
  - name: CostProviderAccounts
    description: Operations about CostProviderAccounts
  - name: Costs
    description: Operations about Costs
  - name: CostService
    description: Operations about CostServices
  - name: Dashboards
    description: Operations about Dashboards
  - name: DataExports
    description: Operations about DataExports
  - name: ExchangeRates
    description: Operations about ExchangeRates
  - name: FinancialCommitmentReports
    description: Operations about FinancialCommitmentReports
  - name: FinancialCommitments
    description: Operations about FinancialCommitments
  - name: Folders
    description: Operations about Folders
  - name: Integrations
    description: Operations about Integrations
  - name: Invoices
    description: Operations about Invoices
  - name: KubernetesEfficiencyReports
    description: Operations about KubernetesEfficiencyReports
  - name: ManagedAccounts
    description: Operations about ManagedAccounts
  - name: Me
    description: Operations about Mes
  - name: NetworkFlowReports
    description: Operations about NetworkFlowReports
  - name: OpenAPISpecification
    description: Operations about OpenAPISpecifications
  - name: Ping
    description: Operations about Pings
  - name: Prices
    description: Operations about Prices
  - name: Recommendations
    description: Operations about Recommendations
  - name: RecommendationViews
    description: Operations about RecommendationViews
  - name: ReportNotifications
    description: Operations about ReportNotifications
  - name: ResourceReports
    description: Operations about ResourceReports
  - name: Resources
    description: Operations about Resources
  - name: SavedFilters
    description: Operations about SavedFilters
  - name: Segments
    description: Operations about Segments
  - name: Tags
    description: Operations about Tags
  - name: Teams
    description: Operations about Teams
  - name: UnitCosts
    description: Operations about UnitCosts
  - name: UserFeedback
    description: Operations about UserFeedbacks
  - name: Users
    description: Operations about Users
  - name: VirtualTags
    description: Operations about VirtualTags
  - name: Workspaces
    description: Operations about Workspaces
paths:
  /costs:
    get:
      tags:
        - Costs
      summary: Get costs for cost report or VQL filter
      description: Return all Costs for a CostReport or VQL filter.
      operationId: getCosts
      parameters:
        - name: cost_report_token
          in: query
          description: The CostReport token.
          schema:
            type: string
        - name: filter
          in: query
          description: >-
            The VQL filter to apply to the costs. If this is supplied you do not
            need cost_report_token.
          schema:
            type: string
        - name: workspace_token
          in: query
          description: >-
            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.
          schema:
            type: string
        - name: start_date
          in: query
          description: First date you would like to filter costs from. ISO 8601 formatted.
          schema:
            type: string
        - name: end_date
          in: query
          description: Last date you would like to filter costs to. ISO 8601 formatted.
          schema:
            type: string
        - name: groupings
          in: query
          description: >-
            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
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
        - name: order
          in: query
          description: Whether to order costs by date in an ascending or descending manner.
          schema:
            type: string
            default: desc
            enum:
              - asc
              - desc
        - name: limit
          in: query
          description: The amount of results to return. The maximum is 5000.
          schema:
            type: integer
            format: int32
        - name: page
          in: query
          description: The page of results to return.
          schema:
            type: integer
            format: int32
        - name: date_bin
          in: query
          description: The date bin of the costs. Defaults to the report's default or day.
          schema:
            type: string
            enum:
              - day
              - week
              - month
              - quarter
              - hour
        - name: settings[include_credits]
          in: query
          description: Results will include credits.
          schema:
            type: boolean
            default: false
        - name: settings[include_refunds]
          in: query
          description: Results will include refunds.
          schema:
            type: boolean
            default: false
        - name: settings[include_discounts]
          in: query
          description: Results will include discounts.
          schema:
            type: boolean
            default: true
        - name: settings[include_tax]
          in: query
          description: Results will include tax.
          schema:
            type: boolean
            default: true
        - name: settings[amortize]
          in: query
          description: Results will amortize.
          schema:
            type: boolean
            default: true
        - name: settings[unallocated]
          in: query
          description: Results will show unallocated costs.
          schema:
            type: boolean
            default: false
        - name: settings[aggregate_by]
          in: query
          description: Results will aggregate by cost or usage.
          schema:
            type: string
            default: cost
        - name: settings[show_previous_period]
          in: query
          description: Results will show previous period costs or usage comparison.
          schema:
            type: boolean
            default: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Costs'
              example:
                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
        '400':
          description: BadRequest
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
        '402':
          description: PaymentRequired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
        '404':
          description: NotFound
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
      security:
        - oauth2:
            - read
components:
  schemas:
    Costs:
      required:
        - costs
        - total_cost
      type: object
      properties:
        links:
          $ref: '#/components/schemas/Links'
        total_cost:
          $ref: '#/components/schemas/CostPartial'
        total_usage:
          type: array
          description: >-
            The sum of all usage for the CostReport for the requested period,
            rounded to 2 decimal places, grouped by usage unit.
          items:
            $ref: '#/components/schemas/UsagePartial'
        costs:
          type: array
          items:
            $ref: '#/components/schemas/Cost'
      description: Costs model
    Errors:
      required:
        - errors
      type: object
      properties:
        links:
          $ref: '#/components/schemas/Links'
        errors:
          type: array
          nullable: false
          items:
            type: string
      description: Errors model
    Links:
      type: object
      properties:
        self:
          type: string
          description: The URL of the current page of results.
          nullable: true
        first:
          type: string
          description: The URL of the first page of results.
          nullable: true
        next:
          type: string
          description: The URL of the next page of results, if one exists.
          nullable: true
        last:
          type: string
          description: The URL of the last page of results, if one exists.
          nullable: true
        prev:
          type: string
          description: The URL of the previous page of results, if one exists.
          nullable: true
    CostPartial:
      required:
        - amount
        - currency
      type: object
      properties:
        amount:
          type: string
          description: The amount of the cost.
          nullable: false
          example: '4.25'
        currency:
          type: string
          description: The currency of the cost.
          nullable: false
          example: USD
    UsagePartial:
      required:
        - amount
        - unit
      type: object
      properties:
        amount:
          type: string
          description: The sum of the usage.
          nullable: false
          example: '4.25'
        unit:
          type: string
          description: The unit of the usage.
          nullable: false
          example: USD
    Cost:
      required:
        - accrued_at
        - amount
        - currency
      type: object
      properties:
        links:
          $ref: '#/components/schemas/Links'
        accrued_at:
          type: string
          description: The date the cost was accrued. ISO 8601 Formatted.
          nullable: false
          example: 2023-09-05+00:00
        amount:
          type: string
          description: The amount of the cost.
          nullable: false
          example: '4.25'
        currency:
          type: string
          description: The currency of the cost.
          nullable: false
          example: USD
        usage:
          type: object
          properties: {}
          description: The usage amount and unit incurred by the cost.
          nullable: true
        provider:
          type: string
          description: The cost provider which incurred the cost.
          nullable: true
          example: aws
          enum:
            - aws
            - azure
            - gcp
            - snowflake
            - databricks
            - mongo
            - datadog
            - fastly
            - new_relic
            - opencost
            - open_ai
            - oracle
            - confluent
            - planetscale
            - coralogix
            - kubernetes
            - custom_provider
            - github
            - linode
            - grafana
            - clickhouse
            - temporal
            - twilio
            - azure_csp
            - kubernetes_agent
            - anthropic
            - anyscale
            - cursor
            - elastic
            - vercel
            - redis_cloud
            - circle_ci
            - modal
            - eleven_labs
            - baseten
            - cloudflare
            - fireworks_ai
        billing_account_id:
          type: string
          description: The cost provider's billing account id that incurred the cost.
          nullable: true
          example: '9109237192'
        account_id:
          type: string
          description: The cost provider's account id that incurred the cost.
          nullable: true
          example: '9109237192'
        service:
          type: string
          description: The service which incurred the cost.
          nullable: true
          example: Amazon Elastic Compute Cloud - Compute
        region:
          type: string
          description: The region which incurred the cost.
          nullable: true
          example: us-east-1
        resource_id:
          type: string
          description: The resource id which incurred the cost.
          nullable: true
          example: arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0
        resource_name:
          type: string
          description: >-
            The human-readable resource name when Vantage can enrich the
            resource id.
          nullable: true
          example: claude_code_key_name
        tag:
          type: string
          description: |-
            The tag attached to the cost that was incurred.
            DEPRECATED: does not support multiple tags.
          nullable: true
          example: production
        tags:
          type: array
          description: The tag pairs attached to the cost that was incurred.
          nullable: true
          items:
            type: string
            example: ''
        cost_category:
          type: string
          description: The category for the cost.
          nullable: true
          example: Data Transfer
        cost_subcategory:
          type: string
          description: The subcategory for the cost.
          nullable: true
          example: DataTransfer-Regional-Bytes
        segment:
          type: string
          description: The segment name for segment report costs.
          nullable: true
          example: Engineering
      description: Cost model
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://console.vantage.sh/account/profile
          scopes:
            read: Grants read access
            write: Grants write access

````