> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clariodesk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Identity & lifecycle

> The four host events that touch the SDK: wire each one and you're done.

Four moments in your app's lifecycle interact with the SDK. Wire all four and
the integration is complete. The code below is platform-agnostic; see the
per-SDK lifecycle guides for exact syntax
([Flutter](/flutter/lifecycle), [React Native](/react-native/lifecycle),
[Swift](/swift/lifecycle)).

## 1. App launch (every time)

The most common integration miss: users who installed your app before you added
ClarioDesk never go through login again, so an "identify on login" hook alone
leaves them as unlabeled devices.

Hydrate from your own persisted session on launch and identify
**unconditionally**. `identify()` is idempotent (same values = no-op write) and
cheap (one signed POST, roughly 5 to 25 ms).

<CodeGroup>
  ```dart Flutter theme={null}
  await ClarioDesk.init(apiKey: 'pk_live_…');
  final user = await yourAuth.currentUser();
  if (user != null) {
    await ClarioDesk.identify(externalId: user.id, email: user.email);
  }
  ```

  ```ts React Native theme={null}
  await ClarioDesk.init({ apiKey: 'pk_live_…' });
  const user = await yourAuth.currentUser();
  if (user) await ClarioDesk.identify({ externalId: user.id, email: user.email });
  ```
</CodeGroup>

## 2. Fresh login or signup

Right after your auth succeeds, call `identify()`. This overwrites the label on
the existing device row, without registering a new device or generating a new
key. The same device now carries the new user's metadata.

## 3. Logout

With [Verified identity](/concepts/verified-identity), call
`clearIdentity()` before signing the user out of your own app.

<CodeGroup>
  ```dart Flutter theme={null}
  await ClarioDesk.clearIdentity();
  await yourAuth.signOut();
  ```

  ```ts React Native theme={null}
  await ClarioDesk.clearIdentity();
  await yourAuth.signOut();
  ```
</CodeGroup>

`clearIdentity()` preserves the device key, advances the signed identity epoch,
and prevents old-account cache/network work from becoming visible to the next
host user. In label-only mode, `reset()` remains the stronger shared-device
isolation option.

## 4. User switch (A → B without restart)

Create and await the `clearIdentity()` intent, switch the host session, then
verified-identify user B with a fresh proof.

<Warning>
  Never activate user B before the clear intent exists, and never fall back to a
  label write after proof failure. `reset()` removes this installation; customer
  erasure is a separate owner/admin dashboard action.
</Warning>

## What if I never call `identify()`?

Tickets still work. The device row exists and agents see a device id but no
email, and the dashboard shows an "Unverified device" badge. Useful for
anonymous-feedback flows; otherwise, wire case 1 above.
