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

# XUser

> XUser

# XUser

Reference material for XUser APIs.

## Functions

| Function                                                                                                                                   | Description                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)                                                                           | Asynchronously adds a user to a game session.                                                                                                                                                                                                                          |
| [XUserAddByIdWithUiAsync](/reference/system/xuser/functions/xuseraddbyidwithuiasync)                                                       | Asynchronously adds a user to a game session based on a XUID from a game invite. This function should only be used in response to a game invite.                                                                                                                       |
| [XUserAddByIdWithUiResult](/reference/system/xuser/functions/xuseraddbyidwithuiresult)                                                     | Retrieves a handle to the user that XUserAddByIdWithUiAsync creates. This function should only be used in response to a game invite.                                                                                                                                   |
| [XUserAddResult](/reference/system/xuser/functions/xuseraddresult)                                                                         | Retrieves a handle to a user that XUserAddAsync creates.                                                                                                                                                                                                               |
| [XUserChangeEventCallback](/reference/system/xuser/functions/xuserchangeeventcallback)                                                     | A callback that an application defines for a user change event.                                                                                                                                                                                                        |
| [XUserCheckPrivilege](/reference/system/xuser/functions/xusercheckprivilege)                                                               | Determines if a user has a specific privilege.                                                                                                                                                                                                                         |
| [XUserCloseHandle](/reference/system/xuser/functions/xuserclosehandle)                                                                     | Closes a specific user handle.                                                                                                                                                                                                                                         |
| [XUserCloseSignOutDeferralHandle](/reference/system/xuser/functions/xuserclosesignoutdeferralhandle)                                       | Closes a specific user sign out deferral handle.                                                                                                                                                                                                                       |
| [XUserCompare](/reference/system/xuser/functions/xusercompare)                                                                             | Compares two user handles for equality.                                                                                                                                                                                                                                |
| [XUserDefaultAudioEndpointUtf16ChangedCallback](/reference/system/xuser/functions/xuserdefaultaudioendpointutf16changedcallback)           | A callback that an application defines and invokes when the default audio endpoint for a user changes.                                                                                                                                                                 |
| [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback)                           | A callback that invokes when the user-device association changes.                                                                                                                                                                                                      |
| [XUserDuplicateHandle](/reference/system/xuser/functions/xuserduplicatehandle)                                                             | Duplicates a user handle.                                                                                                                                                                                                                                              |
| [XUserFindControllerForUserWithUiAsync](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync)                           | Shows a dialog that will prompt the user to turn on and identify which controller they want to use.                                                                                                                                                                    |
| [XUserFindControllerForUserWithUiResult](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult)                         | Retrieves the application local device ID (APP\_LOCAL\_DEVICE\_ID) that a user has chosen to use.                                                                                                                                                                      |
| [XUserFindForDevice](/reference/system/xuser/functions/xuserfindfordevice)                                                                 | Retrieves the user ID for a specific device ID.                                                                                                                                                                                                                        |
| [XUserFindUserById](/reference/system/xuser/functions/xuserfinduserbyid)                                                                   | Retrieves the XBox User ID (XUID) for a local user.                                                                                                                                                                                                                    |
| [XUserFindUserByLocalId](/reference/system/xuser/functions/xuserfinduserbylocalid)                                                         | Retrieves a handle to the user for a specific local user ID.                                                                                                                                                                                                           |
| [XUserGetAgeGroup](/reference/system/xuser/functions/xusergetagegroup)                                                                     | Returns the age group of a user.                                                                                                                                                                                                                                       |
| [XUserGetDefaultAudioEndpointUtf16](/reference/system/xuser/functions/xusergetdefaultaudioendpointutf16)                                   | Retrieves the default audio endpoint for a specific user.                                                                                                                                                                                                              |
| [XUserGetGamerPictureAsync](/reference/system/xuser/functions/xusergetgamerpictureasync)                                                   | Asynchronously retrieves the gamer picture for a specific user.                                                                                                                                                                                                        |
| [XUserGetGamerPictureResult](/reference/system/xuser/functions/xusergetgamerpictureresult)                                                 | Retrieves the result of a call to XUserGetGamerPictureAsync.                                                                                                                                                                                                           |
| [XUserGetGamerPictureResultSize](/reference/system/xuser/functions/xusergetgamerpictureresultsize)                                         | Returns the buffer size that [XUserGetGamerPictureResult](/reference/system/xuser/functions/xusergetgamerpictureresult) requires to retrieve the gamer picture that ]XUserGetGamerPictureAsync]\(/reference/system/xuser/functions/xusergetgamerpictureasync) returns. |
| [XUserGetGamertag](/reference/system/xuser/functions/xusergetgamertag)                                                                     | Retrieves the gamertag for a specific user.                                                                                                                                                                                                                            |
| [XUserGetId](/reference/system/xuser/functions/xusergetid)                                                                                 | Gets the user ID for a specific user.                                                                                                                                                                                                                                  |
| [XUserGetIsGuest](/reference/system/xuser/functions/xusergetisguest)                                                                       | Returns a boolean indicating if a user is a guest.                                                                                                                                                                                                                     |
| [XUserGetLocalId](/reference/system/xuser/functions/xusergetlocalid)                                                                       | Retrieves a unique game session id for a user.                                                                                                                                                                                                                         |
| [XUserGetMaxUsers](/reference/system/xuser/functions/xusergetmaxusers)                                                                     | Retrieves the maximum number of users that a game session allows on the current platform.                                                                                                                                                                              |
| [XUserGetMsaTokenSilentlyAsync](/reference/system/xuser/functions/xusergetmsatokensilentlyasync)                                           | This function is now deprecated.                                                                                                                                                                                                                                       |
| [XUserGetMsaTokenSilentlyResult](/reference/system/xuser/functions/xusergetmsatokensilentlyresult)                                         | This function is now deprecated.                                                                                                                                                                                                                                       |
| [XUserGetMsaTokenSilentlyResultSize](/reference/system/xuser/functions/xusergetmsatokensilentlyresultsize)                                 | This function is now deprecated.                                                                                                                                                                                                                                       |
| [XUserGetSignOutDeferral](/reference/system/xuser/functions/xusergetsignoutdeferral)                                                       | Retrieves a handle to the sign out deferral.                                                                                                                                                                                                                           |
| [XUserGetState](/reference/system/xuser/functions/xusergetstate)                                                                           | Retrieves the state of a user.                                                                                                                                                                                                                                         |
| [XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync)                                         | Asynchronously retrieves xtokens and signatures for web requests.                                                                                                                                                                                                      |
| [XUserGetTokenAndSignatureResult](/reference/system/xuser/functions/xusergettokenandsignatureresult)                                       | Gets the result of a call to XUserGetTokenAndSignatureAsync.                                                                                                                                                                                                           |
| [XUserGetTokenAndSignatureResultSize](/reference/system/xuser/functions/xusergettokenandsignatureresultsize)                               | Gets the buffer size for holding the results of a call to XUserGetTokenAndSignatureAsync.                                                                                                                                                                              |
| [XUserGetTokenAndSignatureUtf16Async](/reference/system/xuser/functions/xusergettokenandsignatureutf16async)                               | Asynchronously retrieves Unicode xtokens and signatures for web requests.                                                                                                                                                                                              |
| [XUserGetTokenAndSignatureUtf16Result](/reference/system/xuser/functions/xusergettokenandsignatureutf16result)                             | Gets the result of a call to XUserGetTokenAndSignatureUtf16Async.                                                                                                                                                                                                      |
| [XUserGetTokenAndSignatureUtf16ResultSize](/reference/system/xuser/functions/xusergettokenandsignatureutf16resultsize)                     | Gets the buffer size for holding the results of a call to XUserGetTokenAndSignatureUtf16Async.                                                                                                                                                                         |
| [XUserIsStoreUser](/reference/system/xuser/functions/xuserisstoreuser)                                                                     | Checks if the XUser MSA is the same as the MSA signed into the Microsoft Store.                                                                                                                                                                                        |
| [XUserRegisterForChangeEvent](/reference/system/xuser/functions/xuserregisterforchangeevent)                                               | Registers a callback for a user change event.                                                                                                                                                                                                                          |
| [XUserRegisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed)     | Registers a callback that the application defines and invokes when the default audio endpoint changes.                                                                                                                                                                 |
| [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged)                     | Registers a callback for user device association change events.                                                                                                                                                                                                        |
| [XUserResolveIssueWithUiAsync](/reference/system/xuser/functions/xuserresolveissuewithuiasync)                                             | Displays a system User Interface for solving token issues with a non-unicode URL.                                                                                                                                                                                      |
| [XUserResolveIssueWithUiResult](/reference/system/xuser/functions/xuserresolveissuewithuiresult)                                           | Retrieves the result of a call to XUserResolveIssueWithUiAsync.                                                                                                                                                                                                        |
| [XUserResolveIssueWithUiUtf16Async](/reference/system/xuser/functions/xuserresolveissuewithuiutf16async)                                   | Displays a system User Interface for solving token issues with a specific unicode URL.                                                                                                                                                                                 |
| [XUserResolveIssueWithUiUtf16Result](/reference/system/xuser/functions/xuserresolveissuewithuiutf16result)                                 | Retrieves the result of a call to XUserResolveIssueWithUiUtf16Async.                                                                                                                                                                                                   |
| [XUserResolvePrivilegeWithUiAsync](/reference/system/xuser/functions/xuserresolveprivilegewithuiasync)                                     | Displays a resolution user interface for required user privileges.                                                                                                                                                                                                     |
| [XUserResolvePrivilegeWithUiResult](/reference/system/xuser/functions/xuserresolveprivilegewithuiresult)                                   | Retrieves the result of a call to XUserResolvePrivilegeWithUiAsync.                                                                                                                                                                                                    |
| [XUserUnregisterForChangeEvent](/reference/system/xuser/functions/xuserunregisterforchangeevent)                                           | Unregisters a previously registered user change callback.                                                                                                                                                                                                              |
| [XUserUnregisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserunregisterfordefaultaudioendpointutf16changed) | Unregisters a previously-registered default audio endpoint change callback.                                                                                                                                                                                            |
| [XUserUnregisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged)                 | Unregisters a previously registered user device association change callback.                                                                                                                                                                                           |
| [xUserPlatformRemoteConnectSetEventHandlers](/reference/system/xuser/functions/xuserplatformremoteconnectseteventhandlers)                 | Sets the remote connect event handlers                                                                                                                                                                                                                                 |
| [XUserPlatformRemoteConnectCancelPrompt](/reference/system/xuser/functions/xuserplatformremoteconnectcancelprompt)                         | Signal to XUser that the remote connect prompt has been dismissed by the user.                                                                                                                                                                                         |
| [XUserPlatformRemoteConnectShowPromptEventHandler](/reference/system/xuser/functions/xuserplatformremoteconnectshowprompteventhandler)     | Show prompt for remote connect authentication event handler.                                                                                                                                                                                                           |
| [XUserPlatformRemoteConnectClosePromptEventHandler](/reference/system/xuser/functions/xuserplatformremoteconnectcloseprompteventhandler)   | Close prompt for remote authentication event handler.                                                                                                                                                                                                                  |
| [XUserPlatformSpopPromptEventHandler](/reference/system/xuser/functions/xuserplatformspopprompteventhandler)                               | Show prompt for SPOP operation event handler                                                                                                                                                                                                                           |
| [XUserPlatformSpopPromptSetEventHandlers](/reference/system/xuser/functions/xuserplatformspoppromptseteventhandlers)                       | Sets the SPOP prompt event handler.                                                                                                                                                                                                                                    |
| [XUserPlatformSpopPromptClearEventHandler](/reference/system/xuser/functions/xuserplatformspoppromptcleareventhandler)                     | Clears the SPOP prompt event handler in XUser.                                                                                                                                                                                                                         |
| [XUserPlatformSpopPromptComplete](/reference/system/xuser/functions/xuserplatformspoppromptcomplete)                                       | Signal to XUser that the user finished interacting with the SPOP prompt.                                                                                                                                                                                               |

