{
  "openapi": "3.1.0",
  "info": {
    "title": "Xynthera AI \u2014 three prepaid operations",
    "version": "2026-10-13",
    "description": "Manual checkout; prepaid Bearer capability. Client-declared data checks only. Complete input details can be stricter than this overview for contract offer/observation fields."
  },
  "servers": [
    {
      "url": "https://pfxxzsnboehxsefyajml.supabase.co/functions/v1/xynthera-ai-payg"
    }
  ],
  "security": [
    {
      "BudgetBearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BudgetBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private saved payg.UUID.secret capability, never x-api-key."
      }
    }
  },
  "paths": {
    "/v1/invoices/reconcile": {
      "post": {
        "operationId": "invoiceCheck",
        "summary": "Invoice check: 5000 micro-EUR excluding tax",
        "description": "Explicit paid API call. Valid findings are charged even if inconsistent. Save receipt/report/signature yourself. Reuse the exact request ID/body for manual retries; no autonomous payment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "request_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                  },
                  "invoice": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                      },
                      "supplier_id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                      },
                      "currency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$",
                        "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
                      },
                      "minor_digits": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 4
                      },
                      "beneficiary_ref": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$",
                        "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
                      },
                      "lines": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                            },
                            "item_ref": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                            },
                            "quantity": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000000
                            },
                            "unit_price_minor": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000000000
                            },
                            "discount_minor": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000000000
                            },
                            "tax_minor": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000000000
                            }
                          },
                          "required": [
                            "id",
                            "item_ref",
                            "quantity",
                            "unit_price_minor",
                            "tax_minor"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 100
                      },
                      "total_minor": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000000000000
                      }
                    },
                    "required": [
                      "id",
                      "supplier_id",
                      "currency",
                      "minor_digits",
                      "lines",
                      "total_minor"
                    ]
                  },
                  "purchase_order": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                      },
                      "supplier_id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                      },
                      "currency": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$",
                        "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
                      },
                      "minor_digits": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 4
                      },
                      "lines": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "item_ref": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                            },
                            "quantity": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000000
                            },
                            "unit_price_minor": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000000000
                            }
                          },
                          "required": [
                            "item_ref",
                            "quantity",
                            "unit_price_minor"
                          ]
                        },
                        "minItems": 0,
                        "maxItems": 100
                      }
                    },
                    "required": [
                      "id",
                      "supplier_id",
                      "currency",
                      "minor_digits",
                      "lines"
                    ]
                  },
                  "receipts": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "po_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "supplier_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "lines": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "item_ref": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                              },
                              "quantity": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000000
                              }
                            },
                            "required": [
                              "item_ref",
                              "quantity"
                            ]
                          },
                          "minItems": 0,
                          "maxItems": 100
                        }
                      },
                      "required": [
                        "id",
                        "po_id",
                        "supplier_id",
                        "lines"
                      ]
                    },
                    "minItems": 0,
                    "maxItems": 20
                  },
                  "payments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "invoice_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "supplier_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$",
                          "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
                        },
                        "minor_digits": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 4
                        },
                        "amount_minor": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000000000000
                        },
                        "beneficiary_ref": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$",
                          "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
                        }
                      },
                      "required": [
                        "id",
                        "invoice_id",
                        "supplier_id",
                        "currency",
                        "minor_digits",
                        "amount_minor"
                      ]
                    },
                    "minItems": 0,
                    "maxItems": 20
                  },
                  "history": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "invoice_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "supplier_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$",
                          "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
                        },
                        "total_minor": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000000000000
                        },
                        "minor_digits": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 4
                        }
                      },
                      "required": [
                        "invoice_id",
                        "supplier_id",
                        "currency",
                        "total_minor",
                        "minor_digits"
                      ]
                    },
                    "minItems": 0,
                    "maxItems": 100
                  },
                  "supplier_profile": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "supplier_id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                      },
                      "approved_beneficiary_ref": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$",
                        "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
                      }
                    },
                    "required": [
                      "supplier_id",
                      "approved_beneficiary_ref"
                    ]
                  }
                },
                "required": [
                  "request_id",
                  "invoice"
                ],
                "$schema": "https://json-schema.org/draft/2020-12/schema",
                "$id": "https://xynthera-ai.toasty-seal-8877.chatgpt.site/schemas/invoice-reconcile-request.json",
                "title": "Xynthera Invoice Reconciliation request",
                "description": "64 KiB maximum complete JSON body; nesting depth 20; 4000 input nodes; 100 receipt lines in total across supplied receipts. Those aggregate limits are additionally enforced by core."
              },
              "example": {
                "request_id": "synthetic-invoice-001",
                "invoice": {
                  "id": "INV-001",
                  "supplier_id": "SUP-001",
                  "currency": "EUR",
                  "minor_digits": 2,
                  "beneficiary_ref": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                  "lines": [
                    {
                      "id": "LINE-1",
                      "item_ref": "SKU-1",
                      "quantity": 2,
                      "unit_price_minor": 1000,
                      "discount_minor": 100,
                      "tax_minor": 380
                    }
                  ],
                  "total_minor": 2280
                },
                "purchase_order": {
                  "id": "PO-001",
                  "supplier_id": "SUP-001",
                  "currency": "EUR",
                  "minor_digits": 2,
                  "lines": [
                    {
                      "item_ref": "SKU-1",
                      "quantity": 2,
                      "unit_price_minor": 1000
                    }
                  ]
                },
                "receipts": [
                  {
                    "id": "GR-001",
                    "po_id": "PO-001",
                    "supplier_id": "SUP-001",
                    "lines": [
                      {
                        "item_ref": "SKU-1",
                        "quantity": 2
                      }
                    ]
                  }
                ],
                "payments": [
                  {
                    "id": "PAY-001",
                    "invoice_id": "INV-001",
                    "supplier_id": "SUP-001",
                    "currency": "EUR",
                    "minor_digits": 2,
                    "amount_minor": 2280,
                    "beneficiary_ref": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                  }
                ],
                "history": [],
                "supplier_profile": {
                  "supplier_id": "SUP-001",
                  "approved_beneficiary_ref": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated signed result; inspect receipt.report.analysis. replayed=true may omit remaining.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "receipt",
                    "replayed"
                  ],
                  "properties": {
                    "receipt": {
                      "type": "object",
                      "required": [
                        "report",
                        "signature"
                      ],
                      "properties": {
                        "report": {
                          "type": "object"
                        },
                        "signature": {
                          "type": "object"
                        }
                      }
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "remaining": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; no debit"
          },
          "401": {
            "description": "Authentication required"
          },
          "402": {
            "description": "Paid access required or credits exhausted"
          },
          "409": {
            "description": "Conflicting ID, expired replay metadata or changed report policy"
          },
          "413": {
            "description": "Body/structure/result limit"
          },
          "503": {
            "description": "Service unavailable; preserve same ID/body if outcome unknown"
          }
        }
      }
    },
    "/v1/contracts/check": {
      "post": {
        "operationId": "contractCheck",
        "summary": "Contract check: 10000 micro-EUR excluding tax",
        "description": "Explicit paid API call. Valid findings are charged even if inconsistent. Save receipt/report/signature yourself. Reuse the exact request ID/body for manual retries; no autonomous payment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "request_id",
                  "document"
                ],
                "properties": {
                  "request_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                  },
                  "document": {
                    "type": "object",
                    "description": "Supplied OpenAPI 3.x document. External references are not fetched."
                  },
                  "offer": {
                    "type": "object"
                  },
                  "published_offer": {
                    "type": "object"
                  },
                  "observations": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "object"
                    }
                  }
                }
              },
              "example": {
                "request_id": "synthetic-contract-001",
                "document": {
                  "openapi": "3.0.3",
                  "info": {
                    "title": "Synthetic example",
                    "version": "1.0.0"
                  },
                  "paths": {
                    "/example": {
                      "get": {
                        "responses": {
                          "200": {
                            "description": "Successful synthetic response"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated signed result; inspect receipt.report.analysis. replayed=true may omit remaining.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "receipt",
                    "replayed"
                  ],
                  "properties": {
                    "receipt": {
                      "type": "object",
                      "required": [
                        "report",
                        "signature"
                      ],
                      "properties": {
                        "report": {
                          "type": "object"
                        },
                        "signature": {
                          "type": "object"
                        }
                      }
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "remaining": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; no debit"
          },
          "401": {
            "description": "Authentication required"
          },
          "402": {
            "description": "Paid access required or credits exhausted"
          },
          "409": {
            "description": "Conflicting ID, expired replay metadata or changed report policy"
          },
          "413": {
            "description": "Body/structure/result limit"
          },
          "503": {
            "description": "Service unavailable; preserve same ID/body if outcome unknown"
          }
        }
      }
    },
    "/v1/events/check": {
      "post": {
        "operationId": "eventsCheck",
        "summary": "Events check: 2000 micro-EUR excluding tax",
        "description": "Explicit paid API call. Valid findings are charged even if inconsistent. Save receipt/report/signature yourself. Reuse the exact request ID/body for manual retries; no autonomous payment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "request_id",
                  "events"
                ],
                "properties": {
                  "request_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "stream",
                        "sequence",
                        "timestamp"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "stream": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "sequence": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "timestamp": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "payload_hash": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$"
                        }
                      }
                    }
                  },
                  "require_contiguous": {
                    "type": "boolean"
                  },
                  "same_clock": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "request_id": "synthetic-events-001",
                "events": [
                  {
                    "id": "evt-001",
                    "stream": "synthetic-stream",
                    "sequence": 1,
                    "timestamp": "2026-10-13T12:00:00Z"
                  },
                  {
                    "id": "evt-002",
                    "stream": "synthetic-stream",
                    "sequence": 2,
                    "timestamp": "2026-10-13T12:01:00Z"
                  }
                ],
                "require_contiguous": true,
                "same_clock": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculated signed result; inspect receipt.report.analysis. replayed=true may omit remaining.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "receipt",
                    "replayed"
                  ],
                  "properties": {
                    "receipt": {
                      "type": "object",
                      "required": [
                        "report",
                        "signature"
                      ],
                      "properties": {
                        "report": {
                          "type": "object"
                        },
                        "signature": {
                          "type": "object"
                        }
                      }
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "remaining": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; no debit"
          },
          "401": {
            "description": "Authentication required"
          },
          "402": {
            "description": "Paid access required or credits exhausted"
          },
          "409": {
            "description": "Conflicting ID, expired replay metadata or changed report policy"
          },
          "413": {
            "description": "Body/structure/result limit"
          },
          "503": {
            "description": "Service unavailable; preserve same ID/body if outcome unknown"
          }
        }
      }
    }
  }
}
