Zum Inhalt

Bestand & Lager

Bestandsverwaltung auf Organisationsebene (nicht Shop-Katalog).

Bestand auflisten

GET /api/v2/public/orgs/{orgId}/inventory
Authorization: Bearer {token}

Bereich: inventory.read

Antwort

{
  "data": [
    {
      "p1_id": 12345,
      "name": "Example Strain",
      "stockquantity": 50,
      "price": 8.99,
      "category": "Blüten",
      "log_entries": 12,
      "last_activity": "2026-06-05T14:00:00Z"
    }
  ]
}

Bestand anpassen

POST /api/v2/public/orgs/{orgId}/inventory/adjust
Authorization: Bearer {token}
Content-Type: application/json

{
  "p1_id": "12345",
  "delta_on_hand": -2,
  "delta_incoming": 0,
  "reason": "POS sale",
  "shop_id": "shop1",
  "metadata": { "pos_ref": "TX-999" }
}

Bereich: inventory.write

Feld Pflicht Beschreibung
p1_id Ja Produkt-ID
reason Ja Grund für Audit-Log
delta_on_hand Nein Änderung verfügbarer Menge (negativ = Abgang)
delta_incoming Nein Änderung erwarteter Menge
shop_id Nein Optionaler Kontext für Log-Eintrag
metadata Nein Beliebiges JSON im Log

Antwort

{ "status": "ok", "id": "log-entry-uuid" }

Bestand kann nicht unter null fallen.


Bestandsänderungs-Log

GET /api/v2/public/orgs/{orgId}/inventory/{p1Id}/log
Authorization: Bearer {token}

Bereich: inventory.read

Bis zu 200 letzte Einträge:

{
  "data": [
    {
      "id": "uuid",
      "p1_id": 12345,
      "shop_id": "shop1",
      "delta_on_hand": -2,
      "delta_incoming": 0,
      "reason": "POS sale",
      "created_at": "2026-06-05T14:00:00Z"
    }
  ]
}

Produkt muss zum Org-Bestand gehören (sonst 404).


Bestandshistorie

GET /api/v2/public/orgs/{orgId}/inventory/{p1Id}/history?days=30
Authorization: Bearer {token}

Bereich: inventory.read

Query Standard Max Beschreibung
days 30 365 Rückblickzeitraum

Tägliche Bestandsänderungen aggregiert aus inventory_log.


Workflow: POS-Sync

Typischer Integrationsablauf:

  1. GET /inventory — aktuellen Bestand abrufen.
  2. Bei Verkauf im POS → POST /inventory/adjust mit negativem delta_on_hand.
  3. Bei Lieferung → positives delta_on_hand.
  4. Webhooks low_stock / out_of_stock für Alarme abonnieren.

Vor Shop-Zuordnung: Katalogartikel mit POST /products/add-to-inventory hinzufügen und Bestand > 0 sicherstellen — siehe Shops & Produkte.