openapi: 3.1.1
info:
  title: Ribba API
  version: 0.1.0
  description: Server-to-server API voor deelnemende rijscholen. Een sleutel geeft toegang binnen één rijschool en omgeving.
servers:
- url: https://api.ribba.nl/v1
  description: Productiepilot voor deelnemende rijscholen
- url: https://sandbox.ribba.example/v1
  description: Fictieve sandbox
security:
- SchoolKey: []
paths:
  /me:
    get:
      operationId: getIdentity
      x-overview: Controleer bij welke rijschool, omgeving en toegangsrechten je API-sleutel hoort.
      tags:
      - Toegang
      summary: Controleer de sleutel en de school
      description: Iedere actieve schoolintegratie heeft toegang tot de eigen identiteit.
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Identity'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /students:
    get:
      operationId: listStudents
      x-overview: Haal de leerlingdossiers van je rijschool pagina voor pagina op.
      tags:
      - Leerlingen
      summary: Blader door leerlingen
      description: 'Vereiste scope: students:read. Gesorteerd op stabiele ID. Geeft alleen de basisvelden van zichtbare schooldossiers.
        Na overdracht staan meeverhuisde leerlingen in de lijst van de ontvangende school.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StudentPage'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
      parameters:
      - name: limit
        in: query
        required: false
        description: Aantal resultaten per pagina.
        schema:
          type: integer
          default: 50
          minimum: 1
          maximum: 100
      - name: cursor
        in: query
        required: false
        description: Ondoorzichtige next_cursor uit de vorige pagina. Gebruik dezelfde filters.
        schema:
          type: string
          minLength: 1
    post:
      operationId: createStudent
      x-overview: Maak een actief leerlingdossier aan of voeg een leerling toe aan de wachtlijst.
      tags:
      - Leerlingen
      summary: Maak een leerlingdossier aan
      description: 'Vereiste scope: students:manage. De toegewezen instructeur moet actief zijn bij dezelfde rijschool. Het
        dossier start met rijbewijscategorie B en heeft nog geen appaccount. Active gebruikt een plek binnen de leerlinglimiet.
        Waitlist zet de leerling op de wachtlijst.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Student'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              first_name: Noor
              last_name: Jansen
              instructor_id: 00000000-0000-4000-8000-000000000012
              status: waitlist
            schema:
              additionalProperties: false
              type: object
              required:
              - first_name
              - last_name
              - instructor_id
              properties:
                first_name:
                  type: string
                  minLength: 1
                  maxLength: 120
                last_name:
                  type: string
                  minLength: 1
                  maxLength: 120
                instructor_id:
                  type: string
                  format: uuid
                status:
                  type: string
                  default: active
                  enum:
                  - active
                  - waitlist
  /students/{student_id}:
    parameters:
    - name: student_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    get:
      operationId: getStudent
      x-overview: Lees het leerlingdossier dat bij een specifiek leerling-ID hoort.
      tags:
      - Leerlingen
      summary: Haal één leerling op
      description: 'Vereiste scope: students:read.
        Het leerling-ID blijft gelijk. Na overdracht krijgt de ontvangende school toegang en geeft deze route voor de vorige school 404.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Student'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '404':
          $ref: '#/components/responses/E404'
    patch:
      operationId: updateStudentProfile
      x-overview: Pas de naam, het telefoonnummer, het adres of de geboortedatum van een leerling aan.
      tags: [Leerlingen]
      summary: Wijzig de profielgegevens van een leerling
      description: 'Vereiste scope: students:write. Alleen meegegeven velden veranderen. Gebruik null om een optioneel veld te wissen.'
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        description: Hergebruik dezelfde sleutel en inhoud bij een retry binnen 24 uur.
        schema: { type: string, minLength: 8, maxLength: 128 }
      requestBody:
        required: true
        content:
          application/json:
            example: { first_name: Sam, city: Rotterdam }
            schema:
              type: object
              minProperties: 1
              additionalProperties: false
              properties:
                first_name: { type: string, minLength: 1, maxLength: 120 }
                last_name: { type: string, minLength: 1, maxLength: 120 }
                phone: { type: [string, 'null'], minLength: 1, maxLength: 64 }
                address: { type: [string, 'null'], minLength: 1, maxLength: 250 }
                postal_code: { type: [string, 'null'], minLength: 1, maxLength: 24 }
                city: { type: [string, 'null'], minLength: 1, maxLength: 120 }
                date_of_birth: { type: [string, 'null'], format: date }
      responses:
        '200':
          description: Profiel opgeslagen.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Student'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '409':
          $ref: '#/components/responses/E409'
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    delete:
      operationId: archiveStudent
      x-overview: Zet een leerling op inactief en behoud het dossier en de lesgeschiedenis.
      tags:
      - Leerlingen
      summary: Archiveer een leerling
      description: 'Vereiste scope: students:manage. Zet de leerling op inactief. Het dossier en de lesgeschiedenis blijven
        bewaard.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /lessons:
    get:
      operationId: listLessons
      x-overview: Haal lessen uit de agenda van je rijschool op voor een gekozen periode.
      tags:
      - Lessen
      summary: Synchroniseer de schoolagenda
      description: 'Vereiste scope: lessons:read. Beide datumgrenzen zijn optioneel. Sorteert op stabiele ID; een cursor geeft
        geen historische snapshot.
        De ontvangende school kan ook lessen van vóór de overdracht opvragen.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LessonPage'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
      parameters:
      - name: limit
        in: query
        required: false
        description: Aantal resultaten per pagina.
        schema:
          type: integer
          default: 50
          minimum: 1
          maximum: 100
      - name: cursor
        in: query
        required: false
        description: Ondoorzichtige next_cursor uit de vorige pagina. Gebruik dezelfde filters.
        schema:
          type: string
          minLength: 1
      - name: from
        in: query
        required: false
        description: Eerste lokale lesdatum, inclusief.
        schema:
          type: string
          format: date
      - name: until
        in: query
        required: false
        description: Laatste lokale lesdatum, exclusief.
        schema:
          type: string
          format: date
    post:
      operationId: createLesson
      x-overview: Boek een les voor een leerling met een instructeur, voertuig en lesdienst.
      tags:
      - Lessen
      summary: Plan een les
      description: 'Vereiste scope: lessons:write. Kies een leerling, instructeur, actief voertuig en actieve lesdienst van
        de school. De instructeur moet de lesdienst mogen geven. Ribba controleert bezetting en past de tegoedinstelling
        van de school toe.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Lesson'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              student_id: 00000000-0000-4000-8000-000000000011
              instructor_id: 00000000-0000-4000-8000-000000000012
              vehicle_id: 00000000-0000-4000-8000-000000000060
              lesson_type_id: 00000000-0000-4000-8000-000000000061
              local_date: '2030-01-15'
              start_time: '10:00'
              end_time: '11:00'
            schema:
              additionalProperties: false
              type: object
              required:
              - student_id
              - instructor_id
              - vehicle_id
              - lesson_type_id
              - local_date
              - start_time
              - end_time
              properties:
                student_id:
                  type: string
                  format: uuid
                instructor_id:
                  type: string
                  format: uuid
                vehicle_id:
                  type: string
                  format: uuid
                lesson_type_id:
                  type: string
                  format: uuid
                local_date:
                  type: string
                  format: date
                start_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
                end_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
                location:
                  type: string
                  maxLength: 250
  /lessons/{lesson_id}:
    parameters:
    - name: lesson_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    get:
      operationId: getLesson
      x-overview: Bekijk de planning en status van één les.
      tags:
      - Lessen
      summary: Haal de actuele les op
      description: 'Vereiste scope: lessons:read.
        Bij overdracht van de leerling blijft het les-ID gelijk. De ontvangende school kan ook eerdere lessen lezen. De vorige school krijgt voor deze les 404.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Lesson'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '404':
          $ref: '#/components/responses/E404'
    patch:
      operationId: rescheduleLesson
      x-overview: Verplaats een geplande les naar een ander tijdstip met dezelfde lesduur.
      tags:
      - Lessen
      summary: Verplaats een geplande les
      description: 'Vereiste scope: lessons:write. Verplaats een geplande les met dezelfde duur, instructeur en leerling.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              local_date: '2030-01-15'
              start_time: '10:00'
              end_time: '11:00'
            schema:
              additionalProperties: false
              type: object
              required:
              - local_date
              - start_time
              - end_time
              properties:
                local_date:
                  type: string
                  format: date
                start_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
                end_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
  /lessons/{lesson_id}/cancel:
    parameters:
    - name: lesson_id
      in: path
      description: ID van de geplande les.
      schema:
        type: string
        format: uuid
      required: true
    post:
      operationId: cancelLesson
      x-overview: Annuleer een les en leg vast wat er met het tegoed en het tijdslot gebeurt.
      tags:
      - Lessen
      summary: Annuleer een geplande les
      description: 'Vereiste scope: lessons:write. Kies refund voor teruggave van tegoed, charge voor inhouding of none
        om het tegoed ongemoeid te laten. Geef apart aan of het tijdslot bezet moet blijven.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              reason: Leerling verhinderd
              credit_action: refund
              keep_in_calendar: false
            schema:
              additionalProperties: false
              type: object
              required:
              - reason
              - credit_action
              - keep_in_calendar
              properties:
                reason:
                  type: string
                  minLength: 1
                  maxLength: 250
                credit_action:
                  type: string
                  enum:
                  - refund
                  - charge
                  - none
                keep_in_calendar:
                  type: boolean
  /vehicles:
    get:
      operationId: listVehicles
      x-overview: Haal de actieve lesvoertuigen van je rijschool op.
      tags:
      - Planning
      summary: Lees actieve voertuigen
      description: 'Vereiste scope: lessons:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Vehicle'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /lesson-types:
    get:
      operationId: listLessonTypes
      x-overview: Bekijk de actieve lesdiensten en hun standaardduur.
      tags:
      - Planning
      summary: Lees actieve lesdiensten
      description: 'Vereiste scope: lessons:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LessonType'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /instructors/{instructor_id}/busy-times:
    parameters:
    - name: instructor_id
      in: path
      description: ID van de instructeur.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getInstructorBusyTimes
      x-overview: Bekijk op welke tijden een instructeur op een bepaalde datum bezet is.
      tags:
      - Planning
      summary: Lees de bezette tijden van een instructeur
      description: 'Vereiste scope: lessons:read. De tijden zijn een momentopname in Europe/Amsterdam.'
      parameters:
      - name: date
        in: query
        description: Lokale datum waarop je bezetting wilt zien.
        schema:
          type: string
          format: date
        required: true
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BusyTimes'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /invoices/{invoice_id}/send:
    parameters:
    - name: invoice_id
      in: path
      description: ID van de conceptfactuur.
      schema:
        type: string
        format: uuid
      required: true
    post:
      operationId: scheduleInvoice
      x-overview: Zet een conceptfactuur klaar voor de verzendronde vanaf een gekozen datum.
      tags:
      - Facturen
      summary: Plan de verzending van een conceptfactuur
      description: 'Vereiste scope: invoices:issue. De bestaande factuurronde verwerkt geldige concepten vanaf deze datum
        en kiest de ingestelde factuuraanbieder. Een 202 bevestigt de planning. Lees vervolgens de factuurstatus en eventuele
        betaallink.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '202':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceSendSchedule'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              send_on: '2030-01-15'
            schema:
              additionalProperties: false
              type: object
              required:
              - send_on
              properties:
                send_on:
                  type: string
                  format: date
  /instructors:
    get:
      operationId: listInstructors
      x-overview: Haal het overzicht van instructeurs van je rijschool op.
      tags:
      - Instructeurs
      summary: Toon instructeurs
      description: 'Vereiste scope: instructors:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Instructor'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /instructors/{instructor_id}:
    parameters:
    - name: instructor_id
      in: path
      description: ID van het record.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getInstructor
      x-overview: Bekijk de naam en status van één instructeur.
      tags:
      - Instructeurs
      summary: Lees één record voor instructeurs
      description: 'Vereiste scope: instructors:read.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Instructor'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    patch:
      operationId: updateInstructorVehicle
      x-overview: Kies of wis het standaardvoertuig van een instructeur.
      tags:
      - Instructeurs
      summary: Stel het standaardvoertuig van een instructeur in
      description: 'Vereiste scope: instructors:manage. Kies een actief voertuig van dezelfde school of geef null mee om
        de voorkeur te wissen.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              default_vehicle_id: 00000000-0000-4000-8000-000000000060
            schema:
              additionalProperties: false
              type: object
              required:
              - default_vehicle_id
              properties:
                default_vehicle_id:
                  type:
                  - string
                  - 'null'
                  format: uuid
  /instructor-invitations:
    get:
      operationId: listInstructorInvites
      x-overview: Bekijk welke uitnodigingen nog geldig zijn en wie ze kan inwisselen.
      tags:
      - Instructeurs
      summary: Bekijk openstaande instructeuruitnodigingen
      description: 'Vereiste scope: instructors:manage. Haal de niet-verlopen en ongebruikte uitnodigingen op, inclusief
        ontvanger en verloopdatum.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/InstructorInvite'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    post:
      operationId: createInstructorInvite
      x-overview: Maak een eenmalige uitnodigingslink voor een collega-instructeur.
      tags:
      - Instructeurs
      summary: Maak een uitnodiging voor een instructeur
      description: 'Vereiste scope: instructors:manage. Maak een eenmalige uitnodiging voor de rol medewerker. De uitnodiging
        verloopt na 30 dagen. Geef de geretourneerde privélink zelf door. Ribba controleert de teamlimiet.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InstructorInviteLink'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              email: instructeur@example.com
            schema:
              additionalProperties: false
              type: object
              required:
              - email
              properties:
                email:
                  type: string
                  format: email
                  maxLength: 254
  /instructor-invitations/{invitation_id}:
    parameters:
    - name: invitation_id
      in: path
      description: ID van de uitnodiging.
      schema:
        type: string
        format: uuid
      required: true
    delete:
      operationId: revokeInstructorInvite
      x-overview: Maak een ongebruikte uitnodigingslink ongeldig.
      tags:
      - Instructeurs
      summary: Trek een instructeuruitnodiging in
      description: 'Vereiste scope: instructors:manage. Trek een ongebruikte uitnodiging in zodat de link niet meer kan
        worden ingewisseld.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /lesson-reservations:
    get:
      operationId: listReservations
      x-overview: Lees de lesaanvragen van je rijschool, eventueel binnen een gekozen periode.
      tags:
      - Reserveringen
      summary: Toon lesaanvragen
      description: 'Vereiste scope: reservations:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      - name: from
        in: query
        description: Eerste lokale datum, inclusief.
        schema:
          type: string
          format: date
      - name: until
        in: query
        description: Laatste lokale grensdatum, exclusief.
        schema:
          type: string
          format: date
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Reservation'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    post:
      operationId: createReservation
      x-overview: Dien voor een leerling een aanvraag voor een praktijkles in.
      tags:
      - Reserveringen
      summary: Maak een lesaanvraag aan
      description: 'Vereiste scope: reservations:manage. Zet een aanvraag voor een praktijkles klaar ter beoordeling. Ribba
        controleert de actieve leerling, instructeur, bezetting en de aanvraaggrenzen van de rijschool.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Reservation'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              student_id: 00000000-0000-4000-8000-000000000011
              instructor_id: 00000000-0000-4000-8000-000000000012
              local_date: '2026-12-02'
              start_time: '13:00'
              end_time: '14:00'
            schema:
              additionalProperties: false
              type: object
              required:
              - student_id
              - instructor_id
              - local_date
              - start_time
              - end_time
              properties:
                student_id:
                  type: string
                  format: uuid
                instructor_id:
                  type: string
                  format: uuid
                local_date:
                  type: string
                  format: date
                start_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
                end_time:
                  type: string
                  pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
  /lesson-reservations/{reservation_id}:
    parameters:
    - name: reservation_id
      in: path
      description: ID van het record.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getReservation
      x-overview: Bekijk het aangevraagde tijdstip en de status van één lesaanvraag.
      tags:
      - Reserveringen
      summary: Lees één record voor lesaanvragen
      description: 'Vereiste scope: reservations:read.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Reservation'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    patch:
      operationId: decideReservation
      x-overview: Bevestig of weiger een openstaande lesaanvraag.
      tags:
      - Reserveringen
      summary: Bevestig of wijs een lesaanvraag af
      description: 'Vereiste scope: reservations:write. Bevestiging maakt een les aan via de bestaande reserveringsregels.
        Een beslissing wordt alleen op een openstaande aanvraag toegepast.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: Het verzoek conflicteert met een eerdere beslissing, bezetting of de tegoedregels van de school.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              decision: confirmed
            schema:
              type: object
              additionalProperties: false
              required:
              - decision
              properties:
                decision:
                  type: string
                  enum:
                  - confirmed
                  - rejected
                notes:
                  type: string
                  maxLength: 500
    delete:
      operationId: cancelReservation
      x-overview: Haal een openstaande lesaanvraag uit de planning.
      tags:
      - Reserveringen
      summary: Annuleer een lesaanvraag
      description: 'Vereiste scope: reservations:manage. Annuleer een openstaande aanvraag. Gebruik het lesendpoint voor
        een bevestigde les.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /students/{student_id}/shop-items:
    parameters:
    - name: student_id
      in: path
      description: ID van de actieve leerling.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: listShopItems
      x-overview: Bekijk welke pakketten, producten en lesdiensten een leerling kan bestellen.
      tags:
      - Winkelbestellingen
      summary: Bekijk artikelen voor een leerling
      description: 'Vereiste scope: shop:read. Haal de beschikbare pakketten, producten en lesdiensten van de leerlingwinkel
        op.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ShopItem'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /shop-orders:
    get:
      operationId: listShopOrders
      x-overview: Bekijk alle winkelbestellingen van je rijschool met de status van hun eerste factuur.
      tags:
      - Winkelbestellingen
      summary: Lees winkelbestellingen en hun factuurstatus
      description: 'Vereiste scope: shop:read. Lees de winkelbestellingen van de eigen rijschool, inclusief de status van
        de eerste factuur.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ShopOrder'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    post:
      operationId: createShopOrder
      x-overview: Plaats een bestelling tegen de catalogusprijs en maak de bijbehorende conceptfacturen aan.
      tags:
      - Winkelbestellingen
      summary: Plaats een bestelling via de leerlingwinkel
      description: 'Vereiste scope: shop:order. Ribba gebruikt de actuele catalogusprijs en maakt de normale conceptfacturen
        en eventuele pakkettermijnen aan. De rijschool ontvangt dezelfde melding als bij een bestelling in de app. Alleen
        een losse les kan een aantal groter dan één hebben. Termijnbetaling is mogelijk als het pakket die aanbiedt.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShopOrder'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              student_id: 00000000-0000-4000-8000-000000000011
              item_type: lesson
              item_id: 00000000-0000-4000-8000-000000000075
              quantity: 2
            schema:
              additionalProperties: false
              type: object
              required:
              - student_id
              - item_type
              - item_id
              properties:
                student_id:
                  type: string
                  format: uuid
                item_type:
                  type: string
                  enum:
                  - package
                  - product
                  - lesson
                item_id:
                  type: string
                  format: uuid
                quantity:
                  type: integer
                  minimum: 1
                  maximum: 20
                  default: 1
                installments:
                  type: integer
                  minimum: 1
                  maximum: 12
                  default: 1
  /shop-orders/{order_id}:
    parameters:
    - name: order_id
      in: path
      description: ID van de winkelbestelling.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getShopOrder
      x-overview: Lees de gegevens van één winkelbestelling en haar eerste factuur.
      tags:
      - Winkelbestellingen
      summary: Bekijk één winkelbestelling en de eerste factuur
      description: 'Vereiste scope: shop:read. Gebruik het ID van de winkelbestelling.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShopOrder'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /orders:
    get:
      operationId: listOrders
      x-overview: Haal het overzicht van pakketbestellingen van je rijschool op.
      tags:
      - Bestellingen
      summary: Toon pakketbestellingen
      description: 'Vereiste scope: orders:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Order'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /orders/{order_id}:
    parameters:
    - name: order_id
      in: path
      description: ID van het record.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getOrder
      x-overview: Bekijk de prijs en huidige status van één pakketbestelling.
      tags:
      - Bestellingen
      summary: Lees één record voor pakketbestellingen
      description: 'Vereiste scope: orders:read.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    delete:
      operationId: cancelOrder
      x-overview: Annuleer een openstaande pakketbestelling zonder factuur.
      tags:
      - Bestellingen
      summary: Annuleer een bestelling
      description: 'Vereiste scope: orders:manage. Zet een openstaande bestelling zonder gekoppelde factuur op geannuleerd.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /invoices:
    get:
      operationId: listInvoices
      x-overview: Haal het overzicht van de facturen van je rijschool op.
      tags:
      - Facturen
      summary: Toon facturen
      description: 'Vereiste scope: invoices:read.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Invoice'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    post:
      operationId: createInvoiceDraft
      x-overview: Maak een losse conceptfactuur met regels en btw voor een leerling.
      tags:
      - Facturen
      summary: Maak een conceptfactuur aan
      description: 'Vereiste scope: invoices:drafts. Maak een losse conceptfactuur in EUR voor een leerling van de school.
        Ribba berekent de bedragen op basis van de regels en het btw-tarief. Het totaal moet hoger dan nul en lager dan €
        1.000.000 zijn.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              student_id: 00000000-0000-4000-8000-000000000011
              items:
              - description: Rijles
                quantity: 2
                unit_price: 60.5
                vat_percentage: 21
            schema:
              additionalProperties: false
              type: object
              required:
              - student_id
              - items
              properties:
                student_id:
                  type: string
                  format: uuid
                items:
                  type: array
                  minItems: 1
                  maxItems: 20
                  items:
                    additionalProperties: false
                    type: object
                    required:
                    - description
                    - quantity
                    - unit_price
                    - vat_percentage
                    properties:
                      description:
                        type: string
                        minLength: 1
                        maxLength: 250
                      quantity:
                        type: number
                        exclusiveMinimum: 0
                        maximum: 1000
                        multipleOf: 0.01
                      unit_price:
                        type: number
                        minimum: 0
                        maximum: 100000
                        multipleOf: 0.01
                        description: Stukprijs in EUR inclusief btw.
                      vat_percentage:
                        type: integer
                        enum:
                        - 0
                        - 9
                        - 21
  /invoices/{invoice_id}:
    parameters:
    - name: invoice_id
      in: path
      description: ID van het record.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getInvoice
      x-overview: Bekijk het bedrag, de status en andere gegevens van één factuur.
      tags:
      - Facturen
      summary: Lees één record voor facturen
      description: 'Vereiste scope: invoices:read.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    patch:
      operationId: updateInvoiceDraft
      x-overview: Vervang de regels van een los concept en laat de bedragen opnieuw berekenen.
      tags:
      - Facturen
      summary: Vervang de regels van een conceptfactuur
      description: 'Vereiste scope: invoices:drafts. Vervang alle regels van een losse conceptfactuur. Ribba berekent de
        bedragen opnieuw. Geplande, uitgegeven en gekoppelde facturen zijn via deze route niet bewerkbaar.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              items:
              - description: Rijles
                quantity: 2
                unit_price: 60.5
                vat_percentage: 21
            schema:
              additionalProperties: false
              type: object
              required:
              - items
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 20
                  items:
                    additionalProperties: false
                    type: object
                    required:
                    - description
                    - quantity
                    - unit_price
                    - vat_percentage
                    properties:
                      description:
                        type: string
                        minLength: 1
                        maxLength: 250
                      quantity:
                        type: number
                        exclusiveMinimum: 0
                        maximum: 1000
                        multipleOf: 0.01
                      unit_price:
                        type: number
                        minimum: 0
                        maximum: 100000
                        multipleOf: 0.01
                        description: Stukprijs in EUR inclusief btw.
                      vat_percentage:
                        type: integer
                        enum:
                        - 0
                        - 9
                        - 21
    delete:
      operationId: deleteInvoiceDraft
      x-overview: Verwijder een losse, nog ongeplande conceptfactuur met de bijbehorende regels.
      tags:
      - Facturen
      summary: Verwijder een conceptfactuur
      description: 'Vereiste scope: invoices:drafts. Verwijder een losse conceptfactuur met haar regels. Geplande, uitgegeven
        en gekoppelde facturen worden geweigerd.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /students/{student_id}/activate:
    parameters:
    - name: student_id
      in: path
      description: ID van de leerling.
      schema:
        type: string
        format: uuid
      required: true
    post:
      operationId: activateStudent
      x-overview: Maak een leerling op de wachtlijst of uit het archief weer actief.
      tags:
      - Leerlingen
      summary: Activeer een leerling
      description: 'Vereiste scope: students:manage. Activeer een gearchiveerde leerling of een leerling op de wachtlijst.
        Ribba controleert de leerlinglimiet van de school.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /orders/{order_id}/reject:
    parameters:
    - name: order_id
      in: path
      description: ID van de bestelling.
      schema:
        type: string
        format: uuid
      required: true
    post:
      operationId: rejectOrder
      x-overview: Weiger een openstaande pakketbestelling zonder factuur.
      tags:
      - Bestellingen
      summary: Wijs een bestelling af
      description: 'Vereiste scope: orders:manage. Weiger een openstaande bestelling zonder gekoppelde factuur.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De status van het record of een eerder verzoek staat dit niet toe.
        '413':
          description: De aanvraag is groter dan 8 KiB.
  /invoices/{invoice_id}/items:
    parameters:
    - name: invoice_id
      in: path
      description: ID van de factuur.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: listInvoiceItems
      x-overview: Lees per factuurregel de omschrijving, prijs en btw.
      tags:
      - Facturen
      summary: Lees de regels van een factuur
      description: 'Vereiste scope: invoices:read. Lees de bedragen en btw van de factuurregels.'
      parameters:
      - name: limit
        in: query
        description: Maximumaantal resultaten per pagina.
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: cursor
        in: query
        description: Gebruik next_cursor uit het vorige antwoord met dezelfde filters.
        schema:
          type: string
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                type: object
                required:
                - data
                - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/InvoiceItem'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
  /orders/{order_id}/invoice:
    parameters:
    - name: order_id
      in: path
      description: ID van een openstaande pakketbestelling.
      schema:
        type: string
        format: uuid
      required: true
    post:
      operationId: createOrderInvoice
      x-overview: Maak vanuit een openstaande pakketbestelling een conceptfactuur aan.
      tags:
      - Facturen
      summary: Maak een conceptfactuur voor een pakketbestelling
      description: 'Vereiste scope: invoices:write. Ribba neemt het bedrag en de valuta over van de bestelling. Factuur,
        regel en goedkeuring worden samen opgeslagen. Stuur geen body mee.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '201':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De bestelling is al verwerkt, kan niet worden gefactureerd of de idempotentiesleutel is voor een
            ander verzoek gebruikt.
  /invoices/{invoice_id}/payment:
    parameters:
    - name: invoice_id
      in: path
      description: ID van de factuur.
      schema:
        type: string
        format: uuid
      required: true
    get:
      operationId: getInvoicePayment
      x-overview: Controleer de betaalstatus en lees de betaallink als die beschikbaar is.
      tags:
      - Betalingen
      summary: Lees de betaalgegevens van een factuur
      description: 'Vereiste scope: payments:read. De status komt van de factuur. Een bestaande betaallink kan worden teruggegeven
        voor een open factuur. Er wordt geen betaling aangemaakt.'
      responses:
        '200':
          description: Verzoek verwerkt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicePayment'
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
    post:
      operationId: recordInvoicePayment
      x-overview: Boek een ontvangen overschrijving, contante betaling of pinbetaling op een factuur.
      tags:
      - Betalingen
      summary: Registreer een ontvangen betaling
      description: 'Vereiste scope: payments:record. Registreer het ontvangen bedrag als volledige betaling op een uitgereikte
        factuur die je rijschool zelf int. Kies overschrijving, contant of pin en geef de ontvangstdatum in Nederland op.
        Ribba past eventueel pakkettegoed toe. Facturen die een betaalprovider beheert worden geweigerd.'
      parameters:
      - name: Idempotency-Key
        in: header
        description: Hergebruik dezelfde sleutel en invoer bij een retry binnen 24 uur.
        schema:
          type: string
          minLength: 8
          maxLength: 128
        required: true
      responses:
        '204':
          description: Verzoek verwerkt.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '409':
          description: De huidige staat, de planning of een eerder verzoek staat deze wijziging niet toe.
        '413':
          description: De JSON-aanvraag is groter dan 8 KiB.
        '422':
          description: Een veldnaam of waarde is ongeldig.
      requestBody:
        required: true
        content:
          application/json:
            example:
              paid_on: '2026-11-27'
              method: overschrijving
            schema:
              additionalProperties: false
              type: object
              required:
              - paid_on
              - method
              properties:
                paid_on:
                  type: string
                  format: date
                method:
                  type: string
                  enum:
                  - overschrijving
                  - contant
                  - pin
  /webhook-subscriptions:
    get:
      operationId: listSubscriptions
      x-overview: Bekijk welke webhookabonnementen bij de integratie horen.
      tags:
      - Webhooks
      summary: Bekijk de abonnementen van de integratie
      description: 'Vereiste scope: webhooks:read.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionPage'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
      parameters:
      - name: limit
        in: query
        required: false
        description: Aantal resultaten per pagina.
        schema:
          type: integer
          default: 50
          minimum: 1
          maximum: 100
      - name: cursor
        in: query
        required: false
        description: Ondoorzichtige next_cursor uit de vorige pagina. Gebruik dezelfde filters.
        schema:
          type: string
          minLength: 1
    post:
      operationId: createSubscription
      x-overview: Registreer een HTTPS-ontvanger voor de gekozen webhookberichten.
      tags:
      - Webhooks
      summary: Abonneer een HTTPS-ontvanger
      description: 'Vereiste scope: webhooks:manage en lessons:read. De ontvanger wordt actief na de ondertekende verificatie.
        Een geheim komt nooit in een leesantwoord.'
      responses:
        '201':
          description: Abonnement aangemaakt, verificatie gestart.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
        '409':
          $ref: '#/components/responses/E409'
        '413':
          $ref: '#/components/responses/E413'
        '422':
          $ref: '#/components/responses/E422'
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        description: Unieke waarde per logische actie. Herhaal dezelfde body en sleutel bij een timeout. Gedurende 24 uur
          geeft dit dezelfde opdracht terug.
        schema:
          type: string
          minLength: 8
          maxLength: 128
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewSubscription'
  /webhook-subscriptions/{subscription_id}:
    parameters:
    - name: subscription_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    get:
      operationId: getSubscription
      x-overview: Controleer of de webhookontvanger is geverifieerd en het abonnement actief is.
      tags:
      - Webhooks
      summary: Lees de verificatiestatus
      description: 'Vereiste scope: webhooks:read.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '404':
          $ref: '#/components/responses/E404'
    delete:
      operationId: deleteSubscription
      x-overview: Stop toekomstige webhookbezorgingen naar deze ontvanger.
      tags:
      - Webhooks
      summary: Stop toekomstige bezorgingen
      description: 'Vereiste scope: webhooks:manage. Annuleert ook geplande herhalingen. Een reeds verzonden HTTP-aanroep
        kan nog aankomen.'
      responses:
        '204':
          description: Abonnement beëindigd.
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '404':
          $ref: '#/components/responses/E404'
  /webhook-subscriptions/{subscription_id}/deliveries:
    parameters:
    - name: subscription_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    get:
      operationId: listDeliveries
      x-overview: Bekijk de bezorgpogingen voor een webhookabonnement van de afgelopen dertig dagen.
      tags:
      - Webhooks
      summary: Bekijk bezorgingen uit de laatste 30 dagen
      description: 'Vereiste scope: webhooks:read. Nieuwste eerst. Iedere rij verwijst naar één event op deze bestemming.'
      responses:
        '200':
          description: Gelukt.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeliveryPage'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
        '404':
          $ref: '#/components/responses/E404'
      parameters:
      - name: limit
        in: query
        required: false
        description: Aantal resultaten per pagina.
        schema:
          type: integer
          default: 50
          minimum: 1
          maximum: 100
      - name: cursor
        in: query
        required: false
        description: Ondoorzichtige next_cursor uit de vorige pagina. Gebruik dezelfde filters.
        schema:
          type: string
          minLength: 1
  /webhook-subscriptions/{subscription_id}/deliveries/{delivery_id}/redeliver:
    parameters:
    - name: subscription_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    - name: delivery_id
      in: path
      required: true
      description: Publieke object-ID binnen deze school en integratieomgeving.
      schema:
        type: string
        format: uuid
    post:
      operationId: redeliver
      x-overview: Zet een mislukte webhookbezorging opnieuw in de wachtrij.
      tags:
      - Webhooks
      summary: Plan een mislukte bezorging opnieuw
      description: 'Vereiste scope: webhooks:manage en lessons:read. Alleen binnen de bewaartermijn, bij een actief abonnement
        en actuele toegang. Behoudt dezelfde event-ID.'
      responses:
        '202':
          description: Opnieuw ingepland.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Delivery'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
        '400':
          $ref: '#/components/responses/E400'
        '404':
          $ref: '#/components/responses/E404'
        '409':
          $ref: '#/components/responses/E409'
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        description: Unieke waarde per logische actie. Herhaal dezelfde body en sleutel bij een timeout. Gedurende 24 uur
          geeft dit dezelfde opdracht terug.
        schema:
          type: string
          minLength: 8
          maxLength: 128
