{
  "openapi": "3.1.0",
  "info": { "title": "Fynvoice API", "version": "0.1.0", "description": "Sandbox contract for invoice liquidity infrastructure. Sandbox responses are mock data." },
  "servers": [{ "url": "https://sandbox-api.fynvoice.com", "description": "Sandbox - safe mock data" }, { "url": "https://api.fynvoice.com", "description": "Live - restricted, coming soon" }],
  "security": [{ "bearerAuth": [] }, { "apiKeyAuth": [] }],
  "paths": {
    "/api/invoices": { "get": { "summary": "List invoices", "responses": { "200": { "$ref": "#/components/responses/ListResponse" }, "401": { "$ref": "#/components/responses/Error" } } }, "post": { "summary": "Create invoice", "requestBody": { "$ref": "#/components/requestBodies/Invoice" }, "responses": { "201": { "$ref": "#/components/responses/InvoiceResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/invoices/{id}": { "get": { "summary": "Get invoice", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "example": "inv-001" }], "responses": { "200": { "$ref": "#/components/responses/InvoiceResponse" }, "404": { "$ref": "#/components/responses/Error" } } } },
    "/api/registry/fingerprint": { "post": { "summary": "Generate invoice fingerprint", "requestBody": { "$ref": "#/components/requestBodies/Invoice" }, "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/verification/run": { "post": { "summary": "Run mock verification", "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/financing-requests": { "get": { "summary": "List financing requests", "responses": { "200": { "$ref": "#/components/responses/ListResponse" } } }, "post": { "summary": "Create financing request", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "201": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/offers": { "get": { "summary": "List offers", "responses": { "200": { "$ref": "#/components/responses/ListResponse" } } }, "post": { "summary": "Create indicative offer", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "201": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/partners": { "get": { "summary": "List configured partners", "responses": { "200": { "$ref": "#/components/responses/ListResponse" } } } },
    "/api/partners/route": { "post": { "summary": "Run mock partner routing", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/audit-log": { "get": { "summary": "List audit events", "responses": { "200": { "$ref": "#/components/responses/ListResponse" } } } },
    "/api/webhooks/test": { "post": { "summary": "Send mock webhook delivery", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/webhooks": { "get": { "summary": "List webhook endpoints and deliveries", "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } }, "post": { "summary": "Create webhook endpoint", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "201": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/connectors/erp/invoices": { "post": { "summary": "Push normalized ERP invoice payload", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "202": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } } },
    "/api/auth/session": { "get": { "summary": "Retrieve demo role session", "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/assignment-rules/{country}": { "get": { "summary": "Retrieve assignment policy placeholder", "parameters": [{ "name": "country", "in": "path", "required": true, "schema": { "type": "string" }, "example": "FR" }], "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/health": { "get": { "summary": "Service health check", "security": [], "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/auth/login": { "post": { "summary": "Create authenticated workspace session", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" }, "401": { "$ref": "#/components/responses/Error" } } } },
    "/api/auth/logout": { "post": { "summary": "Clear authenticated workspace session", "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/storage/invoices/upload-url": { "post": { "summary": "Create private invoice-file upload URL", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } },
    "/api/developer/api-keys": { "get": { "summary": "List API key metadata", "responses": { "200": { "$ref": "#/components/responses/ListResponse" } } }, "post": { "summary": "Create sandbox API key", "requestBody": { "$ref": "#/components/requestBodies/Generic" }, "responses": { "201": { "$ref": "#/components/responses/ObjectResponse" }, "400": { "$ref": "#/components/responses/Error" } } }, "delete": { "summary": "Revoke API key", "parameters": [{ "name": "id", "in": "query", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "$ref": "#/components/responses/ObjectResponse" } } } }
  },
  "components": {
    "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" }, "apiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" } },
    "schemas": {
      "InvoiceInput": { "type": "object", "required": ["sellerId", "debtorId", "invoiceNumber", "amount", "currency"], "properties": { "sellerId": { "type": "string", "example": "cmp-lum" }, "debtorId": { "type": "string", "example": "cmp-nor" }, "invoiceNumber": { "type": "string", "example": "LO-2026-0418" }, "amount": { "type": "number", "example": 84200 }, "currency": { "type": "string", "example": "EUR" }, "issueDate": { "type": "string", "format": "date", "example": "2026-04-18" }, "dueDate": { "type": "string", "format": "date", "example": "2026-07-17" } } },
      "Invoice": { "allOf": [{ "$ref": "#/components/schemas/InvoiceInput" }, { "type": "object", "properties": { "id": { "type": "string", "example": "inv-001" }, "registryId": { "type": "string", "example": "FYN-FR-2026-000184" }, "status": { "type": "string", "example": "Verified" } } }] },
      "Error": { "type": "object", "properties": { "error": { "type": "object", "properties": { "code": { "type": "string", "example": "invalid_request" }, "message": { "type": "string", "example": "invoiceNumber is required" }, "requestId": { "type": "string", "example": "req_sandbox_01HY" } } }, "mode": { "type": "string", "example": "sandbox_mock" } } }
    },
    "requestBodies": { "Invoice": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InvoiceInput" } } } }, "Generic": { "required": true, "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true }, "example": { "environment": "sandbox" } } } } },
    "responses": {
      "InvoiceResponse": { "description": "Invoice response", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Invoice" }, "mode": { "type": "string", "example": "sandbox_mock" } } } } } },
      "ObjectResponse": { "description": "Object response", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "object", "additionalProperties": true }, "mode": { "type": "string", "example": "sandbox_mock" } } } } } },
      "ListResponse": { "description": "List response", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "type": "object", "additionalProperties": true } }, "mode": { "type": "string", "example": "sandbox_mock" } } } } } },
      "Error": { "description": "Error response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    }
  }
}
