> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-auto-generate-llmstxt.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# User Identity

> Use stable user IDs with social.plus SDK while keeping private identity data in your own system.

social.plus SDK identifies each user by a `userId` that your app provides. The `userId` should be stable, unique, and non-sensitive because it becomes the SDK identity used by login, profile, search, permission, and moderation APIs.

<Info>
  Keep your source-of-truth account record, credentials, email address, and private profile data in your own system. Send social.plus only the stable `userId` and the social profile fields your experience needs.
</Info>

## User ID Rules

| Rule                      | Recommendation                                                                       |
| ------------------------- | ------------------------------------------------------------------------------------ |
| Stable                    | Use an ID that will not change for the lifetime of the account.                      |
| Unique                    | Use a value already guaranteed unique by your backend.                               |
| Non-sensitive             | Avoid emails, phone numbers, or other personal identifiers.                          |
| Reusable across SDK calls | Use the same value for login, profile reads, search results, and moderation actions. |

## Recommended IDs

<Tabs>
  <Tab title="Recommended">
    Use database primary keys, UUIDs, or another immutable ID from your backend.

    ```text theme={null}
    userId: "12345"
    userId: "user_abc123"
    userId: "4f8b4c2d-9e1a-4f3a-8b7c-6d5e4f3a9910"
    ```
  </Tab>

  <Tab title="Avoid">
    Do not use identifiers that may change or expose private information.

    ```text theme={null}
    userId: "john.doe@example.com"
    userId: "johndoe123"
    userId: "john_doe"
    ```
  </Tab>
</Tabs>

<Warning>
  After a user is created in social.plus, treat the `userId` as immutable.
</Warning>

## Stored Social Profile Fields

social.plus stores social profile and moderation fields that support SDK features. Avoid putting sensitive personal data in these fields.

| Field                              | Description                                                                        |
| ---------------------------------- | ---------------------------------------------------------------------------------- |
| `userId`                           | Stable identifier supplied by your app.                                            |
| `displayName`                      | User-facing profile name.                                                          |
| `description`                      | User-facing profile description or bio.                                            |
| `metadata`                         | Custom social metadata. Do not store sensitive personal data here.                 |
| `avatarFileId` / `avatarCustomUrl` | Avatar image reference.                                                            |
| `roles`                            | Assigned roles for permissions and moderation workflows.                           |
| `flagCount` / `isFlaggedByMe`      | Moderation reporting state.                                                        |
| `isGlobalBan` / `isDeleted`        | Account moderation or deletion state exposed by SDK query results where available. |

## Parameters

| Operation                  | Input                                                          | Required            | Platforms                         | Description                                                                               |
| -------------------------- | -------------------------------------------------------------- | ------------------- | --------------------------------- | ----------------------------------------------------------------------------------------- |
| Initialize user repository | Initialized SDK client                                         | Yes                 | TypeScript, iOS, Android, Flutter | The SDK must be initialized before user repository APIs are used.                         |
| Initialize user repository | User repository object or import                               | Yes                 | TypeScript, iOS, Android, Flutter | Platform-specific entry point for user reads, search, updates, and moderation operations. |
| Use user operation APIs    | `userId`, display-name keyword, sort option, or paging control | Operation-dependent | TypeScript, iOS, Android, Flutter | Use the operation pages for method-specific inputs and result shapes.                     |

## Initialize the user repository

Initialize the user repository before calling user read, search, update, or moderation APIs.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { UserRepository } from '@amityco/ts-sdk';
  ```

  ```swift iOS theme={null}
  let userRepository = AmityUserRepository()
  ```

  ```kotlin Android theme={null}
  fun initUserRepository() {
      val userRepository = AmityCoreClient.newUserRepository()
  }
  ```

  ```dart Flutter theme={null}
  void initUserRepository() {
    final userRepository = AmityCoreClient.newUserRepository();
  }
  ```
</CodeGroup>

## Related topics

<CardGroup cols={2}>
  <Card title="Create User" href="./user-operations/create-user" icon="user-plus">
    Log in or create a user with the stable `userId`.
  </Card>

  <Card title="User Operations" href="./user-operations/overview" icon="user-gear">
    Choose the right SDK operation for user reads, updates, search, moderation, and tokens.
  </Card>
</CardGroup>
