> 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](/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 %}
{% 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 %}
{% 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
