> ## Documentation Index
> Fetch the complete documentation index at: https://developer.energy-hub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect and Link Sequence

### Steps

<Steps>
  <Step title="Show available vendors to user">
    To inform your user which energy brands or manufacturers are currently supported, the endpoint [All available vendors](/api-reference/connection-controller/all-available-vendors) helps you prepare the vendor selection screen. You can use this list as the basis for offering users a choice of which vendors to connect to.
  </Step>

  <Step title="Create connect session and redirect user">
    The connect session is initiated by redirecting your user to the URL provided by calling, for example, [Connect session for vehicle](/api-reference/connection-controller/connect-url-for-a-vehicle-vendor) (the specific endpoint depends on the device type you want to connect). The user will be redirected to the vendor's official identity provider (IDP) and will connect their vendor account to the Energy Hub Alliance.

    When the connection is successful, the redirect will include the `vendorAccountId` as a parameter in the redirect URL. This `vendorAccountId` is required for the following steps to link the devices associated with the vendor account.

    <Warning>
      The connect session only connects the user's vendor account. To link the devices from that vendor account, continue with the next two steps.
    </Warning>
  </Step>

  <Step title="Let user pick which devices to connect">
    A connected vendor account can include several energy devices. To retrieve a list of devices connected to the vendor account, use, for example, [List vehicles from vendor](/api-reference/vendor-account-vehicles-link-controller/list-vehicles-from-vendor) (the specific endpoint depends on the device type you want to connect).
  </Step>

  <Step title="Link devices to the Energy Hub Alliance">
    As a final step, once the user or application has decided which devices should be added, [Link vehicles](/api-reference/vendor-account-vehicles-link-controller/link-vehicles) links the selected devices to the platform. All set! The items are now linked to the Energy Hub Alliance and can be accessed through the API. Data streaming should also begin for the linked devices.
  </Step>
</Steps>

### Sequence Diagram (simplified)

```mermaid theme={null}
sequenceDiagram
autonumber
actor User
participant A as Application
participant EHA as Energy Hub Alliance
participant V as Vendor IDP
    A->>EHA: Get available vendors
    User->>A: Pick vendor to connect
    A->>EHA: Create connect session for vendor
    User->>V: Direct to connect URL
    Note right of V: User login and consent
    EHA->>A: Redirect with vendor account ID
    A->>EHA: Get energy devices from vendor account
    User->>A: Selects energy devices to link
    A->>EHA: Link devices to Energy Hub Alliance
```