## Structures

| Structure                                                                                                            | Description                                                                      |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [APP\_LOCAL\_DEVICE\_ID](/reference/system/xuser/structs/app_local_device_id)                                        | Specifies the root ID of a local input device.                                   |
| [XUserDeviceAssociationChange](/reference/system/xuser/structs/xuserdeviceassociationchange)                         | Specifies the old and new device associations when a device association changes. |
| [XUserGetTokenAndSignatureData](/reference/system/xuser/structs/xusergettokenandsignaturedata)                       | Specifies the xtokens and signatures that we retrieve for web requests.          |
| [XUserGetTokenAndSignatureHttpHeader](/reference/system/xuser/structs/xusergettokenandsignaturehttpheader)           | Specifies the HTTP header for a web request.                                     |
| [XUserGetTokenAndSignatureUtf16Data](/reference/system/xuser/structs/xusergettokenandsignatureutf16data)             | Contains Unicode xtokens and signatures for web requests.                        |
| [XUserGetTokenAndSignatureUtf16HttpHeader](/reference/system/xuser/structs/xusergettokenandsignatureutf16httpheader) | Contains a Unicode HTTP header for a web request.                                |
| [XUserLocalId](/reference/system/xuser/structs/xuserlocalid)                                                         | Specifies a game session ID for a user.                                          |
| [XUserPlatformRemoteConnectEventHandlers](/reference/system/xuser/structs/xuserplatformremoteconnecteventhandlers)   | Encapsulates the remote connect event handlers                                   |

