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

# Start the game

> **Host only.** Starts the game for the lobby. This triggers a three-step process:

1. Lobby status transitions to `starting`
2. A game server is provisioned (uses the build and compute size from the lobby config)
3. Lobby status transitions to `in_game` with server connection details

The response includes `server.ports` with host and port for game client connections. All players receive a `lobby_updated` event via SSE with the server details.

**Server provisioning** typically takes 10-30 seconds (or ~5 seconds with pool servers). The lobby stays in `starting` status until the server is ready.

If server provisioning fails, the lobby rolls back to `waiting` status.



## OpenAPI

````yaml https://api.computeflow.cloud/api/doc post /api/v3/lobbies/{config}/me/start
openapi: 3.1.0
info:
  title: PlayFlow API
  version: 3.0.0
  description: >
    PlayFlow is a game server hosting and orchestration platform. Deploy,
    manage, and scale multiplayer game servers globally with built-in
    matchmaking, lobby management, and billing.


    ## Authentication


    All API endpoints (except Health) require the `api-key` header:


    ```

    api-key: pf_your_project_api_key

    ```


    Find your API key in the PlayFlow dashboard under **Project Settings**. Each
    project has a server key (`pf_...`) for privileged operations and a client
    key (`pfclient_...`) for game client integrations. Both work in the
    `api-key` header.


    ## Quick Start


    1. **Upload a build**: `POST /v3/builds/upload-url` → get presigned URL →
    `PUT` your ZIP → processing starts automatically

    2. **Start a server**: `POST /v3/servers/start` → get connection info in
    `network_ports`

    3. **Connect your game client**: Use `host:external_port` from the response


    ## Key Concepts


    - **Builds**: Your game server binary packaged as a ZIP or Docker image.
    Versioned per name per project.

    - **Servers**: Running game server instances. Each gets dedicated compute
    and network ports with automatic health monitoring.

    - **Pool Servers**: Pre-provisioned servers for instant startup (~5s vs ~30s
    cold start).

    - **Regions**: 12 global regions (us-east, us-west, eu-north, eu-west,
    eu-uk, ap-south, sea, ap-north, ap-southeast, south-africa,
    south-america-brazil, south-america-chile).

    - **Compute Sizes**: From micro (512MB) to dedicated-xlarge (16GB dedicated
    CPU).


    ## Server Lifecycle


    `launching` → `running` (game ports open) → `stopped` (game exits, TTL
    expires, or manual stop)


    ## Build Lifecycle


    `uploading` → `processing` (build pipeline creates deployable image) →
    `ready` | `failed`


    ## Rate Limits


    - General reads: 100 req/sec per API key

    - Write operations (start server, upload build): 10 req/sec per API key

    - Headers: `X-RateLimit-Limit`, `X-RateLimit-Remaining`


    ## Plan Limits


    - **Free**: 1 server max, forced 1hr TTL, small size only

    - **Pro**: Unlimited servers, all sizes, custom TTL, pool servers


    ## Error Format


    All errors return: `{ "error": "message", "detail": "context", "status": 404
    }`
servers:
  - url: https://api.computeflow.cloud
security:
  - ApiKeyAuth: []
tags:
  - name: Servers
    description: >-
      Create, manage, and monitor game server instances. Each server gets
      dedicated compute, network ports, and automatic health monitoring with TTL
      enforcement. Servers start in `launching` status and transition to
      `running` when the game opens its ports.
  - name: Builds
    description: >-
      Upload and manage game server builds. Supports ZIP uploads (automatically
      processed into deployable images) and direct Docker image references.
      Builds are versioned per name per project — uploading a new build with the
      same name auto-increments the version. Servers always use the latest
      `ready` build unless a specific version is pinned.
  - name: Projects
    description: >-
      Configure project-level settings including network ports, player
      authentication, environment variables, server pooling, and
      lobby/matchmaking rules. Settings apply as defaults to all servers in the
      project and can be overridden per-server at start time.
  - name: Lobbies
    description: >-
      Player-centric lobby and matchmaking system. Every request identifies the
      player via the `x-player-id` header. Use `/me` endpoints to interact with
      your current lobby — the API resolves which lobby you're in automatically.


      **Quick start:** `POST /v3/lobbies/default` creates a lobby with sensible
      defaults (no dashboard config needed). Share the invite `code` with
      friends, or use `POST /v3/lobbies/default/me/matchmaking` to find
      opponents automatically.


      **Matchmaking** supports symmetric teams (2v2, 5v5), asymmetric roles (1
      monster vs 5 hunters), FFA, battle royale duos, and skill-based matching
      with auto-expanding MMR buckets.
