{
 "components": {
  "schemas": {
   "ArtikelEingabe": {
    "properties": {
     "codes": {
      "items": {
       "type": "string"
      },
      "type": "array"
     },
     "ek": {
      "type": "string"
     },
     "lieferant": {
      "type": "string"
     },
     "lieferant_nr": {
      "type": "string"
     },
     "mindest": {
      "type": "string"
     },
     "serie": {
      "description": "Velo: je Stück mit Rahmennummer",
      "type": "boolean"
     },
     "sku": {
      "type": "string"
     },
     "text": {
      "type": "string"
     },
     "vk": {
      "type": "string"
     },
     "warengruppe": {
      "type": "string"
     }
    },
    "type": "object"
   },
   "Bewegung": {
    "properties": {
     "artikel": {
      "type": "string"
     },
     "beleg": {
      "type": "string"
     },
     "ek": {
      "description": "Einkaufspreis je Stück in CHF (Wareneingang)",
      "type": "string"
     },
     "grund": {
      "type": "string"
     },
     "kennung": {
      "type": "string"
     },
     "lieferant": {
      "type": "string"
     },
     "menge": {
      "type": "string"
     },
     "rahmen": {
      "type": "string"
     }
    },
    "required": [
     "artikel",
     "menge",
     "grund",
     "kennung"
    ],
    "type": "object"
   },
   "Etiketten": {
    "properties": {
     "anzahl": {
      "maximum": 500,
      "minimum": 1,
      "type": "integer"
     },
     "kennung": {
      "type": "string"
     }
    },
    "required": [
     "anzahl",
     "kennung"
    ],
    "type": "object"
   },
   "Fehler": {
    "properties": {
     "code": {
      "type": "integer"
     },
     "fehler": {
      "type": "string"
     }
    },
    "type": "object"
   },
   "Seite": {
    "properties": {
     "daten": {
      "items": {
       "type": "object"
      },
      "type": "array"
     },
     "gesamt": {
      "type": "integer"
     },
     "pro_seite": {
      "type": "integer"
     },
     "seite": {
      "type": "integer"
     },
     "weiter": {
      "nullable": true,
      "type": "string"
     }
    },
    "type": "object"
   },
   "Webhook": {
    "properties": {
     "ereignisse": {
      "items": {
       "enum": [
        "verkauf",
        "bestand",
        "auftrag"
       ],
       "type": "string"
      },
      "type": "array"
     },
     "url": {
      "type": "string"
     }
    },
    "required": [
     "url",
     "ereignisse"
    ],
    "type": "object"
   }
  },
  "securitySchemes": {
   "token": {
    "scheme": "bearer",
    "type": "http"
   }
  }
 },
 "info": {
  "description": "REST/JSON auf dem Computer des Betriebs. Token als Bearer, Rate-Limit 120 pro Minute, Webhooks signiert mit HMAC-SHA256 (X-Tresor-Signatur: sha256=…).",
  "title": "Proverio-Schnittstelle",
  "version": "1"
 },
 "openapi": "3.0.3",
 "paths": {
  "/": {
   "get": {
    "responses": {
     "200": {
      "description": "Sammlungen"
     }
    },
    "summary": "Übersicht"
   }
  },
  "/artikel": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "q",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Artikel mit Bestand, Preisen, Codes"
   },
   "post": {
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ArtikelEingabe"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Angelegt"
     },
     "403": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "422": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Artikel anlegen (Recht schreiben)"
   }
  },
  "/artikel/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Artikel mit Bestand, Preisen, Codes)"
   },
   "patch": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-Match",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ArtikelEingabe"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Geändert"
     },
     "412": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "422": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "428": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Artikel ändern (If-Match Pflicht)"
   }
  },
  "/artikel/{id}/etiketten": {
   "post": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Etiketten"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Schon gedruckt (gleiche Kennung)"
     },
     "201": {
      "description": "Gedruckt"
     },
     "409": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "422": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "503": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Verkaufsetiketten drucken (Recht schreiben, mit kennung nie doppelt)"
   }
  },
  "/belege": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Kassenbelege"
   }
  },
  "/belege/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Kassenbelege)"
   }
  },
  "/bestand": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Bestand je Artikel"
   }
  },
  "/bestand/bewegungen": {
   "post": {
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Bewegung"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Schon gebucht (gleiche Kennung)"
     },
     "201": {
      "description": "Gebucht"
     },
     "422": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Bestand buchen (idempotent über kennung)"
   }
  },
  "/bestand/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Bestand je Artikel)"
   }
  },
  "/bestellungen": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Bestellungen aus dem Shop"
   }
  },
  "/bestellungen/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Bestellungen aus dem Shop)"
   }
  },
  "/export/{was}.csv": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "was",
      "required": true,
      "schema": {
       "enum": [
        "artikel",
        "bestand",
        "velos",
        "kunden",
        "belege",
        "werkstatt",
        "bestellungen"
       ],
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "CSV"
     }
    },
    "summary": "Tabelle für Excel (Semikolon, UTF-8 mit BOM, Schweizer Zahlen)"
   }
  },
  "/feeds/{datei}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "datei",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "token",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Datei"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Produktfeed (Google, Galaxus, CSV); Token auch als ?token="
   }
  },
  "/kunden": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Kunden (nur mit Recht «Kunden»)"
   }
  },
  "/kunden/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Kunden (nur mit Recht «Kunden»))"
   }
  },
  "/velos": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Velos mit Rahmennummer (an Lager und verkauft)"
   }
  },
  "/velos/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Velos mit Rahmennummer (an Lager und verkauft))"
   }
  },
  "/wareneingaenge": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Wareneingänge aus Rechnungen der Lieferanten (vorbereitet und eingebucht)"
   }
  },
  "/wareneingaenge/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Wareneingänge aus Rechnungen der Lieferanten (vorbereitet und eingebucht))"
   }
  },
  "/webhooks": {
   "get": {
    "responses": {
     "200": {
      "description": "Liste"
     }
    },
    "summary": "Webhooks"
   },
   "post": {
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Webhook"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Angelegt"
     },
     "422": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Webhook anlegen, Antwort enthält das Geheimnis einmal"
   }
  },
  "/webhooks/{id}": {
   "delete": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "204": {
      "description": "Entfernt"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Webhook entfernen"
   }
  },
  "/webhooks/{id}/protokoll": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Protokoll"
     }
    },
    "summary": "Zustellungen (ohne Inhalt)"
   }
  },
  "/werkstatt": {
   "get": {
    "parameters": [
     {
      "in": "query",
      "name": "seite",
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     },
     {
      "in": "query",
      "name": "pro_seite",
      "schema": {
       "maximum": 200,
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Seite"
        }
       }
      },
      "description": "Eine Seite"
     },
     "401": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     },
     "429": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Werkstattaufträge"
   }
  },
  "/werkstatt/{id}": {
   "get": {
    "parameters": [
     {
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "in": "header",
      "name": "If-None-Match",
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Eintrag mit ETag"
     },
     "304": {
      "description": "Unverändert"
     },
     "404": {
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Fehler"
        }
       }
      },
      "description": "Fehler"
     }
    },
    "summary": "Ein Eintrag (Werkstattaufträge)"
   }
  }
 },
 "security": [
  {
   "token": []
  }
 ],
 "servers": [
  {
   "url": "/api/v1"
  }
 ]
}
