> ## 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 o aggiorna un ospite

> Scope: `guests:write`. Crea l'ospite o aggiorna quello con lo stesso telefono. Risponde 201 se l'ospite è nuovo, 200 se il telefono esiste già (i campi inviati vengono scritti) o se la stessa Idempotency-Key ritrova la richiesta precedente.



## OpenAPI

````yaml /openapi.yaml post /guests
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:
  /guests:
    post:
      tags:
        - Ospiti
      summary: Crea o aggiorna un ospite
      description: >-
        Scope: `guests:write`. Crea l'ospite o aggiorna quello con lo stesso
        telefono. Risponde 201 se l'ospite è nuovo, 200 se il telefono esiste
        già (i campi inviati vengono scritti) o se la stessa Idempotency-Key
        ritrova la richiesta precedente.
      operationId: upsertGuest
      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:
                phone:
                  type: string
                  description: 'Il telefono, qualunque forma: diventa E.164'
                name:
                  anyOf:
                    - type: string
                      description: Il nome come lo si chiama
                      maxLength: 200
                    - type: 'null'
                firstName:
                  anyOf:
                    - type: string
                      description: Nome
                      maxLength: 100
                    - type: 'null'
                lastName:
                  anyOf:
                    - type: string
                      description: Cognome
                      maxLength: 100
                    - type: 'null'
                email:
                  anyOf:
                    - type: string
                      description: Email
                      maxLength: 254
                    - type: 'null'
                allergies:
                  anyOf:
                    - type: string
                      description: Allergie
                      maxLength: 2000
                    - type: 'null'
                notes:
                  anyOf:
                    - type: string
                      description: Note
                      maxLength: 2000
                    - type: 'null'
                externalRef:
                  anyOf:
                    - type: string
                      description: Il tuo identificativo, unico nell'organizzazione
                      maxLength: 200
                    - type: 'null'
              required:
                - phone
      responses:
        '200':
          description: Aggiornato o ritrovato
          content:
            application/json:
              schema:
                type: object
                properties:
                  guest:
                    $ref: '#/components/schemas/Guest'
                required:
                  - guest
        '201':
          description: Creato
          content:
            application/json:
              schema:
                type: object
                properties:
                  guest:
                    $ref: '#/components/schemas/Guest'
                required:
                  - guest
        '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'
        '409':
          description: 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:
    Guest:
      type: object
      properties:
        id:
          type: string
          format: uuid
        phone:
          type: string
          description: E.164
        name:
          anyOf:
            - type: string
            - type: 'null'
        firstName:
          anyOf:
            - type: string
            - type: 'null'
        lastName:
          anyOf:
            - type: string
            - type: 'null'
        email:
          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
        cancelledCount:
          type: integer
        lastVisitAt:
          anyOf:
            - type: string
              description: Istante ISO 8601 con fuso
              format: date-time
            - type: 'null'
        consents:
          type: object
        campaignTags:
          type: array
          items:
            type: string
        serviceTags:
          type: array
          items:
            type: string
        externalRef:
          anyOf:
            - type: string
            - type: 'null'
        createdAt:
          type: string
          description: Istante ISO 8601 con fuso
          format: date-time
        updatedAt:
          type: string
          description: Anche la versione, per If-Match
          format: date-time
      required:
        - id
        - phone
        - name
        - firstName
        - lastName
        - email
        - allergies
        - allergens
        - notes
        - visitCount
        - noShowCount
        - cancelledCount
        - lastVisitAt
        - consents
        - campaignTags
        - serviceTags
        - externalRef
        - createdAt
        - updatedAt
    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
    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_...

````