# identify()

A function that creates an account with Superwall by linking a userId to the automatically generated alias.

> **Tip**

Call this as soon as you have a user ID, typically after login or when the user's identity becomes available.



Purpose [#purpose]

Links a user ID to Superwall's automatically generated alias, creating an account for analytics and personalization.

Signature [#signature]

```kotlin
fun Superwall.identify(
    userId: String,
    options: IdentityOptions? = null
)
```

```java
// Java
public void identify(
    String userId,
    @Nullable IdentityOptions options
)
```

Parameters [#parameters]

<TypeTable
  type="{
  userId: {
    type: &#x22;String&#x22;,
    description: &#x22;Your user's unique identifier, as defined by your backend system.&#x22;,
    required: true,
  },
  options: {
    type: &#x22;IdentityOptions?&#x22;,
    description: &#x22;Optional configuration for identity behavior. Set `restorePaywallAssignments` to `true` to wait for paywall assignments from the server. Use only in advanced cases where users frequently switch accounts.&#x22;,
    default: &#x22;null&#x22;,
  },
}"
/>

Returns / State [#returns--state]

This function returns `Unit`. After calling, [`isLoggedIn`](/docs/android/sdk-reference/userId) will return `true` and [`userId`](/docs/android/sdk-reference/userId) will return the provided user ID.

Usage [#usage]

Basic identification:

```kotlin
Superwall.instance.identify("user_12345")
```

With options for account switching scenarios:

```kotlin
val options = IdentityOptions().apply {
    restorePaywallAssignments = true
}

Superwall.instance.identify(
    userId = "returning_user_67890",
    options = options
)
```

Call as soon as you have a user ID:

```kotlin
fun userDidLogin(user: User) {
    Superwall.instance.identify(user.id)
    
    // Set additional user attributes
    Superwall.instance.setUserAttributes(mapOf(
        "email" to user.email,
        "plan" to user.subscriptionPlan,
        "signUpDate" to user.createdAt
    ))
}
```

Java usage:

```java
// Basic identification
Superwall.getInstance().identify("user_12345");

// With options
IdentityOptions options = new IdentityOptions();
options.setRestorePaywallAssignments(true);
Superwall.getInstance().identify("returning_user_67890", options);
```