{
  "openapi": "3.1.0",
  "info": {
    "title": "TAVYNO Open API",
    "version": "1.0.0",
    "description": "Beschikbaarheid, reserveringen, gasten, kassabonnen, events, cadeaubonnen en webhooks per vestiging. Documentatie met voorbeelden: https://tavyno.nl/api-docs",
    "contact": {
      "name": "TAVYNO partners",
      "url": "https://tavyno.nl/partners",
      "email": "help@tavyno.nl"
    }
  },
  "servers": [
    {
      "url": "https://tavyno.nl/api/public/v1"
    }
  ],
  "tags": [
    {
      "name": "Vestiging",
      "description": "Elke sleutel hoort bij precies één vestiging. Alle endpoints werken automatisch binnen die vestiging; je hoeft geen venue_id mee te sturen."
    },
    {
      "name": "Beschikbaarheid",
      "description": "Vrije tijden per half uur, berekend uit de actieve tafels min overlappende reserveringen (standaard zitduur 120 minuten). Gesloten dagen geven een lege lijst."
    },
    {
      "name": "Reserveringen",
      "description": "Aanmaken controleert eerst de beschikbaarheid. Aanmaken en wijzigen sturen dezelfde ondertekende webhooks als de widget."
    },
    {
      "name": "Gasten",
      "description": "Gastprofielen van deze vestiging: contact, tags, dieet, allergieën, bezoeken, no-shows en besteding."
    },
    {
      "name": "Kassa & omzet",
      "description": "Stuur bonnen vanuit je eigen kassa. We koppelen de bon aan de reservering van dezelfde dag waarvan de starttijd binnen 45 minuten van het openen valt (bij gelijke kandidaten: dichtst bij het aantal couverts)."
    },
    {
      "name": "Groepen & MICE",
      "description": "Groeps- en zakelijke aanvragen komen als \"Aanvraag\" in de pijplijn Groepen & events. De zaak maakt daar de offerte (eventueel met de MICE-agent) en bevestigt zelf; via de API wordt nooit iets bevestigd."
    },
    {
      "name": "Cadeaubonnen",
      "description": "Saldo opvragen, afboeken en terugdraaien vanuit een kassa. Uitgebreide uitleg op /developers/giftcards."
    },
    {
      "name": "Webhooks",
      "description": "In TAVYNO stel je onder Koppelingen een https-adres in. Wij sturen een POST met JSON { event, sentAt, data }, ondertekend met HMAC-SHA256 in de header X-Tavyno-Signature. Gastgegevens zitten er niet in; haal die op via de API."
    }
  ],
  "paths": {
    "/venue": {
      "get": {
        "tags": [
          "Vestiging"
        ],
        "summary": "Welke vestiging hoort bij deze sleutel",
        "description": "Geeft id, naam, slug, stad en tijdzone terug. Handig als eerste test van je sleutel.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/availability": {
      "get": {
        "tags": [
          "Beschikbaarheid"
        ],
        "summary": "Vrije tijden voor een datum",
        "description": "Per tijdslot: time, available (genoeg plek voor party) en seats_left.",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "party",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/services": {
      "get": {
        "tags": [
          "Beschikbaarheid"
        ],
        "summary": "Services en tijdvensters",
        "description": "Lunch (vóór 15:00) en diner, slotinterval en standaard zitduur.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/reservations": {
      "post": {
        "tags": [
          "Reserveringen"
        ],
        "summary": "Reservering aanmaken",
        "description": "Bestaande gast wordt herkend op e-mail, anders aangemaakt. Geen plek: 409 NOT_AVAILABLE met alternatives. Met \"as_option\": true wordt het een optie die 24 uur geldig is.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Reserveringen"
        ],
        "summary": "Reserveringen van een dag",
        "description": "Optionele filters: status, guest_id. Maximaal 500 per dag.",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/reservations/{id}": {
      "get": {
        "tags": [
          "Reserveringen"
        ],
        "summary": "Eén reservering",
        "description": "Alle velden van de reservering.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Reserveringen"
        ],
        "summary": "Reservering wijzigen",
        "description": "date, time, party_size, duration_minutes, status (confirmed, arrived, seated, finished, noshow, option) of note. Nieuwe tijd of meer gasten wordt eerst op beschikbaarheid gecontroleerd.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Reserveringen"
        ],
        "summary": "Annuleren",
        "description": "Zet de status op cancelled en bewaart de reden intern.",
        "parameters": [
          {
            "name": "reason",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/guests": {
      "get": {
        "tags": [
          "Gasten"
        ],
        "summary": "Gasten zoeken",
        "description": "Zoekt in naam, e-mail en telefoon. Maximaal 200 resultaten.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/guests/{id}": {
      "get": {
        "tags": [
          "Gasten"
        ],
        "summary": "Gastprofiel",
        "description": "Profiel plus de laatste 50 reserveringen.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Gasten"
        ],
        "summary": "Gast bijwerken",
        "description": "tags, notes, marketing_opt_in, language, phone, diet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/pos/checks": {
      "post": {
        "tags": [
          "Kassa & omzet"
        ],
        "summary": "Bon aanleveren",
        "description": "external_id is je eigen bonnummer en maakt het verzoek idempotent: dezelfde bon nogmaals sturen geeft de eerste uitkomst terug met duplicate: true.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/pos/checks/{id}": {
      "get": {
        "tags": [
          "Kassa & omzet"
        ],
        "summary": "Bon opvragen",
        "description": "Inclusief gekoppelde reservering en matchmethode (of null als er geen match was).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/events/requests": {
      "post": {
        "tags": [
          "Groepen & MICE"
        ],
        "summary": "Groepsaanvraag indienen",
        "description": "Verplicht: contact, email, date, time, guests. Optioneel: company, phone, space, notes, external_id (maakt het verzoek idempotent).",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Groepen & MICE"
        ],
        "summary": "Aanvragen ophalen",
        "description": "Stage: enquiry, quote, contract, confirmed of lost. Inclusief offerteregels en de status van de verstuurde offerte (sent, accepted of declined) met link.",
        "parameters": [
          {
            "name": "stage",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/events/requests/{id}": {
      "get": {
        "tags": [
          "Groepen & MICE"
        ],
        "summary": "Eén aanvraag",
        "description": "Op TAVYNO-id of op je eigen external_id.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/giftcards/check": {
      "post": {
        "tags": [
          "Cadeaubonnen"
        ],
        "summary": "Saldo en status",
        "description": "Body { code }. Ook als GET /giftcards/{code}.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/giftcards/redeem": {
      "post": {
        "tags": [
          "Cadeaubonnen"
        ],
        "summary": "Afboeken",
        "description": "Body { code, amount, reference }. reference is uniek per kassatransactie; herhalen boekt niet dubbel af.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/giftcards/void": {
      "post": {
        "tags": [
          "Cadeaubonnen"
        ],
        "summary": "Afboeking terugdraaien",
        "description": "Body { reference }. Zet het bedrag terug op de bon.",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Ontbrekende of ongeldige API-sleutel"
          },
          "422": {
            "description": "Ongeldige invoer"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "webhooks": {
    "reservation.created": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Nieuwe reservering",
        "description": "Via widget, AI-assistent of de API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "sentAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Je endpoint bevestigt ontvangst met een 2xx-status."
          }
        }
      }
    },
    "reservation.updated": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Wijziging of annulering",
        "description": "Tijd, aantal gasten of status gewijzigd; bij annuleren is status cancelled.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "sentAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Je endpoint bevestigt ontvangst met een 2xx-status."
          }
        }
      }
    },
    "webhook.test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Testbericht",
        "description": "Vanuit de app te versturen om je endpoint te controleren.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "sentAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Je endpoint bevestigt ontvangst met een 2xx-status."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "tvn_<key>"
      }
    }
  }
}