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

> ## Agent Instructions
> Documentazione di Gestione Sala. Il testo completo, incluso il riferimento API, è in https://docs.gestionesala.com/llms-full.txt. Per endpoint, campi e codici di errore la fonte di verità è openapi.yaml: non usare endpoint o campi non documentati.

# Crea una prenotazione

> Scope: `reservations:write`



## OpenAPI

````yaml /openapi.yaml post /reservations
openapi: 3.1.0
info:
  title: Gestione Sala API
  version: 1.0.0
  description: >-
    Autenticazione: Authorization: Bearer <chiave>. Errori:
    {error:{code,message,details,requestId}}, anche per un percorso che non
    esiste (404 not_found); un metodo che il percorso non ha è un 405 della
    piattaforma, senza corpo. Risorsa singola: {nomeRisorsa: {...}}; lista
    d'attesa: entry. Elenchi: {data,nextCursor}, limit fino a 200. Intervalli di
    giorni: from/to. serviceDate YYYY-MM-DD e time HH:mm nell'ora del locale;
    startsAt/endsAt/updatedAt ISO 8601 UTC; timezone IANA. Un id di percorso
    storto è 404. Ogni risposta porta X-Request-Id; quelle con una chiave
    riconosciuta anche X-RateLimit-Limit/Remaining/Reset (per la chiave pubblica
    del widget, il tetto del tuo indirizzo IP); il 429 anche Retry-After.
    Idempotency-Key: legata a chiave API, operazione e corpo; riusata con un
    altro corpo è 422 idempotency_key_reused, ancora in corso 409
    idempotency_in_progress. Chiavi di prova (gsk_test_, organizzazione di
    prova): ogni risposta JSON porta livemode:false, nessun webhook, messaggio o
    sincronizzazione SQUADD parte. Chiave pubblica del widget (gspk_): solo GET
    /availability, /availability/slots, /availability/days e POST /reservations,
    dai siti ammessi (CORS, header Origin), con un limite per indirizzo IP;
    senza serviceTags né externalRef, e la prenotazione creata torna senza i
    dati dell'ospite. Altrove: 403 forbidden, details.reason publishable_key o
    origin_not_allowed.
servers:
  - url: https://app.gestionesala.com/api/v1
security: []
tags:
  - name: Meta
    description: Identità della chiave, stato del servizio e specifica OpenAPI
  - name: Locali
    description: Locali accessibili alla chiave e relativo `venueId`
  - name: Configurazione del locale
    description: Turni, chiusure, sale, tavoli, piante, regole e stato della sala
  - name: Disponibilità
    description: Disponibilità per orario, per giorno e su un intervallo di giorni
  - name: Prenotazioni
    description: Lettura, creazione, modifica e annullamento delle prenotazioni
  - name: Lista d'attesa
    description: Voci in attesa di un posto, richiamo e conversione in prenotazione
  - name: Ospiti
    description: Rubrica degli ospiti, ricerca per telefono e tag di servizio
  - name: Eventi e report
    description: Storico degli eventi, consuntivi ed export delle prenotazioni
  - name: Webhook
    description: >-
      Consegne, reinvio, evento di prova e rotazione del segreto di firma.
      Firma: X-Gestionesala-Signature = v1=HMAC-SHA256(segreto,
      "v1\n<timestamp>\n<idempotency-key>\n<corpo>"), con
      X-Gestionesala-Timestamp e X-Gestionesala-Idempotency-Key; in una
      rotazione due firme separate da virgola.
  - name: Import
    description: Import di ospiti e prenotazioni da un altro gestionale
