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

# Game Servers and Lobbies

> Use PlayFab Lobbies from a dedicated game server by enabling server APIs, authenticating game_server entities, and creating or claiming server-owned lobbies.

This article explains how to use PlayFab Lobbies from a game server.

## Enabling game server APIs in the PlayFab Multiplayer SDK

To enable the game server APIs in PlayFab Multiplayer, you must define PFMULTIPLAYER\_INCLUDE\_SERVER\_APIS before including PFLobby.h.

```cpp theme={null}
#define PFMULTIPLAYER_INCLUDE_SERVER_APIS
#include <PFMultiplayer.h>
#include <PFLobby.h>
```

## Creating server-owned lobbies

To create server-owned lobbies, follow these steps:

1. Log in as a game\_server PlayFab entity with [AuthenticateGameServerWithCustomId](https://learn.microsoft.com/en-us/rest/api/playfab/authentication/authentication/authenticate-game-server-with-custom-id) and retrieve the entity key and token pair.
2. Provide the game\_server's entity key and token to the PlayFab Multiplayer SDK with [PFMultiplayerSetEntityToken](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayersetentitytoken).
3. Call [PFMultiplayerCreateAndClaimServerLobby](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pfmultiplayercreateandclaimserverlobby) with the game\_server's entity key.

For more information and example code, see [Create a lobby](/services/playfab/multiplayer/lobby/create-a-lobby).

## Servers aren't members

In client-owned lobbies, the owner of the lobby is also a member of the lobby.

Server-owned lobbies are different in this regard. The game\_server entity that owns the lobby isn't a member of the lobby.

Server-owners are able to modify global lobby properties but don't have their own member properties section.

For more information on this distinction, see [Lobby owners vs. members](/services/playfab/multiplayer/lobby/owner-requirements-and-privileges).

## Ownership and ownership migration policy

Unlike client-owned lobbies, there's only one valid ownership migration policy for server-owned lobbies: the "Server" ownership migration policy.

This has important impacts on ownership migration and lobby recovery.

Primarily, when the owner of a server-owned lobby disconnects—for example, because the server crashed—ownership of the lobby will not automatically transfer to any of the members in the lobby. Instead, the lobby becomes hidden in lobby search results (to avoid new members unintentionally joining this lobby) and it's up to the title to coordinate some recovery logic.

At the next available opportunity, the game\_server entity which crashed should search for lobbies it needs to recover using the [lobby/amOwner search key](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/constants/pflobbysearchkeys) via [PFMultiplayerFindLobbies](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pfmultiplayerfindlobbies).

After finding the lobbies that need recovery, the game server can either attempt to resume the gameplay session or delete the lobby.

For more information on ownership changes, see [Ownership changes](/services/playfab/multiplayer/lobby/ownership-changes).

## See also

* [Create a lobby](/services/playfab/multiplayer/lobby/create-a-lobby)
* [Lobby owners vs. members](/services/playfab/multiplayer/lobby/owner-requirements-and-privileges#lobby-owners-vs-members)
* [AuthenticateGameServerWithCustomId](https://learn.microsoft.com/en-us/rest/api/playfab/authentication/authentication/authenticate-game-server-with-custom-id)


## Related topics

- [Create a lobby](/services/playfab/multiplayer/lobby/create-a-lobby.md)
- [Lobby invites](/services/playfab/multiplayer/lobby/lobby-invites.md)
- [Join lobbies](/services/playfab/multiplayer/lobby/join-lobbies.md)
- [Lobby lifetime and expiration](/services/playfab/multiplayer/lobby/lobby-ttl.md)
- [Lobby ownership](/services/playfab/multiplayer/lobby/owner-requirements-and-privileges.md)
