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

# Retrieve consent history

> Returns every consent grant and revocation for the device, across VPP operators, most recent first. `consents` on the device holds what is granted now; a consent the user has withdrawn stays in this history. Each record has an ID that the VPP operator sees too.



## OpenAPI

````yaml energy-api/reference/flatpeak-api-spec-energy.json GET /devices/{device_id}/consent-history
openapi: 3.0.3
info:
  description: >-
    The Flatpeak Energy API connects energy hardware (batteries, EV chargers,
    vehicles, heat pumps, water heaters, solar and generators) to electricity
    prices, grid fees, and VPP programs.


    ## 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://energy-api.flatpeak.com`


    ## Pagination

    List endpoints return a `list` envelope with `data`, `next_cursor`, and
    `url`. Page forward by passing `next_cursor` as `cursor` on the next
    request, until it is `null`. Cursors are opaque and bound to the endpoint
    and query parameters that issued them.


    ## 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

    `live_mode` marks live or test data.
  version: 2027-01-01.busbar
  title: Flatpeak Energy 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://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, VPP enrollment, 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).
    x-tariff-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: Dispatch
    description: >-
      Fetch the VPP operator's instructions for a device, and confirm what the
      device will deliver.
  - name: Events
    description: Retrieve and list account events.
  - name: VPP Enrollments
    description: Create, retrieve and list VPP enrollments, and unenroll a device.
  - name: VPP Programs
    description: List VPP programs available to devices.
  - name: VPP Events
    description: >-
      VPP events committed by VPP operators, with your fleet's share and its
      per-device allocation. You can take over the allocation while it is open.
  - name: Operator groups
    description: >-
      Read-only views of the device groups VPP operators define. You see the
      groups that touch your fleet, and only your own devices in them.
  - name: Zones
    description: >-
      Network areas VPP operators define that touch your fleet. Read-only. You
      see only your own devices in them.
externalDocs:
  description: Documentation
  url: https://docs.flatpeak.com
paths:
  /devices/{device_id}/consent-history:
    parameters:
      - schema:
          type: string
        name: device_id
        in: path
        required: true
        description: Flatpeak Device ID.
    get:
      tags:
        - VPP Enrollments
      summary: Retrieve consent history
      description: >-
        Returns every consent grant and revocation for the device, across VPP
        operators, most recent first. `consents` on the device holds what is
        granted now; a consent the user has withdrawn stays in this history.
        Each record has an ID that the VPP operator sees too.
      operationId: get-consent-history
      parameters: []
      responses:
        '200':
          $ref: '#/components/responses/ConsentHistory'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        '503':
          $ref: '#/components/responses/503'
components:
  responses:
    '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'
    '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'
    ConsentHistory:
      description: Consent history response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ConsentHistory'
          example:
            object: consent_history
            device_id: dev_63a6087272941ef077a8fd3e
            account_id: acc_661677911f2197045e6cf1b1
            data:
              - id: cns_7b2e9d4a1c6f8e3b5a0d2c91
                operator_id: opr_6a3548352c0d07e89d47b7f1
                scopes:
                  - CONTROL
                action: REVOKED
                time_occurred: '2026-08-02T19:22:40Z'
              - id: cns_3f8a1c5e7d2b9a4c6e0f1b28
                operator_id: opr_6a3548352c0d07e89d47b7f1
                scopes:
                  - TELEMETRY
                  - CONTROL
                  - LOCATION
                action: GRANTED
                time_occurred: '2026-06-01T10:04:11Z'
  schemas:
    ConsentHistory:
      title: ConsentHistory
      type: object
      description: >-
        Every consent grant and revocation for the device, across the VPP
        operators it has consented to, with timestamps and scopes: `TELEMETRY`,
        `CONTROL`, `LOCATION`, `SETTINGS`. Consent changes only through Connect
        or user action, and does not expire.
      properties:
        object:
          type: string
          example: consent_history
          description: Object type, `consent_history`.
          enum:
            - consent_history
        device_id:
          type: string
          description: Flatpeak Device ID.
          example: dev_63a6087272941ef077a8fd3e
        account_id:
          type: string
          example: acc_661677911f2197045e6cf1b1
          description: Flatpeak Account ID.
          pattern: ^[a-z]{2,4}_[A-Za-z0-9]+$
        data:
          type: array
          description: Consent records, most recent first.
          items:
            type: object
            properties:
              id:
                type: string
                pattern: ^cns_[A-Za-z0-9]+$
                example: cns_3f8a1c5e7d2b9a4c6e0f1b28
                description: >-
                  Flatpeak ID of this consent record: one grant or one
                  revocation. The VPP operator sees the same ID for the same
                  record.
              operator_id:
                type: string
                example: opr_6a3548352c0d07e89d47b7f1
                description: >-
                  Flatpeak ID of the VPP operator the consent was granted to or
                  revoked from.
              scopes:
                type: array
                items:
                  type: string
                  enum:
                    - TELEMETRY
                    - CONTROL
                    - LOCATION
                    - SETTINGS
                example:
                  - TELEMETRY
                  - CONTROL
                  - LOCATION
                description: >-
                  Consent scopes the record covers, the same values as `scopes`
                  in the device's `consents`. A single Connect session can grant
                  or revoke several scopes at once.
              action:
                type: string
                enum:
                  - GRANTED
                  - REVOKED
                description: Whether the scopes were granted or revoked.
                example: GRANTED
              time_occurred:
                type: string
                format: date-time
                description: Time of the grant or revocation, in UTC.
                example: '2026-06-01T10:04:11Z'
            required:
              - id
              - operator_id
              - scopes
              - action
              - time_occurred
      required:
        - object
        - device_id
        - account_id
        - data
    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.