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

# Create a game with its teams and players

> Creates a game, its teams and each team's players in one request. The game type is chosen by `dll_name`.
Teams are numbered from 0 in the order given, and players are sequenced from 0 within their team.
A player's `ratings` is present only when the player has a rating from a game that has ended.

**Who can call it:** Manager, Host, Venue Admin, Brand Admin or Organization Admin with access to the venue. Also the machine key.



## OpenAPI

````yaml /openapi.yaml post /games/with-teams
openapi: 3.1.0
info:
  description: >-
    Authenticated endpoints need a bearer token: `Authorization: Bearer
    <token>`.

    Each endpoint says whether it needs one. Public endpoints need none.

    A person sends the token they signed in with. A machine, such as a Billy Q
    box, sends its machine key the same way.

    Each endpoint ends with who can call it, and "Who can call what" lists every
    endpoint against every role.


    Every response is wrapped the same way: `status` is always present
    (`success` or `error`),

    `message` carries text that is safe to show a user, and `data` holds the
    payload on success.

    One exception: a 410 for a session that has ended carries the status
    `ended`.


    Money is in minor units (pence). Timestamps are RFC 3339 in UTC. Dates are
    `YYYY-MM-DD`.
  title: CueBridge API
  version: 0.1.0
servers:
  - description: Pre-production
    url: https://api.preprod.poolhouse.dev/api
security: []
tags:
  - description: Confirmed bookings at a venue.
    name: Bookings
  - description: A booking's time at its tables, from check-in to the end of play.
    name: Sessions
  - description: The players checked in to a session.
    name: Session players
  - description: Games played during a session, and the game types a venue offers.
    name: Games
  - description: Shots recorded during a game, and the ratings derived from them.
    name: Game shots
  - description: Per-player statistics and the stat types they are measured in.
    name: Stats
  - description: A venue's pool tables.
    name: Pool tables
  - description: The items placed on a venue's floor plan.
    name: Floor plan
  - description: Achievements players have earned.
    name: Achievements
paths:
  /games/with-teams:
    post:
      tags:
        - Games
      summary: Create a game with its teams and players
      description: >-
        Creates a game, its teams and each team's players in one request. The
        game type is chosen by `dll_name`.

        Teams are numbered from 0 in the order given, and players are sequenced
        from 0 within their team.

        A player's `ratings` is present only when the player has a rating from a
        game that has ended.


        **Who can call it:** Manager, Host, Venue Admin, Brand Admin or
        Organization Admin with access to the venue. Also the machine key.
      operationId: createGameWithTeams
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/models.GameWithTeamsCreateParams'
        description: The game, its teams and their players
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/api.ResponseOf-models_GameWithTeamsResponse
          description: The created game with its teams and players.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.Response'
          description: >-
            The body is not valid JSON, `session_table_id` or a
            `session_player_id` is missing or not a UUID, `dll_name` is missing,
            or a team has no `name` or no `color`.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.Response'
          description: The bearer token is missing, invalid or expired.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.Response'
          description: The caller may not create games at this venue.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.Response'
          description: >-
            No session table has the id given in `session_table_id`, no game
            type has the name given in `dll_name`, or a `session_player_id`
            matches no session player.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api.Response'
          description: Something went wrong on our side.
      security:
        - BearerAuth: []
components:
  schemas:
    models.GameWithTeamsCreateParams:
      properties:
        dll_name:
          type: string
        session_table_id:
          format: uuid
          type: string
        teams:
          items:
            $ref: '#/components/schemas/models.GameWithTeamsTeamParams'
          type: array
      required:
        - dll_name
        - session_table_id
      type: object
    api.ResponseOf-models_GameWithTeamsResponse:
      properties:
        data:
          allOf:
            - $ref: '#/components/schemas/models.GameWithTeamsResponse'
          description: The payload. Left out when there is none.
        message:
          description: Text that is safe to show a user. Left out when there is none.
          type: string
        status:
          allOf:
            - $ref: '#/components/schemas/api.Status'
          description: >-
            `success` or `error`. A 410 for a session that has ended says
            `ended` instead.
      type: object
    api.Response:
      properties:
        data:
          description: The payload. Left out when there is none.
        message:
          description: Text that is safe to show a user. Left out when there is none.
          type: string
        status:
          allOf:
            - $ref: '#/components/schemas/api.Status'
          description: >-
            `success` or `error`. A 410 for a session that has ended says
            `ended` instead.
      type: object
    models.GameWithTeamsTeamParams:
      properties:
        color:
          description: The team's colour, as a number. 0 is refused.
          type: integer
        name:
          type: string
        players:
          items:
            $ref: '#/components/schemas/models.GameWithTeamsPlayerParams'
          type: array
      required:
        - color
        - name
      type: object
    models.GameWithTeamsResponse:
      properties:
        ended_at:
          format: date-time
          type:
            - string
            - 'null'
        game_data_s3_key:
          description: >-
            The S3 key under which the game's data is stored. The data itself is
            not returned.
          type: string
        game_type_id:
          format: uuid
          type: string
        id:
          format: uuid
          type: string
        session_table_id:
          format: uuid
          type: string
        started_at:
          format: date-time
          type:
            - string
            - 'null'
        teams:
          items:
            $ref: '#/components/schemas/models.GameWithTeamsTeamResponse'
          type: array
      type: object
    api.Status:
      enum:
        - success
        - error
        - ended
      type: string
      x-enum-varnames:
        - StatusSuccess
        - StatusError
        - StatusEnded
    models.GameWithTeamsPlayerParams:
      properties:
        session_player_id:
          format: uuid
          type: string
      required:
        - session_player_id
      type: object
    models.GameWithTeamsTeamResponse:
      properties:
        color:
          type: integer
        game_id:
          format: uuid
          type: string
        id:
          format: uuid
          type: string
        name:
          type: string
        number:
          type: integer
        players:
          items:
            $ref: '#/components/schemas/models.GameWithTeamsPlayerResponse'
          type: array
      type: object
    models.GameWithTeamsPlayerResponse:
      properties:
        id:
          format: uuid
          type: string
        ratings:
          $ref: '#/components/schemas/models.PlayerRatings'
        sequence:
          type: integer
        session_player_id:
          format: uuid
          type: string
        team_id:
          format: uuid
          type: string
        user_id:
          format: uuid
          type: string
      type: object
    models.PlayerRatings:
      properties:
        latest:
          $ref: '#/components/schemas/models.RatingSnapshot'
        previous:
          $ref: '#/components/schemas/models.RatingSnapshot'
      type: object
    models.RatingSnapshot:
      properties:
        game_id:
          format: uuid
          type: string
        rating:
          type: number
        shots_played:
          type: integer
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.