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

# Connect Standard Integration (Widget + API)

> Walk through the standard Flinks integration end to end: launch Flinks Connect on the front end, then authorize and retrieve account data through API requests on the back end.

The **standard integration** is the most common way to connect with Flinks. It pairs the [Flinks Connect](https://docs.flinks.com/guides/connect/flinks-connect/flinks-connect.md) iframe on the front end with **API requests** on the back end. This page walks through the full happy-path flow, from launching the iframe to retrieving account data.

## Front end vs. back end

Every Flinks integration has two independent halves. You choose one option for each.

* **Front end:** what the end user interacts with to connect their account, either the [Flinks Connect](https://docs.flinks.com/guides/connect/flinks-connect/flinks-connect.md) iframe or [Flinks Express](https://docs.flinks.com/guides/connect/flinks-express.md). See [Choose a Front-End Solution](https://docs.flinks.com/guides/connect/choose-a-frontend-solution.md).
* **Back end:** how your system receives the connected data, either API requests or Webhooks. See [Choose a Back-End Solution](https://docs.flinks.com/guides/connect/choose-a-backend-solution.md).

The [Dashboard](https://docs.flinks.com/guides/connect/getting-started.md) is a self-serve UI that calls the back end on your behalf, not a separate back-end option.

> [!NOTE]
>
> This page describes the standard integration: **Flinks Connect** on the front end plus **API requests** on the back end. If you want data pushed to you automatically instead of polling, see [Choosing your back end](#choosing-your-back-end) below.

## Prerequisites

Before you begin, make sure you have the following credentials and values. You can find these in your [Flinks Dashboard](https://docs.flinks.com/guides/connect/getting-started.md) or from your Flinks representative.

| Value | Purpose |
| :- | :- |
| **Customer ID** (`customerId`) | Identifies your account. Used in every API URL path. |
| **Instance name** | Your regionally-scoped instance (for example, sandbox vs. production). Determines your base URLs. See [Instances](https://docs.flinks.com/guides/getting-started/instances.md). |
| **Secret key** | The unique key Flinks provides during integration. Passed in the `flinks-auth-key` header of `/GenerateAuthorizeToken` to create authorize tokens. |
| **Authorize token** | A single-use token generated from your secret key. Passed to Flinks Connect (URL parameter) or to `/Authorize` (`flinks-auth-key` header). |
| **iframe base URL** | The Flinks Connect endpoint you launch, in the form `https://yourinstance-iframe.private.fin.ag/`. |

> [!WARNING]
>
> The **secret key** and the **authorize token** are not the same. Use the secret key only to generate authorize tokens; use the authorize token to authenticate Flinks Connect or `/Authorize`. See [Set Up Authorization](https://docs.flinks.com/guides/connect/setup-authorization.md).

## End-to-end flow

The diagram below shows the standard integration happy path.

```mermaid theme={null}
sequenceDiagram
    participant App as Your App / Back end
    participant User as End User
    participant Connect as Connect Widget
    participant API as Connect API

    App->>API: /GenerateAuthorizeToken (token #1)
    API-->>App: authorize token
    App->>Connect: Launch iframe with authorize token
    User->>Connect: Select FI, enter credentials, complete MFA
    Connect-->>App: loginId (and optional accountId)
    App->>API: /GenerateAuthorizeToken (fresh token #2)
    API-->>App: authorize token
    App->>API: /Authorize (loginId, MostRecentCached: true)
    API-->>App: 200 + requestId
    App->>API: /GetAccountsDetail (requestId)
    alt 202: operation pending
        API-->>App: 202 (processing)
        loop Poll every ~10 seconds
            App->>API: /GetAccountsDetailAsync (requestId)
            API-->>App: 202 (still processing)
        end
        API-->>App: 200 (account data)
    else 200: data ready
        API-->>App: account data
    end
```

## Step-by-step

**1. Generate an authorize token to launch the iframe**

Call [`/GenerateAuthorizeToken`](../../api/authorize/endpoints/generate-authorize-token) with your **secret key** in the `flinks-auth-key` header.

* **Input:** secret key (header)
* **Output:** an authorize token that is single-use and active for 15 minutes.

Pass this token to Flinks Connect using the `authorizeToken` URL parameter:

```url URL theme={null}
https://yourinstance-iframe.private.fin.ag/?redirectUrl=flinks.com&authorizeToken=d65f1adb-8ebc-48dc-be8b-20c773ba1565
```

**2. The end user completes Flinks Connect**

The end user selects their financial institution, enters their credentials, and completes multi-factor authentication (MFA) if their bank requires it. Flinks Connect handles all bank processes, edge cases, and errors on your behalf.

When the connection succeeds, capture the `loginId` (and optionally an `accountId`) from the Flinks Connect [event listener](https://docs.flinks.com/guides/connect/flinks-connect/use-event-listener.md) or the [redirect URL](./next-steps#save-your-loginids).

* **Output:** `loginId`, a permanent token representing the saved connection. Store it securely on your servers; never expose it publicly.

> [!NOTE]
>
> The `loginId` does not expire and is required for all future data retrieval. See [Key Concepts](https://docs.flinks.com/guides/getting-started/key-concepts.md#loginid).

**3. Generate a fresh authorize token**

The token you generated in step 1 was consumed when you launched Flinks Connect. Authorize tokens are **single-use**, so call [`/GenerateAuthorizeToken`](../../api/authorize/endpoints/generate-authorize-token) again to create a **new** token before calling `/Authorize`.

* **Input:** secret key (header)
* **Output:** a fresh authorize token.

> [!TIP]
>
> Generate a fresh authorize token continuously across the session, any time you are about to make a call that requires one. Reusing a consumed token will fail authentication.

**4. Call /Authorize in cached mode**

Call [`/Authorize`](../../api/authorize/endpoints/authorize) with the `loginId`, passing the fresh authorize token in the `flinks-auth-key` header. Use cached mode (`MostRecentCached: true`) to open a session against the data that was just collected.

```bash Authorize theme={null}
curl --request POST \
  --url https://yourinstance-api.private.fin.ag/v3/{customerId}/BankingServices/Authorize \
  --header 'Content-Type: application/json' \
  --header 'flinks-auth-key: {authorize_token}' \
  --data '{
    "LoginId": "your-login-id",
    "MostRecentCached": true
  }'
```

In cached mode the response is `200`, because the end user already completed any required authentication in the iframe.

* **`200`:** Authenticated. Use the returned `RequestId` to retrieve data (next step).
* **Output:** a `RequestId`, a session token used to call the data endpoints. It cannot be reused.

**5. Retrieve account data**

Send a `POST` request to [`/GetAccountsDetail`](../../api/connect/endpoints/account-linking/get-accounts-detail) with the `RequestId` in the body. (Use [`/GetAccountsSummary`](../../api/connect/endpoints/account-linking/get-accounts-detail) if you only need summary-level data.)

Handle the response by status:

* **`200`:** Data is ready. The response contains the full account payload.
* **`202`:** The operation is still processing. Poll for the result (next step). A `202` is expected on the initial call.

**6. Poll on 202 until data is ready**

When `/GetAccountsDetail` returns `202`:

1. Call [`/GetAccountsDetailAsync`](../../api/connect/endpoints/account-linking/get-accounts-detail-async) with the same `RequestId` as a path parameter (this is a `GET` request).
2. If the response is `202`, the data is still processing. **Wait \~10 seconds**, then poll again.
3. Repeat until you receive a `200`, which contains the same payload as a `200` from `/GetAccountsDetail`.
4. Set a maximum timeout of 30 minutes to avoid an infinite polling loop.

> [!NOTE]
>
> `/GetAccountsDetailAsync` is not a separate data endpoint. It is the polling mechanism for `/GetAccountsDetail`. See [Retrieve Account Data](https://docs.flinks.com/guides/connect/retrieve-account-data.md#poll-getaccountsdetailasync-on-202).

**7. (Optional) Enrich the data with Attributes**

If your use case needs enriched insights, call the Attributes / Enrich endpoint on demand with the `RequestId`.

> [!NOTE]
>
> Attributes are fetched **on demand** by making an API request. They are not returned automatically with account data and are not delivered by webhook.

## Choosing your back end

This page uses **API requests with polling** on the back end. If you would rather have data pushed to you automatically when processing completes, without writing polling logic, set up [Webhooks](https://docs.flinks.com/guides/webhooks/introduction.md) instead.

For a side-by-side comparison of API requests vs. Webhooks, see [Choose a Back-End Solution](https://docs.flinks.com/guides/connect/choose-a-backend-solution.md).

## Next steps

> [card] [Set Up Authorization](https://docs.flinks.com/guides/connect/setup-authorization.md)
>
> Generate and pass authorize tokens correctly.

> [card] [Retrieve Account Data](https://docs.flinks.com/guides/connect/retrieve-account-data.md)
>
> Full detail on the data retrieval and polling flow.

> [card] [Handled Errors](https://docs.flinks.com/guides/connect/flinks-connect/handled-errors.md)
>
> Understand how Flinks reports and handles errors.

> [card] [Resume and Reconnect](https://docs.flinks.com/guides/connect/resume-and-reconnect.md)
>
> Re-establish a connection for a returning user.

> [card] [Webhooks](https://docs.flinks.com/guides/webhooks/introduction.md)
>
> Receive data automatically instead of polling.
