# 4. User Creation

After initializing the SDK, you must create a Sentiance user in order to activate the various SDK features.

### 1. Obtain an Authentication Code

{% hint style="warning" %}
This step requires server-side development.
{% endhint %}

To create a Sentiance user, you need to associate them with a user in your system. This process involves providing a unique user identifier from your system to Sentiance. In return, Sentiance generates a temporary authentication code, specifically linked to this user, through secure server-to-server communication. You can then use this authentication code with the Sentiance SDK to create the Sentiance user associated with the provided user identifier. This ensures proper linkage between Sentiance users and users in your system, enabling seamless integration and personalized user experiences while maintaining security and privacy measures. The Sentiance SDK can then deliver valuable insights based on the user's behavior and preferences.

Here are the user creation steps:

1. When you decide to create a Sentiance user in your app, contact your backend and request a Sentiance authentication code.
2. On your backend, [create a corresponding request towards the Sentiance backend](/important-topics/user-registration.md), including your user identifier. This request will be authenticated using a [Sentiance API Key](/important-topics/authentication-and-authorization.md), which you can obtain from the Sentiance Insights Dashboard. *Please remember that this API Key must never be transmitted to your app to maintain security*.
3. Retrieve the authentication code provided by Sentiance from your backend and forward it to your app.
4. In your app, use this authentication code to create the Sentiance user as shown below.

### 2. Create a Sentiance User

After obtaining the authentication code in the step above, create a user by passing the code to the SDK's *createUser* method.

```swift
let options = SENTUserCreationOptions(authenticationCode: "authenticationCode")

Sentiance.shared.createUser(options: options) { result, error in
    guard let result = result else {
        NSLog("User creation failed with reason \(error!.failureReason)")
        return
    }
    
    NSLog("Created a user with ID: \(result.userInfo.userId)")
}
```

{% hint style="info" %}
The SDK supports the presence of only one Sentiance user on the device at a time. If your app supports multiple users (e.g. via a login flow), you can utilize the SDK's reset functionality to remove the existing user from the device, before creating a new one.
{% endhint %}

For more information on user creation, check out [this](/important-topics/user-registration.md) page.


---

# Agent Instructions: 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:

```
GET https://docs.sentiance.com/a-complete-integration/ios-sdk/user-creation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
