{
 "openapi": "3.1.0",
 "info": {
  "title": "Valifakt E-Invoice API",
  "version": "1.0.0",
  "summary": "Convert invoices to XRechnung, ZUGFeRD, KSeF, Peppol BIS 3.0 and PINT AE; validate e-invoice XML with the official rules.",
  "description": "Convert PDF, Excel (XLSX/XLSM) and Word (DOCX) invoices into structured e-invoices – **XRechnung** (UBL or CII) and **ZUGFeRD / Factur-X**\nfor Germany, **KSeF FA(3)** for Poland, **Peppol BIS Billing 3.0** for Belgium and **PINT AE** for the UAE – and validate existing e-invoice XML with the\nofficial rule sets (KoSIT XRechnung, EN 16931 / Peppol schematrons, KSeF FA(3) XSD, PINT AE, ZATCA SDK rules for Saudi Arabia, FNFE-MPE XP Z12-012 BR-FR rules\nfor France).\n\n**Authentication:** `Authorization: Bearer vf_…` – the key comes by e-mail with a Pro, Office or api plan.\n\n**Plans and limits** (one quota shared with the website; only conversions that end `status: valid` count; `/validate` never counts):\n\n| Plan | Price | Conversions / month | Requests / minute |\n|---|---|---|---|\n| Pro | €12 / month (€120 / year) | 100 | 10 |\n| Office | €49 / month (€490 / year) | 1,000 | 30 |\n| api | on request | 100,000 | 60 |\n\nEvery response from `/convert` and `/validate` carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`; HTTP 429 adds `Retry-After`.\nErrors use one JSON shape: `{\"error\": {\"code\": \"…\", \"message\": \"…\"}}`. Converted files expire after 60 minutes.\n\nValifakt checks and converts files; it does not transmit invoices to any network, platform or tax authority.",
  "termsOfService": "https://valifakt.com/en/terms.html",
  "contact": {
   "name": "Valifakt",
   "url": "https://valifakt.com/en/api-reference.html",
   "email": "hello@valifakt.com"
  }
 },
 "servers": [
  {
   "url": "https://valifakt.com/api/v1",
   "description": "Production"
  }
 ],
 "paths": {
  "/convert": {
   "post": {
    "tags": [
     "Invoices"
    ],
    "summary": "Convert an invoice",
    "operationId": "convertInvoice",
    "requestBody": {
     "content": {
      "multipart/form-data": {
       "schema": {
        "$ref": "#/components/schemas/ConvertRequest"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Conversion ran. Check `status`: only `valid` counts against the quota.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ConvertResponse"
        }
       }
      }
     },
     "402": {
      "description": "quota_exceeded",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "422": {
      "description": "conversion_failed: the file could not be read or converted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "400": {
      "description": "Bad request: invalid_request, invalid_country, invalid_format, unsupported_file_type, unsafe_file, invalid_patch",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "401": {
      "description": "missing_api_key or invalid_api_key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "403": {
      "description": "plan_not_allowed: the key's plan has no API access",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "413": {
      "description": "file_too_large",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "429": {
      "description": "rate_limited; see the Retry-After header",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     }
    },
    "security": [
     {
      "HTTPBearer": []
     }
    ],
    "description": "Upload one invoice (PDF, XLSX, XLSM or DOCX). The response always contains the pre-check; when `status` is `valid` it also has the official validator result and download URLs in `files`. If `status` is `needs_input`, send the missing values as a JSON object in `patch` and call again."
   }
  },
  "/jobs/{job}/{kind}": {
   "get": {
    "tags": [
     "Invoices"
    ],
    "summary": "Download a converted file",
    "operationId": "downloadJobFile",
    "security": [
     {
      "HTTPBearer": []
     }
    ],
    "parameters": [
     {
      "name": "job",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Job",
       "pattern": "^[0-9a-f]{32}$"
      },
      "description": "Job id from /convert (expires after 60 minutes)"
     },
     {
      "name": "kind",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Kind",
       "enum": [
        "xml",
        "pdf"
       ]
      },
      "description": "xml, or pdf for ZUGFeRD"
     }
    ],
    "responses": {
     "200": {
      "description": "The e-invoice file",
      "content": {
       "application/xml": {},
       "application/pdf": {}
      }
     },
     "404": {
      "description": "not_found: unknown, expired or someone else's job",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "401": {
      "description": "missing_api_key or invalid_api_key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "403": {
      "description": "plan_not_allowed: the key's plan has no API access",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     }
    }
   }
  },
  "/validate": {
   "post": {
    "tags": [
     "Invoices"
    ],
    "summary": "Validate an e-invoice XML",
    "operationId": "validateInvoice",
    "requestBody": {
     "content": {
      "multipart/form-data": {
       "schema": {
        "$ref": "#/components/schemas/ValidateRequest"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Validator result. Does not use conversion quota.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ValidateResponse"
        }
       }
      }
     },
     "400": {
      "description": "Bad request: invalid_request, invalid_country, invalid_format, unsupported_file_type, unsafe_file, invalid_patch",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "401": {
      "description": "missing_api_key or invalid_api_key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "403": {
      "description": "plan_not_allowed: the key's plan has no API access",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "413": {
      "description": "file_too_large",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "429": {
      "description": "rate_limited; see the Retry-After header",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     }
    },
    "security": [
     {
      "HTTPBearer": []
     }
    ],
    "description": "Validate an existing XML e-invoice. The rule set is chosen from the document: XRechnung/EN 16931 (KoSIT), Peppol BIS 3.0, KSeF FA(3), PINT AE, ZATCA (KSA) and French XP Z12-012 / BR-FR. Does not use the conversion quota."
   }
  },
  "/quota": {
   "get": {
    "tags": [
     "Account"
    ],
    "summary": "Current month's usage",
    "operationId": "getQuota",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Quota"
        }
       }
      }
     },
     "401": {
      "description": "missing_api_key or invalid_api_key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     },
     "403": {
      "description": "plan_not_allowed: the key's plan has no API access",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorResponse"
        }
       }
      }
     }
    },
    "security": [
     {
      "HTTPBearer": []
     }
    ]
   }
  }
 },
 "components": {
  "schemas": {
   "ConvertResponse": {
    "properties": {
     "job": {
      "type": "string",
      "title": "Job",
      "description": "Job id; files and job expire after 60 minutes."
     },
     "status": {
      "type": "string",
      "title": "Status",
      "description": "valid | needs_input | invalid",
      "examples": [
       "valid"
      ]
     },
     "format": {
      "type": "string",
      "title": "Format",
      "examples": [
       "xrechnung-ubl"
      ]
     },
     "totals": {
      "additionalProperties": {
       "type": "string"
      },
      "type": "object",
      "title": "Totals",
      "examples": [
       {
        "gross": "119.00",
        "net": "100.00",
        "tax": "19.00"
       }
      ]
     },
     "precheck": {
      "items": {
       "additionalProperties": true,
       "type": "object"
      },
      "type": "array",
      "title": "Precheck",
      "description": "All pre-check findings (severity error | warning | info)."
     },
     "missing": {
      "items": {
       "additionalProperties": true,
       "type": "object"
      },
      "type": "array",
      "title": "Missing",
      "description": "Pre-check findings with severity error. Send the values in `patch` and convert again."
     },
     "validation": {
      "anyOf": [
       {
        "additionalProperties": true,
        "type": "object"
       },
       {
        "type": "null"
       }
      ],
      "title": "Validation",
      "description": "Official validator result (null when status is needs_input)."
     },
     "invoice": {
      "additionalProperties": true,
      "type": "object",
      "title": "Invoice",
      "description": "The extracted invoice data."
     },
     "files": {
      "additionalProperties": {
       "type": "string"
      },
      "type": "object",
      "title": "Files",
      "description": "Absolute download URLs (`xml`, plus `pdf` for ZUGFeRD) when status is valid."
     },
     "quota": {
      "$ref": "#/components/schemas/Quota"
     }
    },
    "type": "object",
    "required": [
     "job",
     "status",
     "format",
     "totals",
     "precheck",
     "missing",
     "invoice",
     "files",
     "quota"
    ],
    "title": "ConvertResponse"
   },
   "ErrorBody": {
    "properties": {
     "code": {
      "type": "string",
      "title": "Code",
      "examples": [
       "quota_exceeded"
      ]
     },
     "message": {
      "type": "string",
      "title": "Message",
      "examples": [
       "Monthly conversion quota reached (100 for plan pro)."
      ]
     }
    },
    "type": "object",
    "required": [
     "code",
     "message"
    ],
    "title": "ErrorBody"
   },
   "ErrorResponse": {
    "properties": {
     "error": {
      "$ref": "#/components/schemas/ErrorBody"
     }
    },
    "type": "object",
    "required": [
     "error"
    ],
    "title": "ErrorResponse"
   },
   "Quota": {
    "properties": {
     "plan": {
      "type": "string",
      "title": "Plan",
      "examples": [
       "pro"
      ]
     },
     "used": {
      "type": "integer",
      "title": "Used",
      "examples": [
       12
      ]
     },
     "limit": {
      "type": "integer",
      "title": "Limit",
      "examples": [
       100
      ]
     },
     "month": {
      "type": "string",
      "title": "Month",
      "examples": [
       "2026-11"
      ]
     },
     "credits_left": {
      "anyOf": [
       {
        "type": "integer"
       },
       {
        "type": "null"
       }
      ],
      "title": "Credits Left",
      "description": "Remaining conversions in a one-time pack.",
      "examples": [
       10
      ]
     },
     "expires": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Expires",
      "description": "ISO date when the current pack credits expire.",
      "examples": [
       "2027-12-01"
      ]
     }
    },
    "type": "object",
    "required": [
     "plan",
     "used",
     "limit",
     "month"
    ],
    "title": "Quota"
   },
   "ValidateResponse": {
    "properties": {
     "ok": {
      "type": "boolean",
      "title": "Ok"
     },
     "engine": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Engine"
     },
     "engines": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Engines"
     },
     "errors": {
      "items": {},
      "type": "array",
      "title": "Errors",
      "default": []
     },
     "warnings": {
      "items": {},
      "type": "array",
      "title": "Warnings",
      "default": []
     },
     "info": {
      "anyOf": [
       {
        "items": {},
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Info"
     }
    },
    "type": "object",
    "required": [
     "ok"
    ],
    "title": "ValidateResponse",
    "examples": [
     {
      "ok": true,
      "engine": "fr-xp-z12-012",
      "engines": [
       "FNFE-MPE 1.4.0.04: XSD CrossIndustryInvoice_100pD22B.xsd",
       "FNFE-MPE 1.4.0.04: EXTENDED-CTC-FR CII",
       "FNFE-MPE 1.4.0.04: BR-FR (règles France) CII"
      ],
      "errors": [],
      "warnings": [],
      "info": []
     }
    ]
   },
   "ConvertRequest": {
    "properties": {
     "file": {
      "type": "string",
      "contentMediaType": "application/octet-stream",
      "title": "File",
      "description": "PDF, XLSX, XLSM or DOCX invoice, max 10 MB",
      "format": "binary"
     },
     "country": {
      "type": "string",
      "title": "Country",
      "description": "de | pl | be | ae",
      "enum": [
       "de",
       "pl",
       "be",
       "ae"
      ],
      "examples": [
       "de"
      ]
     },
     "format": {
      "type": "string",
      "title": "Format",
      "description": "Output format for the country; empty = country default (de: xrechnung-ubl, xrechnung-cii, zugferd; pl: ksef-fa3; be: peppol-bis3; ae: pint-ae)",
      "default": "",
      "enum": [
       "",
       "xrechnung-ubl",
       "xrechnung-cii",
       "zugferd",
       "ksef-fa3",
       "peppol-bis3",
       "pint-ae"
      ],
      "examples": [
       "xrechnung-ubl"
      ]
     },
     "patch": {
      "type": "string",
      "title": "Patch",
      "description": "Optional JSON object with values for fields listed in `missing`",
      "default": ""
     }
    },
    "type": "object",
    "required": [
     "file",
     "country"
    ],
    "title": "ConvertRequest"
   },
   "ValidateRequest": {
    "properties": {
     "file": {
      "type": "string",
      "contentMediaType": "application/octet-stream",
      "title": "File",
      "description": "XRechnung (UBL/CII), ZUGFeRD XML, Peppol BIS 3.0, KSeF FA(3) or PINT-AE XML, max 10 MB",
      "format": "binary"
     }
    },
    "type": "object",
    "required": [
     "file"
    ],
    "title": "ValidateRequest"
   }
  },
  "securitySchemes": {
   "HTTPBearer": {
    "type": "http",
    "description": "API key (vf_…) from the Pro, Office or api plan e-mail.",
    "scheme": "bearer",
    "bearerFormat": "vf_..."
   }
  }
 },
 "externalDocs": {
  "description": "API reference",
  "url": "https://valifakt.com/en/api-reference.html"
 },
 "tags": [
  {
   "name": "Invoices",
   "description": "Convert and validate e-invoices; download converted files."
  },
  {
   "name": "Account",
   "description": "Plan and monthly usage."
  }
 ],
 "security": [
  {
   "HTTPBearer": []
  }
 ]
}
