{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hejstack.com/export-specs/konfiguration.schema.json",
  "title": "hejstack Export: konfiguration.json",
  "description": "Organisationseinstellungen, aktivierte Funktionen, Modellauswahl, Assistenten und angebundene Quellen (Dateiablagen, Postfächer, API-Schlüssel) – jeweils ohne Zugangsdaten, Token oder Geheimnisse. Exportformat 1.0, Stand 15.09.2026.",
  "type": "object",
  "required": ["format_version", "organisation", "settings"],
  "properties": {
    "format_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" },
    "organisation": {
      "type": "object",
      "required": ["id", "name", "slug"],
      "properties": {
        "id": { "$ref": "#/$defs/uuid" },
        "name": { "type": "string" },
        "slug": { "type": "string" },
        "account_status": { "type": "string", "enum": ["aktiv", "in_kuendigung", "gekuendigt"] },
        "created_at": { "type": "string", "format": "date-time" },
        "profile": {
          "type": "object",
          "description": "Stammdaten aus Einstellungen › Unternehmen.",
          "properties": {
            "org_type": { "type": "string" },
            "industry": { "type": "string" },
            "employee_count": { "type": "string" },
            "phone": { "type": "string" },
            "billing": {
              "type": "object",
              "properties": {
                "street": { "type": "string" },
                "city": { "type": "string" },
                "state": { "type": "string" },
                "postal_code": { "type": "string" },
                "country": { "type": "string", "description": "ISO 3166-1 alpha-2, z. B. DE." }
              }
            }
          }
        }
      }
    },
    "settings": {
      "type": "object",
      "description": "Organisationsweite Einstellungen als Schlüssel/Wert (Werte sind Zeichenketten). Bekannte Schlüssel siehe properties; weitere Schlüssel können hinzukommen.",
      "properties": {
        "chat_model": { "type": "string", "description": "Gewähltes Antwort-Sprachmodell (Modellname der Plattform)." },
        "document_engine": { "type": "string", "enum": ["server_side", "off"], "description": "Datei-Export von Antworten (Office-Dateien): server_side = EU-Generator, off = deaktiviert." },
        "general_knowledge": { "type": "string", "description": "Allgemeinwissen des Sprachmodells für die Organisation (on / off)." },
        "web_search": { "type": "string", "description": "Internetsuche für die Organisation (on / off)." },
        "web_search_provider": { "type": "string", "description": "Suchanbieter, z. B. qwant oder ecosia." },
        "mail_index_window_days": { "type": "string", "description": "Indexfenster für Postfach-Wissen in Tagen." },
        "mailbox_knowledge_policy": { "type": "string", "description": "Richtlinie für Postfach-Wissen der Mitglieder (off oder Opt-out-Modus)." },
        "onedrive_personal": { "type": "string", "description": "Persönliches OneDrive als Wissensquelle freigegeben." },
        "rag_system_prompt": { "type": "string", "description": "Organisationseigene Anpassung des Antwortverhaltens (System-Prompt), falls gesetzt." }
      },
      "additionalProperties": { "type": ["string", "null"] }
    },
    "assistants": { "type": "array", "items": { "$ref": "#/$defs/assistant" }, "description": "Von der Organisation angelegte Assistenten." },
    "connections": { "type": "array", "items": { "$ref": "#/$defs/connection" }, "description": "Angebundene Dateiablagen (Nextcloud, OneDrive, SharePoint) – Zuordnung ohne Inhalte und ohne Zugangsdaten." },
    "mailboxes": { "type": "array", "items": { "$ref": "#/$defs/mailbox" }, "description": "Angebundene Postfächer – ohne Zugangsdaten und Token." },
    "api_keys": { "type": "array", "items": { "$ref": "#/$defs/api_key" }, "description": "Ausgestellte API-Schlüssel – nur Metadaten, nie der Schlüssel selbst." }
  },
  "$defs": {
    "uuid": { "type": "string", "format": "uuid" },
    "assistant": {
      "type": "object",
      "required": ["id", "name", "slug", "system_prompt", "model"],
      "properties": {
        "id": { "$ref": "#/$defs/uuid" },
        "name": { "type": "string", "maxLength": 120 },
        "slug": { "type": "string" },
        "description": { "type": ["string", "null"] },
        "system_prompt": { "type": "string" },
        "model": { "type": "string" },
        "temperature": { "type": "number" },
        "knowledge_group_ids": { "type": "array", "items": { "$ref": "#/$defs/uuid" } },
        "is_active": { "type": "boolean" },
        "created_by": { "type": ["string", "null"], "format": "uuid" },
        "created_at": { "type": "string", "format": "date-time" }
      }
    },
    "connection": {
      "type": "object",
      "required": ["id", "provider", "display_name", "status"],
      "properties": {
        "id": { "$ref": "#/$defs/uuid" },
        "provider": { "type": "string", "description": "nextcloud, onedrive (auch SharePoint) …" },
        "display_name": { "type": "string" },
        "user_id": { "type": ["string", "null"], "format": "uuid", "description": "Gesetzt bei persönlichen Laufwerken; null bei Organisationsquellen." },
        "knowledge_group_id": { "type": ["string", "null"], "format": "uuid" },
        "root_path": { "type": "string", "description": "Startordner in der Quelle." },
        "status": { "type": "string" },
        "last_synced_at": { "type": ["string", "null"], "format": "date-time" },
        "mounts": {
          "type": "array",
          "description": "Weitere Ordner derselben Quelle, die als eigene Wissensgruppe eingebunden sind.",
          "items": {
            "type": "object",
            "required": ["knowledge_group_id", "subfolder", "display_name"],
            "properties": {
              "knowledge_group_id": { "$ref": "#/$defs/uuid" },
              "subfolder": { "type": "string" },
              "display_name": { "type": "string" },
              "status": { "type": "string" },
              "last_synced_at": { "type": ["string", "null"], "format": "date-time" }
            }
          }
        },
        "created_at": { "type": "string", "format": "date-time" }
      }
    },
    "mailbox": {
      "type": "object",
      "required": ["id", "provider", "status"],
      "properties": {
        "id": { "$ref": "#/$defs/uuid" },
        "provider": { "type": "string", "enum": ["m365", "m365_app", "imap"], "description": "m365 = Microsoft 365 (persönlich), m365_app = Microsoft 365 (Organisation), imap = IMAP-Postfach." },
        "account_email": { "type": ["string", "null"], "format": "email" },
        "display_name": { "type": ["string", "null"] },
        "user_id": { "type": ["string", "null"], "format": "uuid", "description": "Eigentümer bei persönlichen Postfächern." },
        "status": { "type": "string" },
        "connected_at": { "type": ["string", "null"], "format": "date-time" },
        "knowledge_sync_enabled": { "type": "boolean", "description": "Postfach wird als Wissen indexiert." },
        "knowledge_group_id": { "type": ["string", "null"], "format": "uuid" },
        "index_window_days": { "type": ["integer", "null"] },
        "created_at": { "type": "string", "format": "date-time" }
      }
    },
    "api_key": {
      "type": "object",
      "required": ["id", "name", "prefix", "user_id", "created_at"],
      "properties": {
        "id": { "$ref": "#/$defs/uuid" },
        "name": { "type": "string" },
        "prefix": { "type": "string", "description": "Nur die ersten Zeichen zur Wiedererkennung." },
        "user_id": { "$ref": "#/$defs/uuid" },
        "created_at": { "type": "string", "format": "date-time" },
        "last_used_at": { "type": ["string", "null"], "format": "date-time" },
        "revoked_at": { "type": ["string", "null"], "format": "date-time" }
      }
    }
  }
}
