Skip to main content

Overview

If you already have customer addresses but tariff data is missing, you can automatically assign market tariffs without manual customer action. This lets your customers immediately benefit from energy price data in your system, while still encouraging them to connect their actual tariff later via Connect for better price accuracy.

Implementation

1

Create a Customer (optional)

If your systems maintain a separate reference for customers (i.e., users), independent of their address, you can create a Customer object in Flatpeak to keep your object model aligned. Call the customer-create endpoint and pass your internal customer reference as reference_id.The response will return a Flatpeak Customer ID, which you should store and associate with the customer in your systems.
curl --request POST \
  --url https://api.flatpeak.com/customers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "reference_id": "CUS1234567890"
}'
2

Create a Location

Before creating tariffs, you must first create a Location using the location-create endpoint. Pass your internal location reference as reference_id. The response will return a Flatpeak Location ID, which you must permanently store and associate with the device location in your system.At minimum, you must pass postal_address.city and postal_address.country_code. If the device is located in the US, you must also include postal_address.state. These fields enable Flatpeak to determine the correct timezone, currency, and market rates for the specified location.
If you created a Customer Object in the optional step above, you must include it in this Location Create request using the customer_id field.
curl --request POST \
  --url https://api.flatpeak.com/locations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "reference_id": "LOC1234567890",
  "customer_id": "cus_65e421d1daa4a24082b4f590",
  "postal_address": {
    "address_line1": "1-3 Strand",
    "city": "London",
    "state": "Greater London",
    "post_code": "WC2N 5EH",
    "country_code": "GB"
  }
}'
3

Create a Tariff

Once you have a Location ID, you can create a Tariff by calling create-tariff endpoint.
Object/ParameterDescription
location_idFlatpeak Location ID you created earlier
directionIMPORT
typeCOMMODITY
market_ratesSet to true (important)
curl --request POST \
  --url https://api.flatpeak.com/tariffs \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "location_id": "loc_641b90b758fb8e6293716e40",
  "direction": "IMPORT",
  "type": "COMMODITY",
  "market_rates": true
}'
The presence of the market_rate_source_id value in the response indicates that Flatpeak has successfully assigned the correct market tariff.You can verify this by calling the retrieve-price endpoint with the Location ID.