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

# Retrieve a location cost

> Returns energy cost for the whole property from the records submitted under the location, over a window.



## OpenAPI

````yaml energy-api/reference/flatpeak-api-spec-energy-tariffs.json GET /locations/{location_id}/costs
openapi: 3.0.3
info:
  description: >-
    The tariff functions of the Flatpeak Energy API: tariff connection, prices,
    forecasts and costs. Generated from the full Energy API spec by
    scripts/build-tariff-spec.py. Do not edit.
  version: 2027-01-01.busbar
  title: 'Flatpeak Energy API: Tariffs'
  termsOfService: https://flatpeak.com/legal
  contact:
    name: Technical Support
    email: support@flatpeak.com
    url: https://flatpeak.com/contact
  license:
    name: Apache 2.0
    url: https://flatpeak.com/legal
servers:
  - url: https://energy-api.flatpeak.com
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: >-
      Exchange your account credentials for a bearer token to authenticate API
      requests.
  - name: Connect
    description: >-
      Create and retrieve Connect sessions. Connect drives the user journeys for
      tariff connection and [tariff error
      reporting](/energy-api/reference/connect/tariff/error-report). What
      happens in those journeys reaches your backend as [Connect
      webhooks](/energy-api/guides/platform/events).
  - name: Users
    description: Create, retrieve, update, delete, and list users.
  - name: Locations
    description: Create, retrieve, update, delete, and list locations.
  - name: Devices
    description: >-
      Create, retrieve, update, delete and list devices; submit and retrieve
      their state; read and write their shared settings.
  - name: Meters
    description: Submit meter records and check batch status.
  - name: Tariffs
    description: Create, retrieve, delete, and list tariffs.
  - name: Prices
    description: Retrieve and audit calculated energy prices.
  - name: Costs
    description: Calculate the monetary cost of imported or exported energy.
  - name: Optimizations
    description: >-
      Rank the connected tariff to find the best times to consume or export
      energy, as inputs to your own scheduling.
  - name: Events
    description: Retrieve and list account events.
externalDocs:
  description: Documentation
  url: https://docs.flatpeak.com
paths:
  /locations/{location_id}/costs:
    parameters:
      - name: location_id
        in: path
        required: true
        schema:
          type: string
          example: loc_641b90b758fb8e6293716e40
        description: Flatpeak Location ID.
    get:
      tags:
        - Costs
      summary: Retrieve a location cost
      description: >-
        Returns energy cost for the whole property from the records submitted
        under the location, over a window.
      operationId: get-location-cost
      parameters:
        - name: start_time
          in: query
          required: true
          schema:
            type: string
            format: date-time
            example: '2026-11-07T05:31:56Z'
          description: >-
            Period start time. In RFC 3339 format for example
            `2023-06-15T09:00:00Z` or with time offset, for example
            `2023-06-15T08:00:00+01:00`.
        - name: end_time
          in: query
          required: true
          schema:
            type: string
            format: date-time
            example: '2026-12-07T05:31:56Z'
          description: >-
            Period end time. In RFC 3339 format for example
            `2023-06-15T09:00:00Z` or with time offset, for example
            `2023-06-15T08:00:00+01:00`.
        - name: aggregate_by
          in: query
          required: false
          schema:
            type: string
            example: MONTH
            enum:
              - DAY
              - MONTH
          description: 'Aggregation interval for a window: `DAY` or `MONTH`.'
      responses:
        '200':
          $ref: '#/components/responses/EnergyCostInterval'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '422':
          $ref: '#/components/responses/422'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        '503':
          $ref: '#/components/responses/503'