## Enumerations

| Enumeration                                                                                        | Description                                                                    |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [XUserAddOptions](/reference/system/xuser/enums/xuseraddoptions)                                   | Specifies the options for adding a user.                                       |
| [XUserAgeGroup](/reference/system/xuser/enums/xuseragegroup)                                       | Specifies the age group of a user.                                             |
| [XUserChangeEvent](/reference/system/xuser/enums/xuserchangeevent)                                 | Specifies the type of user change event.                                       |
| [XUserDefaultAudioEndpointKind](/reference/system/xuser/enums/xuserdefaultaudioendpointkind)       | Specifies whether the user's default audio endpoint renders or captures audio. |
| [XUserGamerPictureSize](/reference/system/xuser/enums/xusergamerpicturesize)                       | Specifies the size of the gamer picture in pixels.                             |
| [XUserGamertagComponent](/reference/system/xuser/enums/xusergamertagcomponent)                     | Specifies the type (or component) of gamertag to fetch.                        |
| [XUserGetMsaTokenSilentlyOptions](/reference/system/xuser/enums/xusergetmsatokensilentlyoptions)   | Options for XUserGetMsaTokenSilentlyOptions.                                   |
| [XUserGetTokenAndSignatureOptions](/reference/system/xuser/enums/xusergettokenandsignatureoptions) | Options for GetUserTokenAndSignatureAsync.                                     |
| [XUserPrivilege](/reference/system/xuser/enums/xuserprivilege)                                     | Specifies the privileges of a user.                                            |
| [XUserPrivilegeDenyReason](/reference/system/xuser/enums/xuserprivilegedenyreason)                 | Specifies the reason a user could not obtain a privilege.                      |
| [XUserPrivilegeOptions](/reference/system/xuser/enums/xuserprivilegeoptions)                       | Specifies the user privilege options.                                          |
| [XUserState](/reference/system/xuser/enums/xuserstate)                                             | Specifies the current state of the user.                                       |
| [XUserPlatformOperationResult](/reference/system/xuser/enums/XUserPlatformOperationResult)         | Enum defining the results of a client operation                                |
| [XUserPlatformSpopOperationResult](/reference/system/xuser/enums/xuserplatformspopoperationresult) | Enum defining the results of a client operation.                               |