paths:
  /api/v3/lobbies/{config}/me/start:
    post:
      tags:
        - Lobbies
      summary: Start the game
      description: >-
        **Host only.** Starts the game for the lobby. This triggers a three-step
        process:


        1. Lobby status transitions to `starting`

        2. A game server is provisioned (uses the build and compute size from
        the lobby config)

        3. Lobby status transitions to `in_game` with server connection details


        The response includes `server.ports` with host and port for game client
        connections. All players receive a `lobby_updated` event via SSE with
        the server details.


        **Server provisioning** typically takes 10-30 seconds (or ~5 seconds
        with pool servers). The lobby stays in `starting` status until the
        server is ready.


        If server provisioning fails, the lobby rolls back to `waiting` status.
      operationId: startGame
      parameters:
        - schema:
            type: string
            description: Lobby configuration name or ID.
          required: true
          description: Lobby configuration name or ID.
          name: config
          in: path
        - schema:
            type: string
            description: Unique player identifier. Must be the lobby host.
          required: true
          description: Unique player identifier. Must be the lobby host.
          name: x-player-id
          in: header
      responses:
        '200':
          description: >-
            Game started. The `server` field contains connection details
            (instanceId, ports). Status is `in_game`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Lobby ID.
                  code:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Invite code for joining (null if private mode is
                      disabled).
                  config:
                    type: string
                    description: Lobby config name.
                  status:
                    type: string
                    enum:
                      - waiting
                      - in_queue
                      - starting
                      - matched
                      - match_found
                      - in_game
                    description: Current lobby status.
                  host:
                    type: string
                    description: Player ID of the host.
                  maxPlayers:
                    type: number
                    description: Maximum player capacity.
                  currentPlayers:
                    type: number
                    description: Current number of players.
                  region:
                    type:
                      - string
                      - 'null'
                    description: Preferred game server region.
                  isPrivate:
                    type: boolean
                    description: Whether the lobby is hidden from browsing.
                  allowLateJoin:
                    type: boolean
                    description: Whether players can join mid-game.
                  settings:
                    type: object
                    additionalProperties: {}
                    description: Custom game settings.
                  players:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Player's unique identifier.
                        state:
                          type: object
                          additionalProperties: {}
                          description: >-
                            Player's custom state (ready, team, loadout, MMR,
                            etc.).
                        isHost:
                          type: boolean
                          description: True if this player is the lobby host.
                      required:
                        - id
                        - state
                        - isHost
                      description: A player in the lobby with their current state.
                    description: Players in the lobby with their state.
                  server:
                    type:
                      - object
                      - 'null'
                    properties:
                      instance_id:
                        type: string
                        description: >-
                          Unique identifier for this server instance (UUID). Use
                          this to reference the server in all other API calls.
                      name:
                        type: string
                        description: Display name of the server, as provided when starting.
                      status:
                        type: string
                        enum:
                          - launching
                          - running
                          - stopped
                        description: >-
                          Current server status. "launching": machine is being
                          created and game is starting up. "running": game is
                          ready and accepting connections. "stopped": server has
                          been shut down.
                      network_ports:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              description: >-
                                Port name matching the port_configs entry (e.g.,
                                "game_udp").
                            internal_port:
                              type: number
                              description: >-
                                Port number the game server listens on inside
                                the container.
                            external_port:
                              type: number
                              description: >-
                                Public port number that players connect to from
                                outside.
                            protocol:
                              type: string
                              enum:
                                - udp
                                - tcp
                              description: Network protocol for this port.
                            host:
                              type: string
                              description: >-
                                Hostname or IP address players connect to. For
                                UDP: a proxy IPv4 address. For TCP:
                                "connect.computeflow.cloud" (Fly.io L7 routing).
                            tls_enabled:
                              type: boolean
                              description: >-
                                Whether TLS termination is enabled for this port
                                (TCP only).
                          required:
                            - name
                            - internal_port
                            - external_port
                            - protocol
                            - host
                            - tls_enabled
                          description: >-
                            A network port mapping showing how external traffic
                            reaches your game server. Use host:external_port as
                            the connection address for game clients.
                        description: >-
                          List of allocated network ports with connection
                          details. Give host:external_port to game clients for
                          connecting. Empty if the server has stopped.
                      startup_args:
                        type:
                          - string
                          - 'null'
                        description: >-
                          Command-line arguments passed to the game executable.
                          Null if none were provided.
                      service_type:
                        type: string
                        enum:
                          - match_based
                          - persistent_world
                        description: >-
                          Server type. "match_based" (default): short-lived
                          servers for individual matches. "persistent_world":
                          long-running servers for persistent game worlds.
                      compute_size:
                        type: string
                        description: >-
                          Machine size this server is running on (e.g., "small",
                          "medium", "dedicated-large").
                      region:
                        type: string
                        description: >-
                          Region where this server is deployed (e.g., "us-east",
                          "eu-west").
                      version_tag:
                        type: string
                        description: >-
                          Build name this server was started with (e.g.,
                          "default", "beta").
                      version:
                        type:
                          - number
                          - 'null'
                        description: >-
                          Build version number this server is running. Null if
                          no specific version was resolved.
                      started_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                        description: >-
                          ISO 8601 timestamp when the server transitioned to
                          "running" status (game ports opened). Null if still
                          launching or never reached running state.
                      stopped_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                        description: >-
                          ISO 8601 timestamp when the server was stopped. Null
                          if the server is still active.
                      auto_restart:
                        type: boolean
                        description: >-
                          Whether the game process auto-restarts on crash (max
                          10 retries).
                      custom_data:
                        type:
                          - object
                          - 'null'
                        additionalProperties: {}
                        description: >-
                          Arbitrary metadata attached to this server. Null if no
                          custom data was provided.
                      ttl:
                        type:
                          - number
                          - 'null'
                        description: >-
                          Time-to-live in seconds. The server auto-stops after
                          this duration from start. Null if no TTL was set
                          (server runs until explicitly stopped).
                      is_pool_server:
                        type: boolean
                        description: >-
                          Whether this server was claimed from the
                          pre-provisioned pool. Pool servers have faster startup
                          times (~5s vs ~30s).
                      pool_claimed_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                        description: >-
                          ISO 8601 timestamp when this pool server was claimed
                          for use. Null for non-pool servers or unclaimed pool
                          machines.
                      match_id:
                        type:
                          - string
                          - 'null'
                        description: >-
                          Match identifier for matchmaking integration.
                          Auto-generated if not provided at start time.
                      created_at:
                        type: string
                        format: date-time
                        description: >-
                          ISO 8601 timestamp when the server instance was
                          created in the database.
                      updated_at:
                        type: string
                        format: date-time
                        description: >-
                          ISO 8601 timestamp of the last update to this server
                          record.
                    required:
                      - instance_id
                      - name
                      - status
                      - network_ports
                      - startup_args
                      - service_type
                      - compute_size
                      - region
                      - version_tag
                      - version
                      - started_at
                      - stopped_at
                      - auto_restart
                      - custom_data
                      - ttl
                      - is_pool_server
                      - pool_claimed_at
                      - match_id
                      - created_at
                      - updated_at
                    description: Game server info (null when no game running).
                  matchmaking:
                    type:
                      - object
                      - 'null'
                    properties:
                      mode:
                        type: string
                        description: Active matchmaking mode name.
                      startedAt:
                        type: string
                        description: ISO 8601 timestamp when matchmaking started.
                      queueStats:
                        type:
                          - object
                          - 'null'
                        properties:
                          playersSearching:
                            type: number
                            description: >-
                              Total players currently in the matchmaking queue
                              for this mode.
                          lobbiesInQueue:
                            type: number
                            description: Number of lobbies waiting for a match.
                          avgWaitSeconds:
                            type: number
                            description: >-
                              Average wait time in seconds for lobbies currently
                              in queue.
                        required:
                          - playersSearching
                          - lobbiesInQueue
                          - avgWaitSeconds
                        description: Live queue stats. Updated via SSE while searching.
                      confirmation:
                        type:
                          - object
                          - 'null'
                        properties:
                          deadline:
                            type: string
                            description: >-
                              ISO 8601 deadline. The match cancels if any lobby
                              hasn't confirmed by then.
                          confirmed:
                            type: boolean
                            description: True if THIS lobby has confirmed.
                        required:
                          - deadline
                          - confirmed
                        description: >-
                          Set when status=match_found and players are
                          accepting/declining.
                    required:
                      - mode
                      - startedAt
                      - queueStats
                      - confirmation
                    description: Matchmaking info (null when not searching).
                  createdAt:
                    type: string
                    description: ISO 8601 creation timestamp.
                  updatedAt:
                    type: string
                    description: ISO 8601 last update timestamp.
                required:
                  - id
                  - code
                  - config
                  - status
                  - host
                  - maxPlayers
                  - currentPlayers
                  - region
                  - isPrivate
                  - allowLateJoin
                  - settings
                  - players
                  - server
                  - matchmaking
                  - createdAt
                  - updatedAt
                description: >-
                  Full lobby state including players, server, and matchmaking
                  info.
        '400':
          description: Missing x-player-id header or invalid lobby state for starting.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Human-readable error message describing what went wrong.
                  detail:
                    type: string
                    description: >-
                      Additional error context. May contain the same text as
                      error or more specific technical details.
                  status:
                    type: number
                    description: HTTP status code (matches the response status code).
                required:
                  - error
                  - status
                description: >-
                  Standard error response returned by all API endpoints on
                  failure.
        '403':
          description: Only the host can start the game.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Human-readable error message describing what went wrong.
                  detail:
                    type: string
                    description: >-
                      Additional error context. May contain the same text as
                      error or more specific technical details.
                  status:
                    type: number
                    description: HTTP status code (matches the response status code).
                required:
                  - error
                  - status
                description: >-
                  Standard error response returned by all API endpoints on
                  failure.
        '404':
          description: You are not in a lobby.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Human-readable error message describing what went wrong.
                  detail:
                    type: string
                    description: >-
                      Additional error context. May contain the same text as
                      error or more specific technical details.
                  status:
                    type: number
                    description: HTTP status code (matches the response status code).
                required:
                  - error
                  - status
                description: >-
                  Standard error response returned by all API endpoints on
                  failure.
        '409':
          description: Game is already running or lobby is in an incompatible state.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Human-readable error message describing what went wrong.
                  detail:
                    type: string
                    description: >-
                      Additional error context. May contain the same text as
                      error or more specific technical details.
                  status:
                    type: number
                    description: HTTP status code (matches the response status code).
                required:
                  - error
                  - status
                description: >-
                  Standard error response returned by all API endpoints on
                  failure.
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

````