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

# Submit a device state

> Submits the current operational state of a device, such as battery state of charge and power.



## OpenAPI

````yaml api-reference/busbar/flatpeak-api-spec-busbar.json PUT /devices/{device_id}/state
openapi: 3.0.3
info:
  description: >-
    The Flatpeak API connects energy hardware (batteries, EV chargers, solar) to
    electricity prices, grid fees, and VPP programmes.


    ## Create bearer token

    Obtain a bearer token from `POST /auth/tokens` using your `account_id` and
    `secret_key` via basic auth, then send it as `Authorization: Bearer <token>`
    on every request.


    ## Base URL

    `https://api.flatpeak.com`


    ## Pagination

    List endpoints return a `list` envelope with `data`, `has_more`, and `url`.
    Page forward with `starting_after` (the last item id) or backward with
    `ending_before` (the first item id).


    ## Errors

    Every non-2xx response uses a standard error envelope with `object`, `type`,
    `code`, and `message`. Codes are machine-readable and safe to branch on.


    ## Money

    Monetary values are decimal numbers and are always paired with a
    `currency_code` (ISO 4217). Energy is expressed in kilowatt hours (kWh).


    ## Live vs test

    Objects carry a `live_mode` flag indicating whether they belong to live or
    test data.
  version: 2026-08-01.busbar
  title: Flatpeak API
  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://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 for customer authorisation flows.
  - name: Customers
    description: Create, retrieve, update, delete, and list customers.
  - name: Locations
    description: Create, retrieve, update, delete, and list locations.
  - name: Devices
    description: Create, retrieve, update, delete, and list device identifiers.
  - name: Meters
    description: Submit meter readings and retrieve records or batch status.
  - name: Tariffs
    description: Create, retrieve, update, 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: Schedules
    description: Find optimal times to consume or export energy by price.
  - name: Events
    description: Retrieve and list account events.
  - name: VPP Participations
    description: Retrieve and list VPP Participations.
externalDocs:
  description: Documentation
  url: https://docs.flatpeak.com
paths:
  /devices/{device_id}/state:
    parameters:
      - schema:
          type: string
        name: device_id
        in: path
        required: true
        description: Flatpeak Device ID.
    put:
      tags:
        - Devices
      summary: Submit a device state
      description: >-
        Submits the current operational state of a device, such as battery state
        of charge and power.
      operationId: submit-device-state
      requestBody:
        $ref: '#/components/requestBodies/DeviceStateSubmit'
      responses:
        '200':
          $ref: '#/components/responses/DeviceStateCreate'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '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:
  requestBodies:
    DeviceStateSubmit:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DeviceStateSubmit'
      required: true
  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'
    '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, e.g. 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'
    DeviceStateCreate:
      description: Example response
      content:
        application/json:
          schema:
            type: object
            properties:
              device_id:
                type: string
                example: dev_6563a6757360a6d6a628e839
                description: Flatpeak device ID.
              id:
                type: string
                example: dsr_6a284b7596d3f2b722544e70
                description: Flatpeak device state record ID.
              object:
                type: string
                example: device_state
                description: Object type.
              account_id:
                type: string
                example: acc_661677911f2197045e6cf1b1
                description: Flatpeak Account ID.
              time_created:
                type: string
                format: date-time
                example: '2022-02-01T10:33:00Z'
                description: Time when this object was created. In UTC.
            required:
              - id
              - device_id
              - time_created
              - account_id
  schemas:
    DeviceStateSubmit:
      type: object
      title: Submit a device state
      description: >-
        Submit the current operational state of a device, such as BESS state of
        charge and power.
      properties:
        record_reference_id:
          type: string
          example: MET1234567890
          description: >-
            Optional unique identifier for the telemetry record, used for
            idempotency and reconciliation.
        time:
          type: string
          example: '2022-02-01T10:30:00Z'
          description: Time the measurement was recorded, in RFC3339 format.
          format: date-time
        state_of_charge_percent:
          type: number
          example: 34.2
          description: Current battery state of charge as a percentage from 0 to 100.
        target_state_of_charge_percent:
          type: number
          example: 80
          description: Target battery state of charge as a percentage from 0 to 100.
        energy_flow_direction:
          type: string
          example: EXPORT
          description: >-
            Direction of energy flow this applies to. IMPORT (from grid) or
            EXPORT (to grid).
          enum:
            - IMPORT
            - EXPORT
        battery_power_kw:
          type: number
          description: Current battery power in kilowatts.
          example: 3.4
        energy_remaining_kwh:
          type: number
          description: >-
            Estimated usable energy currently available in the battery, in
            kilowatt-hours.
          example: 8.3
        backup_reserve_percent:
          type: number
          description: >-
            Percentage of battery capacity reserved for backup and unavailable
            for optimisation or dispatch.
          example: 20
      required:
        - time
        - state_of_charge_percent
        - target_state_of_charge_percent
      additionalProperties: false
    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, e.g. `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: '2025-01-01T00:00:00Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authenticate with `bearer` you obtained from
        [authentication](/api-reference/busbar/authentication) endpoint.

````