paths:
  /reservations:
    post:
      tags:
        - Prenotazioni
      summary: Crea una prenotazione
      description: 'Scope: `reservations:write`'
      operationId: createReservation
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            La stessa chiave ripetuta ritrova la risorsa invece di crearne
            un'altra
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                venueId:
                  type: string
                  format: uuid
                serviceDate:
                  type: string
                  description: Giorno di servizio, YYYY-MM-DD
                  format: date
                time:
                  type: string
                  description: Ora locale del locale, HH:mm
                  pattern: ^([01]\d|2[0-3]):[0-5]\d$
                partySize:
                  type: integer
                  minimum: 1
                phone:
                  type: string
                  description: 'Telefono dell''ospite: lo riconosce o lo crea'
                guestName:
                  type: string
                  maxLength: 200
                email:
                  type: string
                  description: Solo con phone; riempie l'ospite se non l'ha già
                  format: email
                  maxLength: 254
                firstName:
                  type: string
                  description: Solo con phone; riempie l'ospite se non l'ha già
                  minLength: 1
                  maxLength: 100
                lastName:
                  type: string
                  description: Solo con phone; riempie l'ospite se non l'ha già
                  minLength: 1
                  maxLength: 100
                serviceTags:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    description: Nome di un tag del catalogo
                    minLength: 1
                    maxLength: 100
                  description: >-
                    Solo con phone: si aggiungono all'ospite; un nome fuori
                    catalogo è un 400
                notes:
                  type: string
                channel:
                  type: string
                  description: 'Da dove arriva, es. sito o Google: finisce in sourceDetail'
                  maxLength: 100
                externalRef:
                  type: string
                  description: Il tuo identificativo, unico nella tua organizzazione
                  maxLength: 200
              required:
                - venueId
                - serviceDate
                - time
                - partySize
      responses:
        '200':
          description: Già creata con la stessa Idempotency-Key
          content:
            application/json:
              schema:
                type: object
                properties:
                  reservation:
                    anyOf:
                      - $ref: '#/components/schemas/Reservation'
                      - $ref: '#/components/schemas/WidgetReservation'
                required:
                  - reservation
        '201':
          description: 'Creata (dalla chiave pubblica del widget: WidgetReservation)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  reservation:
                    anyOf:
                      - $ref: '#/components/schemas/Reservation'
                      - $ref: '#/components/schemas/WidgetReservation'
                required:
                  - reservation
        '400':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: unauthenticated, api_key_invalid, api_key_revoked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: forbidden, insufficient_scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: not_found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: no_availability, conflict, idempotency_in_progress
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: idempotency_key_reused
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: rate_limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
components:
  schemas:
    Reservation:
      type: object
      properties:
        id:
          type: string
          format: uuid
        venueId:
          type: string
          format: uuid
        serviceDate:
          type: string
          description: Giorno di servizio, YYYY-MM-DD
          format: date
        time:
          type: string
          description: Ora locale del locale, HH:mm
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
        startsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        endsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        partySize:
          type: integer
        status:
          type: string
          enum:
            - created
            - confirmed
            - arrived
            - seated
            - released
            - completed
            - no_show
            - cancelled
        tableAssigned:
          type: boolean
        needsAttention:
          type: boolean
          description: Valida, ma da sistemare in sala
        notes:
          anyOf:
            - type: string
            - type: 'null'
        source:
          type: string
          enum:
            - phone
            - voice_agent
            - floor
            - waitlist
            - walk_in
            - api
            - import
        sourceDetail:
          anyOf:
            - type: string
              description: Nome della chiave o channel
            - type: 'null'
        externalRef:
          anyOf:
            - type: string
            - type: 'null'
        guestId:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        updatedAt:
          type: string
          description: Anche la versione, per If-Match
          format: date-time
        guest:
          anyOf:
            - type: object
              properties:
                name:
                  anyOf:
                    - type: string
                    - type: 'null'
                allergies:
                  anyOf:
                    - type: string
                    - type: 'null'
                allergens:
                  type: array
                  items:
                    type: string
                    enum:
                      - gluten
                      - crustaceans
                      - eggs
                      - fish
                      - peanuts
                      - soybeans
                      - milk
                      - nuts
                      - celery
                      - mustard
                      - sesame
                      - sulphites
                      - lupin
                      - molluscs
              required:
                - name
                - allergies
                - allergens
            - type: 'null'
        guestDetails:
          anyOf:
            - $ref: '#/components/schemas/ReservationGuest'
            - type: 'null'
        table:
          anyOf:
            - $ref: '#/components/schemas/ReservationTable'
            - type: 'null'
      required:
        - id
        - venueId
        - serviceDate
        - time
        - startsAt
        - endsAt
        - partySize
        - status
        - tableAssigned
        - needsAttention
        - notes
        - source
        - sourceDetail
        - externalRef
        - guestId
        - updatedAt
        - guest
    WidgetReservation:
      type: object
      properties:
        id:
          type: string
          format: uuid
        venueId:
          type: string
          format: uuid
        serviceDate:
          type: string
          description: Giorno di servizio, YYYY-MM-DD
          format: date
        time:
          type: string
          description: Ora locale del locale, HH:mm
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
        startsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        endsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        partySize:
          type: integer
        status:
          type: string
          enum:
            - created
            - confirmed
            - arrived
            - seated
            - released
            - completed
            - no_show
            - cancelled
      required:
        - id
        - venueId
        - serviceDate
        - time
        - startsAt
        - endsAt
        - partySize
        - status
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Il codice su cui ramificare
            message:
              type: string
              description: Per chi legge i log
            details:
              type: object
              description: >-
                Cosa serve per correggere o riprovare: fields (i campi storti),
                requiredScope, reason; per no_availability anche alternatives,
                gli orari vicini nella forma di GET /availability
              properties:
                fields:
                  type: array
                  items:
                    type: string
                requiredScope:
                  type: string
                reason:
                  type: string
                alternatives:
                  type: array
                  items:
                    $ref: '#/components/schemas/Proposal'
            requestId:
              type: string
              description: Lo stesso valore dell'header X-Request-Id
          required:
            - code
            - message
            - details
      required:
        - error
    ReservationGuest:
      type: object
      properties:
        id:
          type: string
          format: uuid
        phone:
          type: string
          description: E.164
        email:
          anyOf:
            - type: string
            - type: 'null'
        firstName:
          anyOf:
            - type: string
            - type: 'null'
        lastName:
          anyOf:
            - type: string
            - type: 'null'
        name:
          anyOf:
            - type: string
            - type: 'null'
        allergies:
          anyOf:
            - type: string
            - type: 'null'
        allergens:
          type: array
          items:
            type: string
            enum:
              - gluten
              - crustaceans
              - eggs
              - fish
              - peanuts
              - soybeans
              - milk
              - nuts
              - celery
              - mustard
              - sesame
              - sulphites
              - lupin
              - molluscs
        notes:
          anyOf:
            - type: string
            - type: 'null'
        visitCount:
          type: integer
        noShowCount:
          type: integer
        externalRef:
          anyOf:
            - type: string
            - type: 'null'
        updatedAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
      required:
        - id
        - phone
        - email
        - firstName
        - lastName
        - name
        - allergies
        - allergens
        - notes
        - visitCount
        - noShowCount
        - externalRef
        - updatedAt
    ReservationTable:
      type: object
      properties:
        tableId:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        tableCombinationId:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        tables:
          type: array
          description: I tavoli occupati, uno per uno
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              name:
                type: string
              minSeats:
                type: integer
              maxSeats:
                type: integer
            required:
              - id
              - name
              - minSeats
              - maxSeats
      required:
        - tableId
        - tableCombinationId
        - tables
    Proposal:
      type: object
      properties:
        time:
          type: string
          description: Ora locale del locale, HH:mm
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
        startsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        endsAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        turnTimeMinutes:
          type: integer
        seats:
          type: integer
        overflowsShift:
          type: boolean
      required:
        - time
        - startsAt
        - endsAt
        - turnTimeMinutes
        - seats
        - overflowsShift
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: gsk_... | gsk_test_... | gspk_...

````