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

# Book a seat for an event

> Creates a new booking (reservation) for a specific seat at a specific event.
This operation requires user authentication; the server automatically assigns the `user_id` from the authentication token.
The booking is created with an initial `is_paid: false` status.




## OpenAPI

````yaml api-reference/openapi.json post /api/bookings
openapi: 3.0.0
info:
  title: Tandem IT API
  version: 1.0.0
  description: API for tandem it backend
servers:
  - url: https://tandem.hlofiys.xyz
    description: Production server
security: []
tags:
  - name: Documentation
    description: API documentation endpoint
paths:
  /api/bookings:
    post:
      tags:
        - Bookings
      summary: Book a seat for an event
      description: >
        Creates a new booking (reservation) for a specific seat at a specific
        event.

        This operation requires user authentication; the server automatically
        assigns the `user_id` from the authentication token.

        The booking is created with an initial `is_paid: false` status.
      operationId: createBooking
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBookingRequest'
      responses:
        '201':
          description: Booking created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Booking'
        '400':
          description: >-
            Bad Request. The request body is malformed or missing required
            fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: >-
            Unauthorized. Authentication credentials were not provided or are
            invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found. The specified event_id or seat_id does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Conflict. The requested seat for this event has already been booked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error. An unexpected error occurred on the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    CreateBookingRequest:
      type: object
      required:
        - event_id
        - seat_ids
      properties:
        event_id:
          type: integer
          format: int64
          description: The unique identifier for the event
        seat_ids:
          type: array
          items:
            type: integer
            format: int64
          description: An array of unique identifiers for the seats to be booked.
          example:
            - 101
            - 102
            - 103
    Booking:
      type: object
      required:
        - booking_id
        - user_id
        - event_id
        - seat_id
        - is_paid
        - created_at
        - updated_at
      properties:
        booking_id:
          type: integer
          format: int64
        user_id:
          type: string
          format: uuid
        event_id:
          type: integer
          format: int64
        seat_id:
          type: integer
          format: int64
        is_paid:
          type: boolean
          description: >-
            Indicates whether the booking has been paid for. `false` for initial
            reservation
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ValidationError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: Validation failed
        errors:
          type: object
          description: A map of field names to their respective error messages.
          additionalProperties:
            type: string
          example:
            name: The name field is required.
            price: The price must be a valid number.
            hall_id: A valid hall_id is required.
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````