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

# Create Lobby

> Create a lobby.

Allowed entity token types: game_server, title_player_account, title

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| LobbyBadRequest | 13007 |
| LobbyPlayerMaxLobbyLimitExceeded | 13008 |
| LobbyRateLimitExceeded | 13001 |




## OpenAPI

````yaml post /Lobby/CreateLobby
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Multiplayer API
  description: >-
    API methods for managing multiplayer servers. API methods for managing
    parties. The lobby service helps players group together to play multiplayer
    games. It is often used as a rendezvous point for players to share
    connection information. The TrueSkill service helps titles to estimate a
    player's skill based on their match results. The player skill values from
    this service are commonly used by a matchmaking service to provide players
    with balanced matches.
  termsOfService: https://playfab.com/terms/
  contact:
    url: https://community.playfab.com/index.html
  license:
    name: Apache 2.0
    url: https://github.com/PlayFab/API_Specs/blob/master/LICENSE
servers:
  - url: https://{titleId}.playfabapi.com
    description: PlayFab title endpoint
    variables:
      titleId:
        default: your_title_id
        description: Your PlayFab title ID (hex).
security: []
tags:
  - name: Lobby
    description: ''
  - name: Matchmaking
    description: Matchmaking APIs
  - name: Matchmaking Admin
    description: Matchmaking Admin APIs
  - name: MultiplayerServer
    description: Multiplayer Server APIs
  - name: PubSub
    description: PlayFab PubSub APIs
  - name: TrueSkill
    description: TrueSkill APIs
  - name: TrueSkill Admin
    description: TrueSkill Admin APIs
