> ## 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.

# Nightly Refreshes

> If you would like automatic account refreshes, read the following sections to enable Nightly Refreshes.

> [!WARNING]
>
> Nightly Refresh success depends on the institution's Multi-Factor Authentication (MFA)
>
> While Nightly Refresh is supported, the actual response depends on the financial institution, not on Flinks.
>
> A nightly refresh runs without the end user present. That only works when the institution allows an unattended reconnection. When the institution requires a one-time password, a push notification approval, or another challenge that only the end user can answer, the refresh cannot be completed. Most Canadian institutions now apply MFA on every login, so a significant share of connections will not refresh on their own. OAuth-connected institutions are the exception and refresh reliably.
>
> **What this means for your integration:**
>
> * Treat Nightly Refresh as a way to keep part of your account base current, not all of it. Plan for partial coverage.
> * Check the age of the data before you act on it. Do not assume a connection refreshed last night
> * For a guaranteed refresh, the end user must be present and complete a live connection through Flinks Connect. You can implement a "Refresh" button in your application that triggers a live [/Authorize](https://docs.flinks.com/api/authorize/endpoints/authorize.md) call with`MostRecentCached: false`. The user must complete the MFA step if prompted.
> * [Reconnect](https://docs.flinks.com/guides/connect/resume-and-reconnect.md) reduces friction when an end user does need to reconnect. Do not rely on automatic nightly refresh for your use case.
>
> Talk to your Flinks Representative about which institutions your customer base connects to. That mix is the best predictor of the refresh rate you will see.

## Eligibility Criteria

A card must comply with certain eligibility criteria before being refreshed. For a card to be refreshed, it must satisfy the following conditions:

* The Schedule Refresh parameter must be set to true. You can enable it in two ways:
  * **Flinks Connect iframe**: Add `scheduleRefresh=true` to your iframe URL parameters
  * **API**: Call the [/SetScheduledRefresh](https://docs.flinks.com/api/connect/endpoints/account-linking/set-scheduled-refresh.md) endpoint to enable or disable nightly refresh for specific accounts
* The card must have had a successful refresh in the last seven days.
* (Not applicable for Webhooks integrations) The card must have received a cached call in the past seven days.
* The card should not have any errors during Authorization. However, if an error has occurred, the card will still be eligible for refresh if the error is one of the following:
  * `RETRY_LATER`
  * `AGGREGATION_ERROR`
  * `SESSION_EXPIRED`
  * `DISABLED_INSTITUTION`
  * `UNAUTHORIZED`
  * `SESSION_NONEXISTENT`
  * `BANK MAINTENANCE_RETRY_LATER`

> [!NOTE]
>
> Security questions are not always prompted during Nightly Refresh. If MFA answers have been stored using the [/AnswerMFAQuestions](https://docs.flinks.com/api/connect/endpoints/account-linking/answer-mfa-questions.md) endpoint and Enhanced MFA is enabled, Flinks can answer them automatically, minimizing MFA interruptions during nightly refreshes.

## Enabling Nightly Refreshes

You can enable automatic account refreshes using Nightly Refresh and Enhanced MFA.

### Nightly Refresh

If your use case requires automatic account refresh to keep track of transactional history changes, you can enable `Nightly Refresh` for new accounts. For this, you need to set the scheduleRefresh parameter to true in the iframe URL.

### Enhanced MFA (Deprecated)

> [!WARNING]
>
> Enhanced MFA is no longer supported
>
> Enhanced MFA is no longer an actively supported feature. Most Canadian financial institutions have moved to one-time passwords and push notifications for MFA, which cannot be answered automatically. The `enhancedMFA` and `skipEnhancedMFA` iframe parameters should not be used in new integrations.
>
> For refreshing account data, implement a user-initiated reconnection flow instead. See the [Reconnect](https://docs.flinks.com/guides/connect/resume-and-reconnect.md) guide for recommended approaches.

## Useful Endpoints

[/GetNightlyRefreshStatus](https://docs.flinks.com/api/connect/endpoints/account-linking/get-nightly-refresh-status.md): This endpoint returns a list with all of the `loginIds` that are set to Nightly Refresh (`"isScheduledRefresh"=true`), yet are no longer refreshing due to errors. The endpoint's JSON response will clarify what error was encountered on the refresh attempt.

[/Authorize](https://docs.flinks.com/api/authorize/endpoints/authorize.md): This endpoint will also return the error message from the previous refresh attempt when running the batched cached calls. In cases where the JSON response doesn't return any errors, please make sure you check the date of the latest refresh. An example can be seen in the image below:

If the date of your last refresh is too long ago for your use case, perform a manual refresh: call [/Authorize](https://docs.flinks.com/api/authorize/endpoints/authorize.md) with `MostRecentCached: false` and `Save: true`, then call the aggregation endpoints with the returned `requestId`. See [Reconnect](https://docs.flinks.com/guides/connect/resume-and-reconnect.md) for the full refresh and MFA-during-refresh flow.

## Suggested daily routine

Complete the following steps in our suggested daily routine for refreshes:

### Step 1: Check which loginIds are no longer eligible

Call the `/GetNightlyRefreshStatus` endpoint to identify accounts that are set to refresh but no longer meet the eligibility criteria:

```mermaid theme={null}
flowchart LR
    A["/GetNightlyRefreshStatus"] -->|For each LoginId<br/>present on the list| B["Flinks Connect<br/><small>User needs to reconnect</small>"]
    
    style A fill:#4FC3F7,stroke:#333,stroke-width:2px
    style B fill:#B0C4DE,stroke:#333,stroke-width:2px
```

### Step 2: Handle loginIds not on the list

If any `loginIds` are not on the list, follow this flowchart to manually refresh them:

```mermaid theme={null}
flowchart TB
    A["/Authorize<br/>MostRecentCached=true<br/>Save=true"] --> B{200?}
    
    B -->|Yes| D["GetAccountsDetail"]
    B -->|No| C{"Error is RETRY_LATER,<br/>AGGREGATION_ERROR, SESSION_EXPIRED,<br/>DISABLED_INSTITUTION, UNAUTHORIZED,<br/>SESSION_NONEXISTENT, or<br/>BANK_MAINTENANCE_RETRY_LATER?"}
    
    C -->|Yes| F["/Authorize<br/>MostRecentCached=false<br/>Save=true"]
    C -->|No| E1["Flinks Connect<br/>User needs to reconnect"]

    F --> F1{Response?}
    F1 -->|200| D
    F1 -->|203 MFA| MFA["Flinks Connect<br/>with requestId + authorizeToken<br/>User answers MFA"]
    MFA --> D
    
    D --> G{200?}
    D --> H{"202<br/>OPERATION PENDING?"}
    
    G -->|Yes| I["Attributes endpoints"]
    G -->|No| E2["Flinks Connect<br/>User needs to reconnect"]
    
    H -->|Yes| J["GetAccountsDetailAsync"]
    
    J --> K{"202<br/>OPERATION PENDING?"}
    K -->|"Yes, wait 10 seconds"| J
    K -->|No| I2["Attributes endpoints"]

    style A fill:#4FC3F7,stroke:#333
    style D fill:#4FC3F7,stroke:#333
    style F fill:#4FC3F7,stroke:#333
    style J fill:#40E0D0,stroke:#333
    style I fill:#40E0D0,stroke:#333
    style I2 fill:#40E0D0,stroke:#333
    style E1 fill:#B0C4DE,stroke:#333
    style E2 fill:#B0C4DE,stroke:#333
    style MFA fill:#B0C4DE,stroke:#333
```

## Nightly Refresh routine

The Nightly Refresh job has a daily routine. The job is scheduled to run from 4 a.m. to 8 a.m. (UTC). It will only impact all cards that meet the Eligibility Criteria.

## Coverage

For more information about which financial institutions we support Nightly Refreshes for, contact your Flinks Representative.