## Conceptual documentation

* [Asynchronous programming design goals and improvements](/build/core-features/common/async/async-whitepaper)
* [WinHTTP overview](/build/console-features/networking/web-requests/intro-winhttp)
* [Web requests (contents)](/build/console-features/networking/web-requests/web-requests-toc)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)
* [Using C# wrappers for GDK APIs in your Unity project](/build/gdk-and-engines/unity/unity-api-wrappers)

## See also

[System API reference](/reference/system/gc-reference-system-toc)

## Error Codes

The following error codes may be returned by XUser APIs. For a complete list, see [Error codes](/reference/errorcodes).

| Code                                              | Value      | Description                                                                                                 |
| ------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------- |
| E\_GAMEUSER\_MAX\_USERS\_ADDED                    | 0x89245100 | Cannot add this user because the maximum number of users has been reached.                                  |
| E\_GAMEUSER\_SIGNED\_OUT                          | 0x89245101 | Cannot perform the operation because the user is signed out.                                                |
| E\_GAMEUSER\_RESOLVE\_USER\_ISSUE\_REQUIRED       | 0x89245102 | UI is required to resolve an issue with this user.                                                          |
| E\_GAMEUSER\_DEFERRAL\_NOT\_AVAILABLE             | 0x89245103 | Not an appropriate time to request deferral.                                                                |
| E\_GAMEUSER\_USER\_NOT\_FOUND                     | 0x89245104 | User matching the ID was not found.                                                                         |
| E\_GAMEUSER\_NO\_TOKEN\_REQUIRED                  | 0x89245105 | No token is required for this call.                                                                         |
| E\_GAMEUSER\_NO\_DEFAULT\_USER                    | 0x89245106 | No current default user. If you get this error, call XUserAddAsync again without AddDefaultUserSilently.    |
| E\_GAMEUSER\_FAILED\_TO\_RESOLVE                  | 0x89245107 | Failed to resolve the given privilege.                                                                      |
| E\_GAMEUSER\_NO\_TITLE\_ID                        | 0x89245108 | An XBOX Live TitleId must be configured.                                                                    |
| E\_GAMEUSER\_UNKNOWN\_GAME\_IDENTITY              | 0x89245109 | The game identity is not recognized. The MSAAppId and TitleId do not match the ones associated to the game. |
| E\_GAMEUSER\_NO\_PACKAGE\_IDENTITY                | 0x89245110 | A package identity must be configured.                                                                      |
| E\_GAMEUSER\_FAILED\_TO\_GET\_TOKEN               | 0x89245111 | The token request failed.                                                                                   |
| E\_GAMEUSER\_INVALID\_APP\_CONFIGURATION          | 0x89245112 | The MSAAppId in the game config is invalid or not configured for the authentication stack.                  |
| E\_GAMEUSER\_MALFORMED\_MSAAPPID                  | 0x89245113 | The MSAAppId in the game config does not match the expected format (16 character string or GUID).           |
| E\_GAMEUSER\_INCONSISTENT\_MSAAPPID\_AND\_TITLEID | 0x89245114 | The MSAAppId and TitleId in the game config do not match the ones associated to the game.                   |


## Related topics

- [User identity and XUser](/build/core-features/common/user/player-identity-xuser.md)
- [Users](/build/core-features/common/user/user-toc.md)
- [Headless automation of XUser](/build/core-features/common/user/users-headless-automation.md)
- [User identity and XUser APIs in the GDK](/build/core-features/common/user/index.md)
- [XUserIsStoreUser](/reference/system/xuser/functions/xuserisstoreuser.md)
