# Configure Flows Locally and Run End to End

This pattern uses `startOnboarding()` to run a locally-defined flow from start to finish in a single call. The SDK creates the session, runs every module in the order you specify, and returns aggregated results when the flow finishes.

Use this pattern when you want the simplest integration and the SDK can own the full onboarding experience without your app intervening between modules.

## Prerequisite

The SDK must be initialized before you call `startOnboarding()`. See [Installation](installation) for the `initializeSDK()` call and its arguments.

## Walkthrough

Define the session configuration, the list of modules to run, and (optionally) session recording settings, then call `startOnboarding()`:

```js
let sessionConfig = {
  configurationId: "your-workflow-id", // optional, applies dashboard settings
  region: "ALL",
  mergeSessionRecordings: false
};

let flowConfig = [
  { module: "addPhone" },
  { module: "addId", showIdTypeChooser: "true", showTutorials: "true" },
  { module: "addDocumentScan", documentType: "ADDRESS_STATEMENT" },
  { module: "addGeolocation", isSkippable: "true" },
  { module: "addSelfieScan", showTutorials: "true" },
  { module: "addFaceMatch" },
  { module: "addSignature" },
  { module: "addVideoSelfie" }
];

let recordSessionConfig = {
  recordSession: "false",
  forcePermissions: "false"
};

cordova.exec(
  function (result) {
    console.log("Onboarding completed:", result);
    // result contains the aggregated module results
  },
  function (error) {
    console.log("Onboarding error:", error);
  },
  "Cplugin",
  "startOnboarding",
  [sessionConfig, flowConfig, recordSessionConfig]
);
```

## Arguments

- `sessionConfig`**:** session-level configuration. See [API Reference](api-reference) for the full list of fields. `configurationId` is optional; when provided, the Dashboard-level session settings for that configuration are applied. Module execution order always comes from your local `flowConfig`.
- `flowConfig`**:** an array of module objects describing which modules to run and in what order. See [Modules](modules) for every module and its parameters.
- `recordSessionConfig`**:** optional session recording configuration.

## Results

The success callback receives an object containing the aggregated results of every module in the flow. The error callback receives a typed error string. See [Results](results) for the full structure of the success payload and the list of possible error strings.

## Related pages

- [Modules](modules): every module available in `flowConfig` and its parameters.
- [Results](results): the structure of the success payload and the list of error strings.
- [API Reference](api-reference): the full signature of `startOnboarding()` and every field on `sessionConfig` and `recordSessionConfig`.

<br />
