openapi: 3.0.3
info:
  title: Invoice & Receipt Extract API
  version: "0.2"
  description: >
    Send a PDF, photo or text of an invoice or receipt and get structured JSON back
    (seller, buyer, VAT IDs, lines, VAT breakdown, totals, IBAN, dates) plus automatic
    arithmetic and format checks. Works with German, English and most EU invoices.
    AI-assisted extraction: review results before booking or payment. Not tax advice,
    not an EN 16931 / XRechnung validation. Files are processed in memory and not stored.
servers:
  - url: https://fatura-api-lunafzai.pages.dev
paths:
  /v1/extract:
    post:
      summary: Extract invoice data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [file, mime]
              properties:
                file: { type: string, format: byte, description: Base64 file content (max 8 MB) }
                mime: { type: string, enum: [application/pdf, image/png, image/jpeg, image/webp, text/plain] }
      responses:
        "200":
          description: Extracted data and checks
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: { type: object, description: Invoice fields, see /v1/schema }
                  checks:
                    type: object
                    properties:
                      passed: { type: boolean }
                      issues: { type: array, items: { type: object, properties: { kod: { type: string }, mesaj: { type: string } } } }
                  meta: { type: object }
        "401": { description: Missing or wrong key }
        "413": { description: File larger than 8 MB }
        "415": { description: Unsupported file type }
        "422": { description: Scanned PDF without text layer; send the page as image }
        "502": { description: Extraction failed, retry }
  /v1/schema:
    get: { summary: JSON schema of the data object, responses: { "200": { description: Schema } } }
  /v1/health:
    get: { summary: Health check, responses: { "200": { description: OK } } }