paths:
  /Lobby/CreateLobby:
    post:
      tags:
        - Lobby
      summary: Create Lobby
      description: |
        Create a lobby.

        Allowed entity token types: game_server, title_player_account, title

        ## Error codes

        This operation may return the following PlayFab errors:

        | Error | Code |
        | --- | --- |
        | LobbyBadRequest | 13007 |
        | LobbyPlayerMaxLobbyLimitExceeded | 13008 |
        | LobbyRateLimitExceeded | 13001 |
      operationId: CreateLobby
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLobbyRequest'
        description: Request to create a lobby. A Server or client can create a lobby.
      responses:
        '200':
          $ref: '#/components/responses/CreateLobbyResult'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  schemas:
    CreateLobbyRequest:
      description: Request to create a lobby. A Server or client can create a lobby.
      type: object
      properties:
        AccessPolicy:
          allOf:
            - $ref: '#/components/schemas/AccessPolicy'
          description: >-
            The policy indicating who is allowed to join the lobby, and the
            visibility to queries. May be 'Public', 'Friends' or 'Private'.
            Public means the lobby is both visible in queries and any player may
            join, including invited players. Friends means that users who are
            bidirectional friends of members in the lobby may search to find
            friend lobbies, to retrieve its connection string. Private means the
            lobby is not visible in queries, and a player must receive an
            invitation to join. Defaults to 'Public' on creation. Can only be
            changed by the lobby owner.
        CustomTags:
          description: >-
            The optional custom tags associated with the request (e.g. build
            number, external trace identifiers, etc.).
          type: object
        LobbyData:
          description: >-
            The private key-value pairs which are visible to all entities in the
            lobby. At most 30 key-value pairs may be stored here, keys are
            limited to 30 characters and values to 1000. The total size of all
            lobbyData values may not exceed 4096 bytes. Keys are case sensitive.
          type: object
        MaxPlayers:
          description: >-
            The maximum number of players allowed in the lobby. The value must
            be between 2 and 128.
          type: number
          x-actualtype: uint32
        Members:
          description: >-
            The member initially added to the lobby. Client must specify exactly
            one member, which is the creator's entity and member data. Member
            PubSubConnectionHandle must be null or empty. Game servers must not
            specify any members.
          type: array
          items:
            $ref: '#/components/schemas/Member'
          x-isclass: true
        Owner:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: The lobby owner. Must be the calling entity.
        OwnerMigrationPolicy:
          allOf:
            - $ref: '#/components/schemas/OwnerMigrationPolicy'
          description: >-
            The policy for how a new owner is chosen. May be 'Automatic',
            'Manual' or 'None'. Can only be specified by clients. If
            client-owned and 'Automatic' - The Lobby service will automatically
            assign another connected owner when the current owner leaves or
            disconnects. The useConnections property must be true. If client -
            owned and 'Manual' - Ownership is protected as long as the current
            owner is connected. If the current owner leaves or disconnects any
            member may set themselves as the current owner. The useConnections
            property must be true. If client-owned and 'None' - Any member can
            set ownership. The useConnections property can be either true or
            false.
        RestrictInvitesToLobbyOwner:
          description: >-
            A setting that controls whether only the lobby owner can send
            invites to join the lobby. When true, only the lobby owner can send
            invites. When false or not specified, any member can send invites.
            Defaults to false if not specified. Restricted to client owned
            lobbies.
          type: boolean
        SearchData:
          description: >-
            The public key-value pairs which allow queries to differentiate
            between lobbies. Queries will refer to these key-value pairs in
            their filter and order by clauses to retrieve lobbies fitting the
            specified criteria. At most 30 key-value pairs may be stored here.
            Keys are of the format string_key1, string_key2 ... string_key30 for
            string values, or number_key1, number_key2, ... number_key30 for
            numeric values.Numeric values are floats. Values can be at most 256
            characters long. The total size of all searchData values may not
            exceed 1024 bytes.
          type: object
        UseConnections:
          description: >-
            A setting to control whether connections are used. Defaults to true.
            When true, notifications are sent to subscribed players, disconnect
            detection removes connectionHandles, only owner migration policies
            using connections are allowed, and lobbies must have at least one
            connected member to be searchable or be a server hosted lobby with a
            connected server. If false, then notifications are not sent,
            connections are not allowed, and lobbies do not need connections to
            be searchable.
          type: boolean
      required:
        - MaxPlayers
        - Owner
        - UseConnections
        - RestrictInvitesToLobbyOwner
      example:
        MaxPlayers: 50
        Owner:
          Id: '1234'
          Type: title_player_account
          TypeString: title_player_account
        OwnerMigrationPolicy: Automatic
        UseConnections: true
        AccessPolicy: Public
        SearchData:
          string_key1: searchable value
        LobbyData:
          MyGameKey: MyGameKey value
        Members:
          - MemberEntity:
              Id: '1234'
              Type: title_player_account
              TypeString: title_player_account
    AccessPolicy:
      type: string
      enum:
        - Public
        - Friends
        - Private
    Member:
      type: object
      properties:
        MemberData:
          description: Key-value pairs specific to member.
          type: object
        MemberEntity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: The member entity key.
        PubSubConnectionHandle:
          description: >-
            Opaque string, stored on a Subscribe call, which indicates the
            connection an owner or member has with PubSub.
          type: string
    EntityKey:
      description: >-
        Combined entity type and ID structure which uniquely identifies a single
        entity.
      type: object
      properties:
        Id:
          description: Unique ID of the entity.
          type: string
        Type:
          description: >-
            Entity type. See
            https://learn.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types
          type: string
      required:
        - Id
    OwnerMigrationPolicy:
      type: string
      enum:
        - None
        - Automatic
        - Manual
        - Server
    CreateLobbyResult:
      type: object
      properties:
        ConnectionString:
          description: A field which indicates which lobby the user will be joining.
          type: string
        LobbyId:
          description: Id to uniquely identify a lobby.
          type: string
      required:
        - LobbyId
        - ConnectionString
    ApiErrorWrapper:
      description: The basic wrapper around every failed API response
      type: object
      properties:
        code:
          description: Numerical HTTP code
          type: integer
        status:
          description: String HTTP code
          type: string
        error:
          description: Playfab error code
          type: string
        errorCode:
          description: Numerical PlayFab error code
          type: integer
        errorMessage:
          description: Description for the PlayFab errorCode
          type: string
        errorDetails:
          description: Detailed description of individual issues with the request object
          type: object
      required:
        - code
        - errorCode
  responses:
    CreateLobbyResult:
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: >-
                  The Http status code. If X-ReportErrorAsSuccess header is set
                  to true, this will report the actual http error code.
              status:
                type: string
                description: The Http status code as a string.
              data:
                $ref: '#/components/schemas/CreateLobbyResult'
    ApiErrorWrapper:
      description: This is the outer wrapper for all responses with errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorWrapper'
  securitySchemes:
    EntityToken:
      type: apiKey
      in: header
      name: X-EntityToken
      description: >-
        This API requires an Entity Session Token, available from the Entity
        GetEntityToken method.

````

## Related topics

- [Create Lobby](/api-reference/lobby/create-lobby.md)
- [Create a lobby](/services/playfab/multiplayer/lobby/create-a-lobby.md)
- [Create searchable lobbies](/services/playfab/multiplayer/lobby/define-search-keywords.md)
- [LobbyCreateConfiguration](/services/playfab/multiplayer/lobby/unity-multiplayer-api-reference/PlayFab.Multiplayer/LobbyCreateConfiguration/LobbyCreateConfiguration.md)
- [PFLobbyCreateConfiguration](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pflobby/structs/pflobbycreateconfiguration.md)
