# 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]

```swift
public func identify(
  userId: String,
  options: IdentityOptions? = nil
)
```

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;nil&#x22;,
  },
}"
/>

> **Warning**

`appAccountToken` must be a UUID to be accepted by StoreKit.If the `userId` you pass to `identify` is not a valid UUID string, StoreKit will not accept it for `appAccountToken` and the SDK will fall back to the anonymous alias UUID. This can cause the identifier in App Store Server Notifications to differ from the `userId` you passed. See Apple's docs: [appAccountToken](https://developer.apple.com/documentation/appstoreserverapi/appaccounttoken).



Returns / State [#returns--state]

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

Usage [#usage]

Basic identification:

```swift
Superwall.shared.identify(userId: "user_12345")
```

With options for account switching scenarios:

```swift
let options = IdentityOptions()
options.restorePaywallAssignments = true

Superwall.shared.identify(
  userId: "returning_user_67890",
  options: options
)
```

Call as soon as you have a user ID:

```swift
func userDidLogin(user: User) {
  Superwall.shared.identify(userId: user.id)
  
  // Set additional user attributes
  Superwall.shared.setUserAttributes([
    "email": user.email,
    "plan": user.subscriptionPlan,
    "signUpDate": user.createdAt
  ])
}
```