> For the complete documentation index, see [llms.txt](https://docs.thryve.health/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thryve.health/integrate-your-mobile-app/update-thryve-sdk-and-module-configs.md).

# Update Thryve SDK and module configs

After the SDK is initialized with `getOrCreate`, you can change credentials, locale, identity, or module settings without restarting the app.

There are two APIs:

| API                  | Use when                                                                                                     |
| -------------------- | ------------------------------------------------------------------------------------------------------------ |
| `updateSDKConfig`    | You need to change top-level SDK fields and/or multiple modules together                                     |
| `updateModuleConfig` | You only need to update one module (for example device events listener, Shen AI listener, or observability). |

{% hint style="warning" %}
`updateSDKConfig` treats the config as authoritative. Always pass a full `ThryveSDKConfig` that still includes every module you want to keep active. Omitting a module config (for example Garmin Companion license) can tear that module down at runtime.
{% endhint %}

{% hint style="danger" %}
`ThryveGarminCompanionConfig` can not be updated at runtime. It can only be updated after [re-intialization](https://docs.thryve.health/connect-data-sources.md) using `getOrCreate`  during a restart of your application.
{% endhint %}

{% hint style="danger" %}
`updateModuleConfig` does not support updating `ThryveObservability` configuration in the Thryve Android SDK
{% endhint %}

### Update `ThryveSDKConfig` at runtime using `updateSDKConfig`

{% tabs %}
{% tab title="iOS" %}

```swift
private func makeFullSDKConfig(endUserId: String?, endUserAlias: String?) -> ThryveSDKConfig {
    let credentials = partnerInfo.resolvedCredentialPair()
    let backgroundSyncEnabled = UserDefaults.standard.bool(forKey: AppleHealthViewModel.bgSyncKey)
    return ThryveSDKConfig(
        authId: credentials.authId,
        authSecret: credentials.authSecret,
        endUserAlias: endUserAlias,
        endUserId: endUserId,
        locale: partnerInfo.language == "none" ? nil : partnerInfo.language,
        configs: [
            ThryveAppleHealthConfig(
                dataTypes: ThryveAppleHealthDataType.allConnectorTypes,
                enableBackgroundSync: backgroundSyncEnabled
            ),
            ThryveShenAIConfig(apiKey: Environment.shenAIApiKey)
        ],
        observability: ObservabilityConfig(
            tracingEnabled: observabilityEnabled,
            crashReportingEnabled: crashReportingEnabled
        )
    )
}
```

```swift
//Apply updated fields without recreating the SDK using the function above
let updatedConfig = makeFullSDKConfig(
        endUserId: endUserId,
        endUserAlias: endUserAlias
    )
    ThryveSDK.get().updateSDKConfig(
        thryveSDKConfig: updatedConfig,
        callback: completion
    )
```

{% endtab %}

{% tab title="Android" %}

```kt
fun buildSDKConfig(
    endUserId: String? = null,
    endUserAlias: String,
): ThryveSDKConfig {
    return ThryveSDKConfig(
        authId = authId,
        authSecret = authSecret,
        endUserAlias = endUserAlias,
        endUserId = endUserId,
        locale = locale,
        healthConnectConfig = ThryveHealthConnectConfig(
            dataTypes = healthConnectPermissions,
            enableBackgroundSync = true,
            enableReadHealthDataHistory = true,
        ),
        samsungHealthConfig = currentSamsungHealthConfig(),
        shenAIConfig = ThryveShenAIConfig(
            apiKey = "SHEN_AI_API_KEY",
            eventsListener = shenAIEventListener,
        ),
        observabilityConfig = ThryveObservabilityConfig(
            tracingEnabled = tracingEnabled,
            crashReportingEnabled = crashReportingEnabled,
        ),
    )
}
```

```kt
//Apply updated fields without recreating the SDK using the function above and shared state

//Apply updated locale
sharedState.locale = selectedLanguage
ThryveSDK.get().updateSDKConfig(sharedState.buildSDKConfig())

//Apply updated ThryveHealthConnect data types
sharedState.healthConnectPermissions = updatedDataTypes
ThryveSDK.get().updateSDKConfig(sharedState.buildSDKConfig())

//Apply updated ThryveSamsungHealth data types
sharedState.samsungHealthPermissions = updated
ThryveSDK.get().updateSDKConfig(sharedState.buildSDKConfig())
```

{% endtab %}

{% tab title="React Native" %}

```dart
import { InitOptions, Source } from '@thryve/react-native-sdk';

function buildSDKConfig(
  endUserAlias: string,
  endUserId: string | null = null,
  locale: string = 'en',
): InitOptions {
  return {
    authId: 'AUTH_ID',
    authSecret: 'AUTH_SECRET',
    endUserAlias,
    endUserId,
    locale,
    configs: [
      {
        source: Source.APPLE,
        dataTypes: appleHealthDataTypes,
        enableBackgroundSync: true,
      },
      {
        source: Source.HEALTH_CONNECT,
        dataTypes: healthConnectDataTypes,
        enableBackgroundSync: true,
        enableReadHealthDataHistory: true,
      },
      {
        source: Source.SAMSUNG,
        dataTypes: samsungHealthDataTypes,
        enableBackgroundSync: true,
      },
      {
        source: Source.SHENAI,
        apiKey: 'SHEN_AI_API_KEY',
      },
    ],
  };
}

async function changeLanguage(selectedLanguage: string) {
  // `thryve` is the initialised ThryveSDK instance (see initialisation above).

  // The new config replaces the one passed to getOrCreate,
  // so repeat every value the app still needs.
  const response = await thryve.updateSDKConfig(
    buildSDKConfig('YOUR_UNIQUE_USER_IDENTIFIER', null, selectedLanguage),
  );
  if (response.errors && response.errors.length > 0) {
    // Process all `ThryveError`s in `response.errors`
    return;
  }
}
```

{% endtab %}

{% tab title="Flutter" %}

```dart
import 'package:flutter/foundation.dart';
import 'package:module_apple_health/module_apple_health.dart';
import 'package:module_health_connect/module_health_connect.dart';
import 'package:thryve_sdk/thryve_sdk.dart';

/// Switches the SDK to [locale], e.g. 'de'. A ThryveDataSourceConnectionWidget
/// shown afterwards renders in that language.
Future<void> changeSdkLanguage(String locale) async {
  const thryveSDK = ThryveSDK();

  // The new config replaces the one passed to init, so repeat every value the app
  // still needs. Only the locale changes here.
  final ThryveResponse<bool> response = await thryveSDK.updateSDKConfig(
    ThryveSDKConfig(
      authId: '<auth id>',
      authSecret: '<auth secret>',
      endUserAlias: '<end user alias>',
      locale: locale,
      healthConnectConfig: ThryveHealthConnectConfig(
        dataTypes: [ThryveHealthConnectDataType.steps, ThryveHealthConnectDataType.heartRate],
      ),
      appleHealthConnectConfig: ThryveAppleHealthConfig(
        dataTypes: [ThryveAppleHealthDataType.stepCount, ThryveAppleHealthDataType.heartRate],
      ),
    ),
  );

  if (response.isSuccessful) {
    debugPrint('SDK language changed to $locale');
  } else {
    // The previous configuration, including its locale, is still active.
    for (final error in response.errors) {
      debugPrint('updateSDKConfig failed: ${error?.code} ${error?.message}');
    }
  }
}
```

{% endtab %}
{% endtabs %}

### `updateModuleConfig` at runtime

{% tabs %}
{% tab title="iOS" %}

```swift
// Apply Cbservability configuration changes
 ThryveSDK.get().updateModuleConfig(
    config: ObservabilityConfig(
        tracingEnabled: tracingEnabled,
        crashReportingEnabled: crashReportingEnabled
    )
)

// Apply ShenAI configuration changes
let configWithListener = ThryveShenAIConfig(
    apiKey: Environment.shenAIApiKey,
    eventsListener: self
)
ThryveSDK.get().updateModuleConfig(config: configWithListener)
```

{% endtab %}

{% tab title="Android" %}

```kt
// Apply Health Connect configuration changes
ThryveSDK.get().updateModuleConfig(
    source = Source.HEALTH_CONNECT,
    config = ThryveHealthConnectConfig(
        dataTypes = updatedHealthConnectTypes,
        enableBackgroundSync = true,
        enableReadHealthDataHistory = true,
    ),
)
```

{% endtab %}

{% tab title="React Native" %}

```
import { Source } from '@thryve/react-native-sdk';

// `thryve` is the initialised ThryveSDK instance (see initialisation above).

// Apply Health Connect configuration changes (Android)
thryve.updateModuleConfig({
  source: Source.HEALTH_CONNECT,
  dataTypes: updatedHealthConnectTypes,
  enableBackgroundSync: true,
  enableReadHealthDataHistory: true,
});

// Apply Apple Health configuration changes (iOS)
thryve.updateModuleConfig({
  source: Source.APPLE,
  dataTypes: updatedAppleHealthTypes,
  enableBackgroundSync: true,
});

```

{% endtab %}

{% tab title="Flutter" %}

```dart
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:module_apple_health/module_apple_health.dart';
import 'package:module_health_connect/module_health_connect.dart';
import 'package:thryve_sdk/thryve_sdk.dart';

Future<void> updateRequestedDataTypes() async {
  const thryveSDK = ThryveSDK();

  // Pass the complete module configuration, not just the changed fields. Every flag is
  // sent with this call, so an omitted flag falls back to its default rather than
  // keeping the value set at init.
  final ThryveResponse<bool> response = Platform.isAndroid
      ? await thryveSDK.updateModuleConfig(
          Source.healthConnect.id,
          ThryveHealthConnectConfig(
            dataTypes: [ThryveHealthConnectDataType.steps, ThryveHealthConnectDataType.heartRate],
          ),
        )
      : await thryveSDK.updateModuleConfig(
          Source.apple.id,
          ThryveAppleHealthConfig(
            dataTypes: [ThryveAppleHealthDataType.stepCount, ThryveAppleHealthDataType.heartRate],
          ),
        );

  if (response.isSuccessful) {
    debugPrint('Module config updated: ${response.data}');
  } else {
    for (final error in response.errors) {
      debugPrint('updateModuleConfig failed: ${error?.code} ${error?.message}');
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Which API should I call?

1. Changing locale, auth, end-user identity, or several modules → `updateSDKConfig(fullConfig)`
2. Changing one module listener / one module setting → `updateModuleConfig(...)`
3. Changing end-user identity in a way that requires a clean re-init → `getOrCreate(fullConfig)` again&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thryve.health/integrate-your-mobile-app/update-thryve-sdk-and-module-configs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
