Native API implementation
The Connect API methods differ from the rest of the FlatPeak API. They use a single endpoint that functions like a chatbot, exchanging a predefined set of JSON-formatted questions and responses. Review the Connect Section in API reference.
Here’s how it works:
Initiating the Session
Your customer begins by clicking a “Connect My Tariff” button (or similarly named control) in your app.
Your app should then:
- Call the create-connect-token endpoint to generate a
connect_token
. - Use the token to start a new session by calling the session_restore API route.
Receiving Page Objects
Once the session starts, your app will receive one of fifteen possible Connect “Page Objects”. Each object contains all the necessary information to render a page that guides the customer through the next step in tariff discovery process.
Handling Customer Actions
For each page:
- Your app captures the user’s input.
- Submits the response to the Connect endpoint.
- Receives the next Page Object to render the next step.
Connect dynamically determines the next page based on the customer’s previous responses and returns a corresponding page object. This process continues until Connect determines the session is complete.
Completing the Session
Once the customer’s tariff is successfully connected:
- Connect returns a special session_complete object.
- A webhook is triggered to notify your backend systems that:
- The session is complete
- You can now exchange the
connect_token
for a permanentlocation_id
that represents a property address.
Subscribe to tariff lifecycle webhooks
After your customer completes the Connect flow, FlatPeak will automatically keep their tariff information up to date. If any action is required from the customer, FlatPeak will generate an event. You should subscribe to these events via webhooks and implement a communication flow to notify your customers and guide them through the necessary steps (below).
Let customers view their tariff and change connection
Customers may wish to modify their tariff settings from time to time or when you notify them of a detected change (webhook). To support these scenarios, follow the Building a tariff settings page in your app guide to add controls that let them update or reconnect their energy account.
Next steps
You can now query the FlatPeak API for your customer’s tariff data and access all other energy intelligence endpoints.
Choose from two different integration paths for this step: