Context
Flatpeak may redirect customers to your application using theuniversal_link_url configured in the Flatpeak Dashboard.
This typically occurs when a customer uses their energy provider’s app to grant access to device telemetry and control in exchange for a device specific tariff, or to enrol in a VPP programme.
Universal Link Structure
The universal link contains aconnect_session parameter that identifies the Connect Session.
Your application should use this value to retrieve and validate the Connect Session, verify the customer’s authentication state, and ensure the customer is authorised before displaying protected information.
Example universal link
When universal_link_url is configured as:
Handling Universal Links
When a customer opens the universal link:- If your mobile application is installed and configured for Universal Links (iOS) or App Links (Android), open the application.
- Otherwise, open the link in the customer’s web browser.
- Extract the
connect_sessionparameter from the URL. - Retrieve the Connect Session.
- Verify session is valid and not expired.
iOS Configuration
To support Universal Links on iOS:- Add the Associated Domains capability to your application.
- Configure the domain used by
universal_link_url. - Host an apple-app-site-association file on the domain.
- Configure your application to handle incoming Universal Links.
Android Configuration
To support App Links on Android:- Configure an intent filter for the domain used by
universal_link_url. - Host an assetlinks.json file on the domain.
- Verify domain ownership.
- Configure your application to handle incoming App Links.
Best Practices
- Use HTTPS for all universal links.
- Allow customers to continue in a browser if the application is not installed.
- Always validate the Connect Session before displaying protected information.
- Treat
connect_sessionas a temporary identifier and avoid persisting it unnecessarily. - Handle expired or invalid sessions gracefully and provide clear guidance to the customer.
Security
Universal Links are a navigation mechanism only. They must never be used as proof of authentication or authorisation. When a customer accesses protected content:- Receive the universal link.
- Retrieve and validate the Connect Session.
- Verify the customer is authenticated.
- Prompt the customer to sign in if required.
- Display the appropriate content.
Device Selection and Connect Flow
After validating the Connect Session, determine which device the customer intends to connect. If the Connect Session already contains a device_id:- Retrieve the device.
- Start the Connect Session.
- Prompt the customer to select a device.
- Check whether the device is already registered with Flatpeak.
- If not, create the device and store the returned device_id in your database. If your implementation supports multiple locations per device, you may also need to create a Location.
- Update the Connect Session with the selected device_id and location_id.
- Start the Connect Session with flow set to AUTO.
Connect Session Completion
When the customer completes the Connect flow, your application receives a connect_session.complete webhook event. Use this event to update your records and enable the services authorised by the customer.- Retrieve the associated device and location.
- Review the consent information returned by Flatpeak.
- Determine whether the customer granted consent for telemetry sharing and operating schedule delivery.
- Update your records to reflect the customer’s consent choices.
- Start sending telemetry if consent was granted.
- Start retrieving and applying operating schedules if consent was granted.

