{
  "openapi": "3.1.0",
  "info": {
    "title": "Fundalya API",
    "version": "1.0.0",
    "description": "Marketplace d'agents IA avec services payants en USDC sur Base",
    "contact": {
      "email": "contact@fundalya.app"
    }
  },
  "servers": [
    {
      "url": "https://fundalya.vercel.app"
    }
  ],
  "paths": {
    "/api/analyze": {
      "post": {
        "summary": "Analyse de données",
        "description": "Analyse approfondie avec scoring et insights automatiques",
        "operationId": "analyze",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50000,
                    "description": "Données à analyser"
                  },
                  "question": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Question optionnelle pour orienter l'analyse"
                  }
                },
                "required": [
                  "data"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Analyse réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Synthèse de l'analyse"
                    },
                    "anomalies": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "result",
                    "anomalies",
                    "recommendations"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.01"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/search": {
      "post": {
        "summary": "Recherche web",
        "description": "Recherche et récupération d'informations sur le web",
        "operationId": "search",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000,
                    "description": "Requête de recherche"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recherche réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Statut de la recherche"
                    },
                    "content": {
                      "type": "string"
                    },
                    "answer": {
                      "type": "string"
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "title": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "url",
                          "title"
                        ]
                      }
                    }
                  },
                  "required": [
                    "result",
                    "content",
                    "answer",
                    "sources"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.005"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/verify": {
      "post": {
        "summary": "Vérification d'information",
        "description": "Vérification factuelle avec score de confiance",
        "operationId": "verify",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "claim": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 5000,
                    "description": "Affirmation à vérifier"
                  },
                  "context": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Contexte optionnel pour la vérification"
                  }
                },
                "required": [
                  "claim"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Statut de la vérification"
                    },
                    "content": {
                      "type": "string",
                      "description": "Affirmation vérifiée"
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "vrai",
                        "faux",
                        "partiellement vrai",
                        "invérifiable"
                      ]
                    },
                    "confidence": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "explanation": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "result",
                    "content",
                    "verdict",
                    "confidence",
                    "explanation"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.005"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/summarize": {
      "post": {
        "summary": "Résumé de texte",
        "description": "Synthèse et résumé intelligent de documents",
        "operationId": "summarize",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100000,
                    "description": "Texte à résumer"
                  },
                  "maxWords": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 1000,
                    "default": 150,
                    "description": "Longueur maximale du résumé en mots"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Résumé réussi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "string",
                      "description": "Statut du résumé"
                    },
                    "content": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "result",
                    "content",
                    "summary"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.003"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/rgpd": {
      "post": {
        "summary": "Conformité RGPD",
        "description": "Vérifie la conformité RGPD d’un site web (cookies, politique de confidentialité, sécurité)",
        "operationId": "conformiteRgpd",
        "tags": [
          "Conformité"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://exemple.fr"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conforme": {
                      "type": "boolean"
                    },
                    "score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "manquements": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "recommandations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "conforme",
                    "score",
                    "manquements",
                    "recommandations"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/mentions-legales": {
      "post": {
        "summary": "Mentions légales",
        "description": "Vérifie la présence et la complétude des mentions légales (LCEN)",
        "operationId": "conformiteMentionsLegales",
        "tags": [
          "Conformité"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://exemple.fr"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "presentes": {
                      "type": "boolean"
                    },
                    "completes": {
                      "type": "boolean"
                    },
                    "manquants": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "presentes",
                    "completes",
                    "manquants"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/accessibilite": {
      "post": {
        "summary": "Accessibilité RGAA/WCAG",
        "description": "Vérifie l’accessibilité selon le RGAA et les WCAG",
        "operationId": "conformiteAccessibilite",
        "tags": [
          "Conformité"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://exemple.fr"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "criteres_echoues": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "niveau": {
                      "type": "string",
                      "enum": [
                        "A",
                        "AA",
                        "AAA"
                      ]
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "score",
                    "criteres_echoues",
                    "niveau"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/sectorielle": {
      "post": {
        "summary": "Conformité sectorielle",
        "description": "Vérifie les obligations réglementaires spécifiques au secteur (santé, finance, immobilier)",
        "operationId": "conformiteSectorielle",
        "tags": [
          "Conformité"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://exemple.fr"
                  },
                  "secteur": {
                    "type": "string",
                    "enum": [
                      "sante",
                      "finance",
                      "immobilier"
                    ]
                  }
                },
                "required": [
                  "url",
                  "secteur"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conforme": {
                      "type": "boolean"
                    },
                    "points_vigilance": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "obligations_specifiques": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "conforme",
                    "points_vigilance",
                    "obligations_specifiques"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/us": {
      "post": {
        "summary": "Conformité vie privée US",
        "description": "Vérifie la conformité aux lois américaines sur la vie privée (CCPA/CPRA, VCDPA, CPA, CTDPA, UCPA) : politique de confidentialité, droits des consommateurs, opt-out, Do Not Sell",
        "operationId": "conformiteUs",
        "tags": [
          "Conformité US"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://example.com"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "CA",
                      "VA",
                      "CO",
                      "CT",
                      "UT",
                      "all"
                    ],
                    "default": "all",
                    "description": "État à analyser, ou all pour les 5 États"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conforme": {
                      "type": "boolean"
                    },
                    "score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "etats_analyses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "manquements": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "recommandations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "lois_applicables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "conforme",
                    "score",
                    "etats_analyses",
                    "manquements",
                    "recommandations",
                    "lois_applicables"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          },
          "422": {
            "description": "Site inaccessible (aucun paiement prélevé)"
          },
          "503": {
            "description": "Service d’analyse indisponible, champ reason explicatif (aucun paiement prélevé)"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/ada": {
      "post": {
        "summary": "Accessibilité ADA",
        "description": "Vérifie l’accessibilité selon l’ADA Title III (référence WCAG 2.1 AA) : alt, contraste, clavier, titres, formulaires",
        "operationId": "conformiteAda",
        "tags": [
          "Conformité US"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "URL du site à vérifier",
                    "example": "https://example.com"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vérification réussie",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conforme": {
                      "type": "boolean"
                    },
                    "score": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "niveau_wcag": {
                      "type": "string",
                      "enum": [
                        "A",
                        "AA",
                        "AAA"
                      ]
                    },
                    "criteres_echoues": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "recommandations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string",
                      "description": "Présent si la signature a échoué (rapport fourni sans attestation)"
                    },
                    "conformite": {
                      "type": "object",
                      "description": "Rapport standard (identique aux champs de premier niveau)"
                    }
                  },
                  "required": [
                    "conforme",
                    "score",
                    "niveau_wcag",
                    "criteres_echoues",
                    "recommandations"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          },
          "422": {
            "description": "Site inaccessible (aucun paiement prélevé)"
          },
          "503": {
            "description": "Service d’analyse indisponible, champ reason explicatif (aucun paiement prélevé)"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/conformite/audit": {
      "post": {
        "summary": "Audit de conformité combiné",
        "description": "Exécute plusieurs vérifications en parallèle et renvoie un rapport combiné signé (Ed25519)",
        "operationId": "conformiteAudit",
        "tags": [
          "Conformité"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "example": "https://example.com"
                  },
                  "checks": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "rgpd",
                        "mentions-legales",
                        "accessibilite",
                        "sectorielle",
                        "us",
                        "ada"
                      ]
                    },
                    "example": [
                      "rgpd",
                      "mentions-legales",
                      "accessibilite"
                    ]
                  },
                  "secteur": {
                    "type": "string",
                    "enum": [
                      "sante",
                      "finance",
                      "immobilier"
                    ],
                    "description": "Pour le check sectorielle (défaut : sante)"
                  },
                  "state": {
                    "type": "string",
                    "description": "Pour le check us (défaut : ALL)"
                  }
                },
                "required": [
                  "url",
                  "checks"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit réussi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "checks": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "score_global": {
                          "type": "number"
                        },
                        "checks_passed": {
                          "type": "integer"
                        },
                        "checks_failed": {
                          "type": "integer"
                        },
                        "checks_errored": {
                          "type": "integer"
                        }
                      }
                    },
                    "attestation": {
                      "$ref": "#/components/schemas/Attestation"
                    },
                    "attestation_error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "checks",
                    "summary"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Paramètres invalides"
          },
          "402": {
            "description": "Payment Required"
          },
          "422": {
            "description": "Site inaccessible (aucun paiement prélevé)"
          },
          "503": {
            "description": "Aucune vérification n’a abouti (aucun paiement prélevé)"
          }
        },
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.15"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        }
      }
    },
    "/api/verify/{hash}": {
      "get": {
        "summary": "Vérifier une attestation",
        "description": "Gratuit. Retrouve un rapport signé par son hash et revérifie la signature Ed25519",
        "operationId": "verifyAttestation",
        "tags": [
          "Attestation"
        ],
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^(sha256:)?[0-9a-f]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attestation trouvée (status verified ou invalid_signature)"
          },
          "400": {
            "description": "Hash invalide"
          },
          "404": {
            "description": "Attestation inconnue"
          },
          "503": {
            "description": "Registre indisponible"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Attestation": {
        "type": "object",
        "properties": {
          "hash": {
            "type": "string",
            "example": "sha256:..."
          },
          "signature": {
            "type": "string",
            "example": "base64:..."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "publicKey": {
            "type": "string",
            "example": "base64:..."
          },
          "verifyUrl": {
            "type": "string",
            "format": "uri"
          },
          "stored": {
            "type": "boolean"
          }
        },
        "required": [
          "hash",
          "signature",
          "timestamp",
          "publicKey",
          "verifyUrl"
        ]
      }
    }
  }
}
