{
  "openapi": "3.1.0",
  "info": {
    "title": "Coretool E-Rechnungs-API",
    "version": "1.0.0",
    "description": "E-Rechnungen (XRechnung UBL/CII, ZUGFeRD/Factur-X) per API prüfen. Authentifizierung mit API-Schlüssel im Header X-API-Key oder Authorization: Bearer. Leitweg-IDs prüfen. 3 Prüfungen kostenlos je Konto. Bremse je Schlüssel: 60 Anfragen/Minute, 1.000/Tag. Rechnungsinhalte werden nicht gespeichert."
  },
  "paths": {
    "/v1/keys": {
      "get": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "Eigene API-Schlüssel auflisten",
        "operationId": "schluessel_liste_v1_keys_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "API-Schlüssel anlegen (Coretool-Login nötig)",
        "operationId": "schluessel_anlegen_v1_keys_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchluesselNeu",
                "default": {}
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/v1/keys/{key_id}": {
      "delete": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "API-Schlüssel widerrufen",
        "operationId": "schluessel_widerrufen_v1_keys__key_id__delete",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Key Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "Kontingent und Verbrauch zum API-Schlüssel",
        "operationId": "nutzung_v1_usage_get",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/validate": {
      "post": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "E-Rechnung prüfen (XRechnung UBL/CII, ZUGFeRD/Factur-X-PDF)",
        "operationId": "validieren_v1_validate_post",
        "parameters": [
          {
            "name": "report",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "Prüfschritte (XSD/Schematron) mit ausgeben",
              "default": false,
              "title": "Report"
            },
            "description": "Prüfschritte (XSD/Schematron) mit ausgeben"
          },
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_validieren_v1_validate_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Schlüssel fehlt oder ungültig"
          },
          "402": {
            "description": "Gratis-Kontingent aufgebraucht"
          },
          "413": {
            "description": "Datei größer als 5 MB"
          },
          "429": {
            "description": "Ratenbegrenzung"
          },
          "503": {
            "description": "Prüfdienst vorübergehend nicht erreichbar (wird nicht berechnet)"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/auth/test": {
      "post": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "API-Schlüssel testen (POST-Variante)",
        "description": "Für Schlüsseltest: 200 = Schlüssel gültig, 401 = ungültig.\nKein Kontingentverbrauch; zählt nur zur Bremse (Minute/Tag).",
        "operationId": "auth_test_post",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Schlüssel fehlt oder ungültig"
          },
          "429": {
            "description": "Bremse"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      },
      "get": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "API-Schlüssel testen (verbraucht kein Kontingent)",
        "description": "Für Schlüsseltest: 200 = Schlüssel gültig, 401 = ungültig.\nKein Kontingentverbrauch; zählt nur zur Bremse (Minute/Tag).",
        "operationId": "auth_test_get",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "Schlüssel fehlt oder ungültig"
          },
          "429": {
            "description": "Bremse"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/leitweg/pruefen": {
      "post": {
        "tags": [
          "E-Rechnungs-API v1"
        ],
        "summary": "Leitweg-ID prüfen (KoSIT-Regeln, Prüfziffer MOD 97-10)",
        "description": "Flache Antwort: gueltig, pruefziffer_ok, grobadressierung, feinadressierung, fehler (de), fehler_en, ...\nEine ungültige ID ist ein normales Ergebnis (200, gueltig=false) und wird berechnet; ein leeres Feld nicht.",
        "operationId": "leitweg_pruefen_v1_leitweg_pruefen_post",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Api-Key"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Feld fehlt / kein JSON"
          },
          "401": {
            "description": "Schlüssel fehlt oder ungültig"
          },
          "402": {
            "description": "Kontingent aufgebraucht"
          },
          "413": {
            "description": "Body > 16 KB"
          },
          "429": {
            "description": "Bremse (Minute/Tag)"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "leitweg_id": {
                    "type": "string",
                    "example": "04011000-1234512345-06"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Body_validieren_v1_validate_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "XML (XRechnung UBL/CII) oder PDF (ZUGFeRD/Factur-X)"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_validieren_v1_validate_post"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "SchluesselNeu": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 60
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "Frei wählbarer Name, z. B. 'n8n' oder 'Zapier'"
          }
        },
        "type": "object",
        "title": "SchluesselNeu"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.coretool.de",
      "description": "Produktiv"
    }
  ]
}