components:
  responses:
    '400':
      description: >-
        400 Bad Request: the request was malformed or a required field is
        missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '401':
      description: '401 Unauthorized: authentication credentials are missing or invalid.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '403':
      description: '403 Forbidden: you do not have permission to access this resource.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '404':
      description: '404 Not Found: the requested resource does not exist.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '422':
      description: >-
        422 Unprocessable Entity: the request is well-formed but cannot be
        processed, for example missing required data.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '429':
      description: '429 Too Many Requests: the rate limit has been exceeded.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '500':
      description: >-
        500 Internal Server Error: an unexpected error occurred. Safe to retry
        with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    '503':
      description: >-
        503 Service Unavailable: the service is temporarily down for
        maintenance. Retry after the indicated delay.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    EnergyCostInterval:
      description: '200 OK: the calculated monetary cost of the imported or exported energy.'
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                type: string
                description: Flatpeak ID of this response.
                example: ecs_65ea3fb185c1541f247c251e
              object:
                type: string
                example: energy_cost
                description: Object type.
                enum:
                  - energy_cost
              device_id:
                type: string
                example: dev_65e6d8334c8d715963d99db3
                description: Device the cost is for; `null` for location costs.
                nullable: true
              session_reference_id:
                type: string
                description: Present when the cost was requested by `session_reference_id`.
                example: SESSION1234567890
                nullable: true
              live_mode:
                type: boolean
                description: '`true` for live data, `false` for test data.'
              timezone:
                type: string
                description: >-
                  Timezone at the location, tz database name such as
                  `Europe/Berlin`.
                example: Europe/London
              currency_code:
                type: string
                example: EUR
                description: >-
                  Currency of the cost values. Amounts are in large currency
                  units.
              data:
                type: object
                properties:
                  import:
                    type: array
                    items:
                      $ref: '#/components/schemas/EnergyCostResponse'
                    description: Cost intervals for imported energy.
                  export:
                    type: array
                    items:
                      $ref: '#/components/schemas/EnergyCostResponse'
                    description: Cost intervals for exported energy.
                description: Costs per energy flow direction.
              account_id:
                type: string
                example: acc_661677911f2197045e6cf1b1
                description: Flatpeak Account ID.
            required:
              - id
              - object
              - device_id
              - live_mode
              - timezone
              - currency_code
              - data
              - account_id
  schemas:
    EnergyCostResponse:
      type: object
      description: Calculated energy cost.
      properties:
        start_time:
          type: string
          description: Period start.
          format: date-time
          example: '2026-02-01T10:30:00Z'
        end_time:
          type: string
          description: Period end.
          format: date-time
          example: '2026-02-01T11:00:00Z'
        grid_energy_kwh:
          type: number
          example: 14.7
          description: >-
            Amount of energy transferred, in kilowatt hours. Negative values
            represent export.
        pv_energy_kwh:
          type: number
          example: 14.7
          description: Amount of PV energy, in kilowatt-hours. Included in grid_energy_kwh.
        cost:
          type: object
          description: >-
            Monetary cost of the energy, as a decimal amount paired with the
            response `currency_code` (ISO 4217).
          required:
            - value
            - confidence
          properties:
            value:
              type: number
              description: Monetary value in *large* currency units.
              example: 928.372
            confidence:
              type: number
              description: >-
                Estimated confidence of the data: `1` is 100% accurate, `0.1` is
                10%.
              example: 1
        pv_savings:
          type: object
          required:
            - value
            - confidence
          description: >-
            Monetary value of cost savings from PV generation, as a decimal
            amount paired with the response `currency_code` (ISO 4217).
          properties:
            value:
              type: number
              example: 45.329
              description: Monetary value in *large* currency units.
            confidence:
              type: number
              description: >-
                Estimated confidence of the data: `1` is 100% accurate, `0.1` is
                10%.
              example: 0.8
      required:
        - start_time
        - end_time
        - grid_energy_kwh
        - pv_energy_kwh
        - cost
        - pv_savings
    Error:
      type: object
      description: Standard error envelope returned by every non-2xx response.
      required:
        - object
        - type
        - code
        - message
      properties:
        object:
          type: string
          enum:
            - error
          default: error
          description: Object type.
        type:
          type: string
          description: High-level error category.
          example: invalid_request
        code:
          type: string
          description: Machine-readable error code, safe to branch on.
          example: not_found
        message:
          type: string
          description: Human-readable description of the error.
          example: The requested resource could not be found.
        context:
          type: string
          description: Optional originating context, for example `api.price_get`.
          example: api.price_get
        live_mode:
          type: boolean
          description: Whether the error occurred against live or test data.
        time_created:
          type: string
          format: date-time
          description: Time the error was generated (RFC 3339).
          example: '2026-01-01T00:00:00Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token obtained from POST /auth/tokens.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.