Skip to main content
PUT
/
meters
/
cumulative
/
epoch
Submit cumulative meter records
curl --request PUT \
  --url https://api.flatpeak.com/meters/cumulative/epoch \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "location_id": "loc_641b90b758fb8e6293716e40",
  "units": "WH",
  "data": [
    {
      "time": 1721991392,
      "value": 1553,
      "record_reference_id": "MET1234567890"
    }
  ],
  "device_id": "dev_65e6d8334c8d715963d99db3",
  "session_reference_id": "SESSION1234567890",
  "energy_flow_direction": "INBOUND",
  "tariff_direction": "IMPORT"
}
'
import requests

url = "https://api.flatpeak.com/meters/cumulative/epoch"

payload = {
"location_id": "loc_641b90b758fb8e6293716e40",
"units": "WH",
"data": [
{
"time": 1721991392,
"value": 1553,
"record_reference_id": "MET1234567890"
}
],
"device_id": "dev_65e6d8334c8d715963d99db3",
"session_reference_id": "SESSION1234567890",
"energy_flow_direction": "INBOUND",
"tariff_direction": "IMPORT"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
location_id: 'loc_641b90b758fb8e6293716e40',
units: 'WH',
data: [{time: 1721991392, value: 1553, record_reference_id: 'MET1234567890'}],
device_id: 'dev_65e6d8334c8d715963d99db3',
session_reference_id: 'SESSION1234567890',
energy_flow_direction: 'INBOUND',
tariff_direction: 'IMPORT'
})
};

fetch('https://api.flatpeak.com/meters/cumulative/epoch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flatpeak.com/meters/cumulative/epoch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'location_id' => 'loc_641b90b758fb8e6293716e40',
'units' => 'WH',
'data' => [
[
'time' => 1721991392,
'value' => 1553,
'record_reference_id' => 'MET1234567890'
]
],
'device_id' => 'dev_65e6d8334c8d715963d99db3',
'session_reference_id' => 'SESSION1234567890',
'energy_flow_direction' => 'INBOUND',
'tariff_direction' => 'IMPORT'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.flatpeak.com/meters/cumulative/epoch"

payload := strings.NewReader("{\n \"location_id\": \"loc_641b90b758fb8e6293716e40\",\n \"units\": \"WH\",\n \"data\": [\n {\n \"time\": 1721991392,\n \"value\": 1553,\n \"record_reference_id\": \"MET1234567890\"\n }\n ],\n \"device_id\": \"dev_65e6d8334c8d715963d99db3\",\n \"session_reference_id\": \"SESSION1234567890\",\n \"energy_flow_direction\": \"INBOUND\",\n \"tariff_direction\": \"IMPORT\"\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.flatpeak.com/meters/cumulative/epoch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"location_id\": \"loc_641b90b758fb8e6293716e40\",\n \"units\": \"WH\",\n \"data\": [\n {\n \"time\": 1721991392,\n \"value\": 1553,\n \"record_reference_id\": \"MET1234567890\"\n }\n ],\n \"device_id\": \"dev_65e6d8334c8d715963d99db3\",\n \"session_reference_id\": \"SESSION1234567890\",\n \"energy_flow_direction\": \"INBOUND\",\n \"tariff_direction\": \"IMPORT\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.flatpeak.com/meters/cumulative/epoch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"location_id\": \"loc_641b90b758fb8e6293716e40\",\n \"units\": \"WH\",\n \"data\": [\n {\n \"time\": 1721991392,\n \"value\": 1553,\n \"record_reference_id\": \"MET1234567890\"\n }\n ],\n \"device_id\": \"dev_65e6d8334c8d715963d99db3\",\n \"session_reference_id\": \"SESSION1234567890\",\n \"energy_flow_direction\": \"INBOUND\",\n \"tariff_direction\": \"IMPORT\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "bat_65e42b7827c0526548432b9f",
  "object": "meter_batch",
  "records_submitted": 18379,
  "records_accepted": 18378,
  "records_processed": 32,
  "failed_records": [
    {
      "record_num": 1,
      "error": "end_time must not be before start_time",
      "record_reference_id": "MET1234567890"
    }
  ],
  "time_created": "2023-11-07T05:31:56Z",
  "account_id": "acc_661677911f2197045e6cf1b1"
}
{
"object": "error",
"type": "invalid_request",
"code": "access_denied",
"time_created": "2025-01-01T00:00:00Z"
}
{
"object": "error",
"type": "rate_limit",
"code": "too_many_requests",
"message": "Too many requests. Please retry after a short delay.",
"time_created": "2026-01-29T17:11:52Z"
}

Authorizations

Authorization
string
header
required

Authenticate with bearer you obtained from authentication endpoint.

Body

application/json
location_id
string
required

Flatpeak location_id that you are submitting metering records for.

Example:

"loc_641b90b758fb8e6293716e40"

units
string
required

Units of measure, supported values are WH, KWH.

Example:

"WH"

data
object[]
required

Metering data array

device_id
string

Flatpeak device_id you are submitting metering records for. If you provided both location_id and device_id your records will be attributed to device_id.

Example:

"dev_65e6d8334c8d715963d99db3"

session_reference_id
string

A reference for a group of metering records, for example, a charging session ID.

Example:

"SESSION1234567890"

energy_flow_direction
string

Energy flow direction. Set to INBOUND or OUTBOUND. Defaults to INBOUND.

Example:

"INBOUND"

tariff_direction
string

Tariff direction. Set to IMPORT, EXPORT or LOCAL. Defaults to match the direction parameter.

Example:

"IMPORT"

Response

id
string

Flatpeak ID for this submission.

Example:

"bat_65e42b7827c0526548432b9f"

object
string

Object name, i.e. meter_batch.

Example:

"meter_batch"

records_submitted
integer

Number of received metering records.

Example:

18379

records_accepted
integer

Number of accepted metering records.

Example:

18378

records_processed
integer

Number of processed metering records.

Example:

32

failed_records
FailedMeterRecord · object[]

Returns details of any meter records that failed processing

time_created
string<date-time>

Time when this object was created. In UTC.

Example:

"2023-11-07T05:31:56Z"

account_id
string

Flatpeak account ID.

Example:

"acc_661677911f2197045e6cf1b1"