{
  "openapi": "3.1.0",
  "info": {
    "title": "NexAI Mailagent: offene Schnittstelle",
    "version": "1",
    "description": "Nur lesend und kostenlos. Jede Instanz antwortet unter ihrer eigenen Adresse. Den Schlüssel legt die Verwaltung der Instanz unter „Datenschutz“ an; er gilt bis zum Widerruf. Jeder Abruf steht im Schnittstellenprotokoll der Instanz. Was jedes Feld bedeutet: https://nexaimail.de/datenformate"
  },
  "servers": [
    {
      "url": "/",
      "description": "die Adresse der jeweiligen Instanz"
    }
  ],
  "security": [
    {
      "schluessel": []
    }
  ],
  "components": {
    "securitySchemes": {
      "schluessel": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer nexaimail_…; nie in der Adresse"
      }
    }
  },
  "paths": {
    "/api/v1/export": {
      "get": {
        "operationId": "export",
        "summary": "Der ganze Export als ZIP-Datei, derselbe wie in der Oberfläche",
        "responses": {
          "200": {
            "description": "ZIP-Datei",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/zip"
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "es läuft schon ein Export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tabellen": {
      "get": {
        "operationId": "tabellen",
        "summary": "Die Tabellen mit Zahl ihrer Zeilen",
        "responses": {
          "200": {
            "description": "Liste",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "datei": {
                        "type": "string"
                      },
                      "zeilen": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "name",
                      "datei",
                      "zeilen"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tabellen/{name}": {
      "get": {
        "operationId": "tabelle",
        "summary": "Eine Tabelle als JSON Lines, Zeile für Zeile wie im Export",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "messages",
                "attachments",
                "anhang_text",
                "anhang_pruefung",
                "analysis",
                "deadlines",
                "drafts",
                "corrections",
                "questions",
                "freigaben",
                "freigaben_anker",
                "verwaltungsprotokoll",
                "rechnungen",
                "wiedervorlagen",
                "zuweisungen",
                "notizen",
                "vorgaenge",
                "anfragen",
                "absender_ibans",
                "sender_rules",
                "auto_send",
                "briefings",
                "link_summaries",
                "hausregeln",
                "style_profile",
                "mailbox_actions",
                "accounts",
                "runs",
                "verbrauch",
                "schnittstellen_schluessel",
                "schnittstellenprotokoll"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "je Datensatz eine Zeile JSON (RFC 8259), UTF-8",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "keine solche Tabelle",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/einstellungen": {
      "get": {
        "operationId": "einstellungen",
        "summary": "Die Einstellungen des Hauses, wie einstellungen.json im Export",
        "responses": {
          "200": {
            "description": "JSON-Objekt",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/anhaenge/{id}": {
      "get": {
        "operationId": "anhang",
        "summary": "Ein Dateianhang; die Angaben dazu stehen in der Tabelle attachments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "die Datei",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/octet-stream"
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "kein solcher Anhang",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dateien": {
      "get": {
        "operationId": "dateien",
        "summary": "Die Dateien, die das Haus pflegt, mit Pfad und Größe",
        "responses": {
          "200": {
            "description": "Liste",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "pfad": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "pfad",
                      "bytes"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/datei": {
      "get": {
        "operationId": "datei",
        "summary": "Eine dieser Dateien, mit dem Pfad genau wie in der Liste",
        "parameters": [
          {
            "name": "pfad",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "dateien/hausregeln.md"
          }
        ],
        "responses": {
          "200": {
            "description": "die Datei",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/octet-stream"
                }
              }
            }
          },
          "401": {
            "description": "kein oder kein gültiger Schlüssel",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "keine solche Datei",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fehler": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fehler"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
