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

# Quickstart

> Create a user, location and device, connect a tariff through Connect, and read prices.

This guide takes you from an API key to the prices for one device. The examples use curl.

### 1. Authenticate

Copy your **Account ID** and **secret key** from [Console](https://console.flatpeak.com/keys/api) > **API Keys**. Use a Live mode key. If you have no account, [create one](https://flatpeak.com/signup), then [contact support](https://console.flatpeak.com/support) to activate your trial.

Base64 encode `account_id:secret_key` and [create a token](/docs/energy-api/reference/auth/tokens.md). The token lasts one hour.

```bash Request example theme={"system"}
curl --request POST \
  --url https://energy-api.flatpeak.com/auth/tokens \
  --header 'Authorization: Basic <base64 encoded account_id:secret_key>'
```

```json Response example theme={"system"}
{
  "bearer_token": "eyJhbGciOiJIUzI1NiIsInR5cC",
  "expires_in": 3600,
  "live_mode": true
}
```

### 2. Create a user, location and device

[Create a user](/docs/energy-api/reference/users/create.md).

```bash Request example theme={"system"}
curl --request POST \
  --url https://energy-api.flatpeak.com/users \
  --header 'Authorization: Bearer <bearer_token>' \
  --header 'Content-Type: application/json'
```

```json Response example theme={"system"}
{
  "id": "usr_65e421d1daa4a24082b4f590",
  "object": "user"
}
```

[Create a location](/docs/energy-api/reference/locations/create.md) with the `user_id`.

```bash Request example highlight={6} theme={"system"}
curl --request POST \
  --url https://energy-api.flatpeak.com/locations \
  --header 'Authorization: Bearer <bearer_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "user_id": "usr_65e421d1daa4a24082b4f590"
}'
```

```json Response example theme={"system"}
{
  "id": "loc_641b90b758fb8e6293716e40",
  "object": "location"
}
```

[Create a device](/docs/energy-api/reference/devices/create.md) with the `location_id` and a `device_type`: `BATTERY_STORAGE`, `ELECTRIC_VEHICLE`, `EV_CHARGER`, `AIR_CONDITIONER`, `HEAT_PUMP`, `WATER_HEATER`, `PV_SYSTEM`, `POWER_GENERATOR` or `OTHER`.

```bash Request example highlight={6,7} theme={"system"}
curl --request POST \
  --url https://energy-api.flatpeak.com/devices \
  --header 'Authorization: Bearer <bearer_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "location_id": "loc_641b90b758fb8e6293716e40",
  "device_type": "BATTERY_STORAGE"
}'
```

```json Response example theme={"system"}
{
  "id": "dev_9c1f70a4e2b6485db3f0c8a1",
  "object": "device",
  "device_type": "BATTERY_STORAGE",
  "location_id": "loc_641b90b758fb8e6293716e40"
}
```

### 3. Create a Connect session

A Connect session is a single-use key that launches Connect without exposing your secret key. [Create a Connect session](/docs/energy-api/reference/connect-sessions/create.md) with:

| Field | Value |
| :- | :- |
| `device_id` | The device from the previous step |
| `connect_url` | Where Connect is hosted. Use `https://busbar.connect-web.flatpeak.com` |
| `callback_url` | Where the user lands after Connect. Use `myapp://flatpeak/complete` |

```bash Request example theme={"system"}
curl --request POST \
  --url https://energy-api.flatpeak.com/connect-sessions \
  --header 'Authorization: Bearer <bearer_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "device_id": "dev_9c1f70a4e2b6485db3f0c8a1",
  "connect_url": "https://busbar.connect-web.flatpeak.com",
  "callback_url": "myapp://flatpeak/complete"
}'
```

```json Response example theme={"system"}
{
  "id": "cos_6587fa4362341be5b524de3b",
  "object": "connect_session",
  "live_mode": true,
  "time_created": "2026-06-15T09:00:00Z",
  "time_expiry": "2026-06-17T09:00:00Z"
}
```

### 4. Launch the Connect web app in Tariff mode

Open the hosted Connect web app with the session `id` and `flow=TARIFF`:

```http theme={"system"}
https://busbar.connect-web.flatpeak.com/?connect_session=cos_6587fa4362341be5b524de3b&flow=TARIFF
```

The user picks their supplier, signs in, grants access to their tariff and returns to your app. A session expires after 48 hours and launches Connect once, so create a new one for every launch.

![Flatpeak Connect flow](https://mintcdn.com/flatpeak-d495c19e/2B6nWUU4-c2pSD3E/images/busbar/connect-tariff-flow.png?fit=max\&auto=format\&n=2B6nWUU4-c2pSD3E\&q=85\&s=d7cc98ef68a872d3f394b95c0ce71ec0)

Connect in Tariff mode

Use your own account with a [supported supplier](https://flatpeak.com/coverage). To test the supplier login, pick one with a **Direct** connection, or switch to a test mode key and use the test supplier [Antarctic Energy](/docs/energy-api/guides/platform/test-supplier.md).

### 5. Get prices

[Retrieve the device price](/docs/energy-api/reference/prices/retrieve-device.md).

```bash Request example theme={"system"}
curl --request GET \
  --url 'https://energy-api.flatpeak.com/devices/dev_9c1f70a4e2b6485db3f0c8a1/prices?start_time=2026-06-15T09:00:00Z&end_time=2026-06-15T23:00:00Z' \
  --header 'Authorization: Bearer <bearer_token>'
```

```json Response example theme={"system"}
{
  "object": "price",
  "device_id": "dev_9c1f70a4e2b6485db3f0c8a1",
  "timezone": "Europe/London",
  "currency_code": "GBP",
  "data": {
    "import": [
      {
        "start_time": "2026-06-15T09:00:00Z",
        "end_time": "2026-06-15T11:00:00Z",
        "price": {
          "value": 0.14998,
          "confidence": 1
        }
      },
      {
        "start_time": "2026-06-15T11:00:00Z",
        "end_time": "2026-06-15T23:00:00Z",
        "price": {
          "value": 0.23072,
          "confidence": 0.8
        }
      }
    ],
    "export": []
  }
}
```

## Next steps

* [Connect](/docs/energy-api/guides/tariffs/connect.md): put the flow in your app.
* [Prices and costs](/docs/energy-api/guides/tariffs/prices.md): prices, costs and price updates.
* [Optimizations](/docs/energy-api/guides/tariffs/optimizations.md): the best times to run a device.
* [VPP quickstart](/docs/energy-api/guides/vpp/quickstart.md): enroll the device in a program.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.