Reset API in Mobile SDKs

Learn about the reset API call in Kotlin and Swift SDKs.

This guide explains how to use the reset API in Kotlin and Swift SDKs.

Overview

The RudderStack Kotlin and Swift SDKs provide a reset API that lets you clear the persisted data, for example, user ID and traits.

The SDK also does the following once you call the reset API:

  • Generates a new anonymousId (default behavior)
  • If session tracking is enabled, clears the current sessionId and generates a new one.
info
If a mobile device mode integration plugin is present, then calling the reset API also triggers the integration’s reset API — provided it is supported.

The reset API supports the following invocations:

Default behavior

By default, calling the reset API clears all persisted user data including user ID and traits, refreshes session information, and generates a new anonymous ID.

Selective reset

You can also use the reset API to choose which specific data components to reset while preserving others. This way, you have granular control over each component — you can regenerate the anonymous ID, clear the user ID, clear traits, or refresh session information, or preserve any of these values as per your requirement.

To perform a selective reset, the SDKs provide a options parameter that accepts a ResetOptions object with the following structure:

entries parameters

The following table describes the parameters accepted by the entries object of ResetOptions:

ParameterDescriptionDefault value
anonymousIdResets the anonymous user ID.true
userIdResets the persisted user ID.true
traitsResets the persisted user traits.true
sessionResets the current session information.true
info
All entries in the ResetOptions.entries object are optional. If you do not specify any entry, the SDK sets its default value as described in the above table.

Examples

This section provides examples of how to perform a selective reset by using the reset API with different entries parameters.

Reset all data except session information

Reset only session information

Reset only user ID and traits


Questions? Contact us by Email or on Slack