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

# XUserFindUserById

> XUserFindUserById

# XUserFindUserById

Retrieves the XUserHandle based on the XBOX User ID (XUID) of a local user.

## Syntax

```cpp theme={null}
HRESULT XUserFindUserById(  
         uint64_t userId,  
         XUserHandle* handle  
)  
```

### Parameters

*userId*   \_In\_\
Type: uint64\_t

The local user to retrieve the XUID for.

*handle*   \_Out\_\
Type: XUserHandle\*

Contains the XUID for the local user.

### Return value

Type: HRESULT

HRESULT success or error code.\
For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

For each **XUserHandle** handle that you retrieve from an **XUser** API, inluding **XUserFindUserById**, you must
close that handle calling [XUserCloseHandle](/reference/system/xuser/functions/xuserclosehandle).

To retrieve the XBox User ID (XUID) for a local user, call XUserFindUserById.

To retrieve a handle to a user for a specific local user ID, call [XUserFindUserByLocalId](/reference/system/xuser/functions/xuserfinduserbylocalid).

To retrieve a user ID for a specific device ID, call [XUserFindForDevice](/reference/system/xuser/functions/xuserfindfordevice).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, Steam Deck, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)
* [Using the Game Chat 2 C++ API](/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2)

## See also

[XUser](/reference/system/xuser/xuser_members)

[XUserFindUserByLocalId](/reference/system/xuser/functions/xuserfinduserbylocalid)

[XUserFindForDevice](/reference/system/xuser/functions/xuserfindfordevice)


## Related topics

- [XUserFindUserByLocalId](/reference/system/xuser/functions/xuserfinduserbylocalid.md)
- [XUserGetId](/reference/system/xuser/functions/xusergetid.md)
- [Using the Game Chat 2 C++ API](/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2.md)
- [XUser](/reference/system/xuser/xuser_members.md)
- [XUserFindForDevice](/reference/system/xuser/functions/xuserfindfordevice.md)
