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

# PFMultiplayerCreateAndJoinLobby

> PFMultiplayerCreateAndJoinLobby reference for creating a new PlayFab lobby and adding the creating client entity to it via the PlayFab Multiplayer C++ SDK.

Create a new lobby and add the creating PlayFab entity to it.

## Syntax

```cpp theme={null}
HRESULT PFMultiplayerCreateAndJoinLobby(  
    PFMultiplayerHandle handle,  
    const PFEntityKey* creator,  
    const PFLobbyCreateConfiguration* createConfiguration,  
    const PFLobbyJoinConfiguration* joinConfiguration,  
    void* asyncContext,  
    PFLobbyHandle* lobby  
)  
```

### Parameters

**`handle`**   PFMultiplayerHandle

The handle of the PFMultiplayer API instance.

**`creator`**   [PFEntityKey\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfentitykey_clientsdk)

The local PlayFab entity creating the lobby.

**`createConfiguration`**   [PFLobbyCreateConfiguration\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateconfiguration)

The initial configuration data used when creating the lobby.

**`joinConfiguration`**   [PFLobbyJoinConfiguration\*](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbyjoinconfiguration)

The initial configuration data for the member creating and joining the lobby.

**`asyncContext`**   void\*\
*optional*

An optional, app-defined, pointer-sized context value that can be used to associate the completion state change with this call.

**`lobby`**   PFLobbyHandle\*\
*optional, library-allocated output*

The optional, output lobby object which can be used to queue operations for immediate execution of this operation completes.

### Return value

Type: HRESULT

`S_OK` if the call succeeded or an error code otherwise. The human-readable form of the error code can be retrieved via [PFMultiplayerGetErrorMessage()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage).

## Remarks

This is an asynchronous operation. Upon successful completion, the title will be provided a [PFLobbyMemberAddedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbymemberaddedstatechange) followed by a [PFLobbyCreateAndJoinLobbyCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateandjoinlobbycompletedstatechange) with the [PFLobbyCreateAndJoinLobbyCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateandjoinlobbycompletedstatechange) field set to `S_OK`. Upon a failed completion, the title will be provided a [PFLobbyCreateAndJoinLobbyCompletedStateChange](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateandjoinlobbycompletedstatechange) with the [PFLobbyCreateAndJoinLobbyCompletedStateChange::result](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateandjoinlobbycompletedstatechange) field set to a failure.

## Requirements

**Header:** PFLobby.h

## See also

[PFLobby members](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/pflobby_members)


## Related topics

- [Create a lobby](/services/playfab/multiplayer/lobby/create-a-lobby.md)
- [PFLobbyGetLobbyProperty](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetlobbyproperty.md)
- [Lobby SDK Quickstart](/services/playfab/multiplayer/lobby/lobby-getting-started.md)
- [PFLobbyGetLobbyPropertyKeys](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/functions/pflobbygetlobbypropertykeys.md)
- [Integrate Party with Lobby using Multiplayer SDK](/services/playfab/multiplayer/networking/party-lobby-integration.md)