webhooks:
  lessonEvent:
    post:
      operationId: receiveEvent
      x-overview: Ontvang een webhook wanneer een les wordt aangemaakt, gewijzigd of verwijderd.
      summary: Ontvang een leswijziging
      security: []
      description: Ribba roept de ontvanger aan. Verifieer de Standard Webhooks-handtekening over de oorspronkelijke bytes
        met het afzonderlijke webhookgeheim.
      parameters:
      - name: webhook-id
        in: header
        required: true
        description: Stabiele bericht-ID, gelijk aan body.id.
        schema:
          type: string
          format: uuid
      - name: webhook-timestamp
        in: header
        required: true
        description: Unix-tijd in seconden van deze bezorgpoging.
        schema:
          type: string
          pattern: ^[0-9]+$
      - name: webhook-signature
        in: header
        required: true
        description: Versie en Base64 HMAC-SHA256. Tijdens rotatie kunnen meerdere handtekeningen aanwezig zijn.
        schema:
          type: string
          minLength: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Event'
      responses:
        2XX:
          description: Duurzaam ontvangen; verwerking mag asynchroon.
  verifyEndpoint:
    post:
      operationId: receiveVerification
      x-overview: Beantwoord een verificatieverzoek waarmee Ribba de webhookontvanger controleert.
      summary: Verifieer bezit van de ontvanger
      security: []
      description: Ribba roept de ontvanger aan. Verifieer de Standard Webhooks-handtekening over de oorspronkelijke bytes
        met het afzonderlijke webhookgeheim.
      parameters:
      - name: webhook-id
        in: header
        required: true
        description: Stabiele bericht-ID, gelijk aan body.id.
        schema:
          type: string
          format: uuid
      - name: webhook-timestamp
        in: header
        required: true
        description: Unix-tijd in seconden van deze bezorgpoging.
        schema:
          type: string
          pattern: ^[0-9]+$
      - name: webhook-signature
        in: header
        required: true
        description: Versie en Base64 HMAC-SHA256. Tijdens rotatie kunnen meerdere handtekeningen aanwezig zijn.
        schema:
          type: string
          minLength: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Verification'
      responses:
        '200':
          description: Geef dezelfde challenge terug.
          content:
            application/json:
              schema:
                type: object
                properties:
                  challenge:
                    type: string
                    minLength: 1
                required:
                - challenge
