# Run Flows Configured Online

Use this pattern when your Flow or Workflow is configured online in the Incode Dashboard rather than in your app code. The SDK fetches the configuration from the Dashboard at runtime using a `configurationId`, so you can update the flow's modules and behavior without redeploying your app.

## When to use this pattern

Use this pattern when:

- Your Flow or Workflow is configured in the Incode Dashboard.
- You want to update flow behavior without app redeployment.
- You want to resume an existing session by `interviewId`, or start a Flow from a specific module.

For flows configured in app code, see [Configure Flows Locally and Run End to End](./flutter-configure-flows-locally-and-run-end-to-end) or [Configure Flows Locally and Run Step by Step](./flutter-configure-flows-locally-and-run-step-by-step).

## Workflows vs. Flows

Incode supports two distinct Dashboard artifacts:

- **Flows**: Simple and straightforward user journeys. Start a Flow with `startFlow()`.
- **Workflows**: Highly customizable user journeys, where the results of a module can alter what the user is presented with next. Start a Workflow with `startWorkflow()`.

The two methods are similar in shape but are not interchangeable. Use the method that matches the artifact configured in the Dashboard.

## Prerequisites

- The SDK is initialized. See [Installation](./flutter-installation).
- A `configurationId` from the Incode Dashboard for the Flow or Workflow you want to run.

## Start a Flow

Call `startFlow()` with an `OnboardingSessionConfiguration` that includes the `configurationId`. Optionally provide an `interviewId` to resume an existing session, and a `moduleId` to start from a specific module within the flow.

```dart
OnboardingSessionConfiguration sessionConfig = OnboardingSessionConfiguration(
  configurationId: "YOUR_CONFIGURATION_ID",
  interviewId: "YOUR_INTERVIEW_ID", // optional
);

IncodeOnboardingSdk.startFlow(
  sessionConfig: sessionConfig,
  moduleId: 'YOUR_MODULE_ID', // optional, e.g., "PHONE"
  onError: (String error) {
    print('Incode startFlow error: $error');
  },
  onSuccess: () {
    print('Incode startFlow completed!');
  },
  onUserCancelled: () {
    print('User cancelled');
  },
);
```

### Start Flow parameters

- `sessionConfig`: Required. An `OnboardingSessionConfiguration` containing at minimum the `configurationId`. See [Configure the onboarding session](./flutter-configure-flows-locally-and-run-end-to-end#1-configure-the-onboarding-session) on the end-to-end pattern page for the full list of session parameters.
- `moduleId`: Optional String. Starts the Flow from a specific module. Useful when resuming a partially completed session. See [Modules](./flutter-modules) for the list of valid module IDs.
- `onSuccess`: Called when the Flow completes successfully.
- `onError`: Called when an error stops the Flow.
- `onUserCancelled`: Called when the user cancels the Flow.

You can also add optional per-module listener callbacks (for example, `onIdFrontCompleted`, `onSelfieScanCompleted`) to `startFlow`, the same way you can on `startOnboarding`. See [`startOnboarding`](./flutter-api-reference#startonboarding) on the API Reference page for the full callback inventory.

## Start a Workflow

Call `startWorkflow()` with an `OnboardingSessionConfiguration` that includes the `configurationId` of a Workflow configured in Dashboard.

`startWorkflow()` has the same signature as `startFlow()`, without the `moduleId` parameter. For the full signature and parameter list, see [`startWorkflow`](./flutter-api-reference#startworkflow) on the API Reference page.

```dart
OnboardingSessionConfiguration sessionConfig = OnboardingSessionConfiguration(
  configurationId: "YOUR_CONFIGURATION_ID",
);

IncodeOnboardingSdk.startWorkflow(
  sessionConfig: sessionConfig,
  onError: (String error) {
    print('Incode startWorkflow error: $error');
  },
  onSuccess: () {
    print('Incode startWorkflow completed!');
  },
  onUserCancelled: () {
    print('User cancelled');
  },
);
```

You can also add optional per-module listener callbacks (for example, `onIdFrontCompleted`, `onSelfieScanCompleted`) to `startWorkflow`, the same way you can on `startOnboarding`. See [`startOnboarding`](./flutter-api-reference#startonboarding) on the API Reference page for the full callback inventory.
