Skip to main content
POST
Optimize by time duration

Authorizations

Authorization
string
header
required

Bearer token obtained from POST /auth/tokens.

Path Parameters

device_id
string
required

Flatpeak Device ID.

Example:

"dev_63a6087272941ef077a8fd3e"

Body

application/json
start_time
string<date-time>
required

RFC 3339 timestamp marking the start of the data window, for example 2026-06-15T09:00:00Z or 2026-06-15T08:00:00+01:00. Use either UTC or a time offset. If offsets differ, end_time takes precedence.

Example:

"2026-06-15T09:00:00Z"

end_time
string<date-time>
required

RFC 3339 end of the window, for example 2026-06-15T13:00:00Z. At most 3 days after start_time.

Example:

"2026-06-16T09:00:00Z"

rank_by
enum<string>
default:PRICE

What ranks the intervals: PRICE (default) uses the tariff, SOLAR uses the generation forecast and returns the intervals with the most generation adding up to the duration. SOLAR requires forecasts on the device or its location.

Available options:
PRICE,
SOLAR
Example:

"PRICE"

import
object

Import optimization request.

export
object

Export optimization request.

Response

Optimization by duration response.

id
string
required

Flatpeak Optimization ID.

Example:

"opt_65e42cdd73e9f861edda35d7"

object
enum<string>
required

Object type.

Available options:
optimization_duration
Example:

"optimization_duration"

live_mode
boolean
required

true for live data, false for test data.

device_id
string
required

Flatpeak Device ID.

Example:

"dev_63a6087272941ef077a8fd3e"

location_id
string
required

Flatpeak Location ID.

Example:

"loc_65e42ce4d3b813479b252160"

timezone
string
required

Timezone at the location, tz database name such as Europe/Berlin.

Example:

"Europe/London"

currency_code
string
required

Currency at the location in ISO 4217.

Pattern: ^[A-Z]{3}$
Example:

"EUR"

data
PriceWindow · object[]
required

The price windows of the optimization, in time order.

account_id
string
required

Flatpeak Account ID.

Pattern: ^[a-z]{2,4}_[A-Za-z0-9]+$
Example:

"acc_661677911f2197045e6cf1b1"

time_created
string<date-time>
required

Time when this response was calculated. In UTC.

Example:

"2026-05-23T15:14:22Z"