components:
  securitySchemes:
    SchoolKey:
      type: http
      scheme: bearer
      description: API-sleutel voor servergebruik. Sandbox en productie hebben eigen sleutels.
  schemas:
    Vehicle:
      type: object
      required:
      - id
      - license_plate
      - brand
      - model
      - transmission_type
      properties:
        id:
          type: string
          format: uuid
        license_plate:
          type: string
        brand:
          type: string
        model:
          type: string
        transmission_type:
          type:
          - string
          - 'null'
    LessonType:
      type: object
      required:
      - id
      - school_category_id
      - display_name
      - lesson_type
      - default_duration_minutes
      properties:
        id:
          type: string
          format: uuid
        school_category_id:
          type: string
          format: uuid
        display_name:
          type: string
        lesson_type:
          type: string
          enum:
          - practical
          - theory
          - exam
          - trial
        default_duration_minutes:
          type:
          - integer
          - 'null'
    BusyTimes:
      type: object
      required:
      - local_date
      - time_zone
      - busy
      properties:
        local_date:
          type: string
          format: date
        time_zone:
          type: string
          enum:
          - Europe/Amsterdam
        busy:
          type: array
          items:
            type: object
            required:
            - start_time
            - end_time
            properties:
              start_time:
                type: string
                pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
              end_time:
                type: string
                pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
    InvoiceSendSchedule:
      type: object
      required:
      - invoice_id
      - scheduled_send_on
      properties:
        invoice_id:
          type: string
          format: uuid
        scheduled_send_on:
          type: string
          format: date
    InstructorInvite:
      type: object
      required:
      - id
      - email
      - expires_at
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        expires_at:
          type: string
          format: date-time
    InstructorInviteLink:
      type: object
      required:
      - id
      - expires_at
      - invite_url
      properties:
        id:
          type: string
          format: uuid
        expires_at:
          type: string
          format: date-time
        invite_url:
          type: string
          format: uri
    Instructor:
      type: object
      required:
      - id
      - first_name
      - last_name
      - status
      properties:
        id:
          type: string
          format: uuid
        first_name:
          type: string
        last_name:
          type: string
        status:
          type: string
        default_vehicle_id:
          type: [string, "null"]
          format: uuid
    Reservation:
      type: object
      required:
      - id
      - student_id
      - instructor_id
      - local_date
      - start_time
      - end_time
      - time_zone
      - lesson_type
      - status
      properties:
        id:
          type: string
          format: uuid
        student_id:
          type: string
          format: uuid
        instructor_id:
          type: string
          format: uuid
        local_date:
          type: string
          format: date
        start_time:
          type: string
        end_time:
          type: string
        time_zone:
          type: string
          enum:
          - Europe/Amsterdam
        lesson_type:
          type: string
        status:
          type: string
          enum:
          - pending
          - confirmed
          - rejected
          - cancelled
    Order:
      type: object
      required:
      - id
      - student_id
      - package_id
      - package_name
      - amount
      - currency
      - status
      - created_at
      properties:
        id:
          type: string
          format: uuid
        student_id:
          type: string
          format: uuid
        package_id:
          type:
          - string
          - 'null'
          format: uuid
        package_name:
          type: string
        amount:
          type: number
        currency:
          type: string
        status:
          type: string
        created_at:
          type: string
          format: date-time
    Invoice:
      type: object
      required:
      - id
      - student_id
      - order_id
      - invoice_number
      - amount
      - currency
      - status
      - due_date
      - paid_at
      - created_at
      - is_credit_note
      properties:
        id:
          type: string
          format: uuid
        student_id:
          type: string
          format: uuid
        order_id:
          type:
          - string
          - 'null'
          format: uuid
        invoice_number:
          type:
          - string
          - 'null'
        amount:
          type: number
        currency:
          type: string
        status:
          type: string
        due_date:
          type:
          - string
          - 'null'
          format: date
        paid_at:
          type:
          - string
          - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
        is_credit_note:
          type: boolean
    InvoicePayment:
      type: object
      required:
      - invoice_id
      - invoice_status
      - paid_at
      - checkout_url
      properties:
        invoice_id:
          type: string
          format: uuid
        invoice_status:
          type: string
        paid_at:
          type:
          - string
          - 'null'
          format: date-time
        checkout_url:
          type:
          - string
          - 'null'
          format: uri
    Identity:
      type: object
      properties:
        school_id:
          type: string
          format: uuid
        integration_id:
          type: string
          format: uuid
        environment:
          type: string
          enum:
          - sandbox
          - live
        scopes:
          type: array
          items:
            type: string
            enum:
            - students:read
            - students:write
            - students:manage
            - lessons:read
            - lessons:write
            - instructors:read
            - instructors:manage
            - reservations:read
            - reservations:write
            - reservations:manage
            - orders:read
            - orders:manage
            - shop:read
            - shop:order
            - invoices:read
            - invoices:write
            - invoices:drafts
            - invoices:issue
            - payments:read
            - payments:record
            - webhooks:read
            - webhooks:manage
      required:
      - school_id
      - integration_id
      - environment
      - scopes
    ShopItem:
      type: object
      required:
      - id
      - item_type
      - name
      - max_installments
      properties:
        id:
          type: string
          format: uuid
        item_type:
          type: string
          enum:
          - package
          - product
          - lesson
        name:
          type: string
        max_installments:
          type: integer
    ShopOrder:
      type: object
      required:
      - id
      - student_id
      - item_type
      - item_id
      - item_name
      - invoice_id
      - invoice_status
      - first_invoice_amount
      - currency
      - created_at
      properties:
        id:
          type: string
          format: uuid
        student_id:
          type: string
          format: uuid
        item_type:
          type: string
          enum:
          - package
          - product
          - lesson
        item_id:
          type: string
          format: uuid
        item_name:
          type: string
        invoice_id:
          type:
          - string
          - 'null'
          format: uuid
        invoice_status:
          type:
          - string
          - 'null'
        first_invoice_amount:
          type:
          - number
          - 'null'
        currency:
          type:
          - string
          - 'null'
        created_at:
          type: string
          format: date-time
    InvoiceItem:
      type: object
      required:
      - id
      - description
      - quantity
      - unit_price
      - vat_percentage
      - vat_included
      - amount_excl_vat
      properties:
        id:
          type: string
          format: uuid
        description:
          type: string
        quantity:
          type:
          - number
          - 'null'
        unit_price:
          type: number
        vat_percentage:
          type:
          - integer
          - 'null'
        vat_included:
          type:
          - boolean
          - 'null'
        amount_excl_vat:
          type:
          - number
          - 'null'
    Student:
      type: object
      properties:
        id:
          type: string
          format: uuid
        first_name:
          type: string
        last_name:
          type: string
        status:
          type: [string, "null"]
      required:
      - id
      - first_name
      - last_name
    Lesson:
      type: object
      properties:
        id:
          type: string
          format: uuid
        student_id:
          anyOf:
          - type: string
            format: uuid
          - type: 'null'
        instructor_id:
          type: string
          format: uuid
        local_date:
          type: string
          format: date
        start_time:
          type: string
          pattern: ^([01][0-9]|2[0-3]):[0-5][0-9]$
        end_time:
          type: string
          pattern: ^([01][0-9]|2[0-3]):[0-5][0-9]$
        time_zone:
          type: string
          enum:
          - Europe/Amsterdam
        status:
          type: string
          enum:
          - scheduled
          - completed
          - cancelled
          - no_show
      required:
      - id
      - student_id
      - instructor_id
      - local_date
      - start_time
      - end_time
      - time_zone
      - status
    Subscription:
      type: object
      properties:
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
            enum:
            - lesson.created
            - lesson.updated
            - lesson.deleted
        status:
          type: string
          enum:
          - pending
          - active
          - paused
        created_at:
          type: string
          format: date-time
      required:
      - id
      - url
      - events
      - status
      - created_at
    NewSubscription:
      type: object
      properties:
        url:
          type: string
          format: uri
          pattern: ^https://
          description: Publieke HTTPS-ontvanger zonder credentials of tokens in de URL.
        events:
          type: array
          items:
            type: string
            enum:
            - lesson.created
            - lesson.updated
            - lesson.deleted
          minItems: 1
          uniqueItems: true
        signing_secret:
          type: string
          writeOnly: true
          pattern: ^whsec_[A-Za-z0-9+/]{43}=$
          description: whsec_ gevolgd door 32 willekeurige bytes in standaard-Base64. Alleen bij registratie meesturen.
      required:
      - url
      - events
      - signing_secret
      additionalProperties: false
    Delivery:
      type: object
      properties:
        id:
          type: string
          format: uuid
        event_id:
          type: string
          format: uuid
        subscription_id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - pending
          - delivered
          - failed
        attempts:
          type: integer
          minimum: 0
        last_http_status:
          anyOf:
          - type: integer
            minimum: 100
            maximum: 599
          - type: 'null'
        created_at:
          type: string
          format: date-time
      required:
      - id
      - event_id
      - subscription_id
      - status
      - attempts
      - last_http_status
      - created_at
    Event:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
          - lesson.created
          - lesson.updated
          - lesson.deleted
        version:
          type: string
          enum:
          - '1'
        school_id:
          type: string
          format: uuid
        occurred_at:
          type: string
          format: date-time
        data:
          type: object
          properties:
            lesson_id:
              type: string
              format: uuid
          required:
          - lesson_id
      required:
      - id
      - type
      - version
      - school_id
      - occurred_at
      - data
    Verification:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
          - endpoint.verification
        challenge:
          type: string
          minLength: 1
      required:
      - id
      - type
      - challenge
    Problem:
      type: object
      properties:
        type:
          type: string
          format: uri-reference
        title:
          type: string
        status:
          type: integer
        code:
          type: string
          minLength: 1
        request_id:
          type: string
          minLength: 1
      required:
      - type
      - title
      - status
      - code
      - request_id
    StudentPage:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Student'
        next_cursor:
          anyOf:
          - type: string
            minLength: 1
          - type: 'null'
      required:
      - data
      - next_cursor
    LessonPage:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Lesson'
        next_cursor:
          anyOf:
          - type: string
            minLength: 1
          - type: 'null'
      required:
      - data
      - next_cursor
    SubscriptionPage:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Subscription'
        next_cursor:
          anyOf:
          - type: string
            minLength: 1
          - type: 'null'
      required:
      - data
      - next_cursor
    DeliveryPage:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Delivery'
        next_cursor:
          anyOf:
          - type: string
            minLength: 1
          - type: 'null'
      required:
      - data
      - next_cursor
  responses:
    E400:
      description: Ongeldige parameters of ongeldige cursor.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E401:
      description: Sleutel ontbreekt, is verlopen of ingetrokken.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E403:
      description: Vereiste scope of schooltoegang ontbreekt.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E404:
      description: Object onbekend of buiten de zichtbare school of integratie.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E409:
      description: Statusconflict of hergebruik van een Idempotency-Key met andere invoer.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E413:
      description: De JSON-body is groter dan 8 KiB.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E422:
      description: Bestemming of eventselectie kan niet worden geaccepteerd.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    E429:
      description: Quotum bereikt.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
      headers:
        Retry-After:
          description: Aantal seconden tot de volgende poging.
          schema:
            type: integer
            minimum: 1
    E500:
      description: Tijdelijke serverfout. Geef request_id door aan support.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
