{"openapi":"3.1.0","info":{"title":"Lexispect API","version":"1.0.0","description":"Analyse de contrats financiers et juridiques. Chaque appel applique les mêmes règles que l'application web : quota du plan, plafond de dépense IA, et refus des catégories non couvertes par un rapport.\n\n**Information, pas conseil.** Les analyses produites sont de l'information générale ; elles ne constituent pas une consultation juridique (art. 54 de la loi n° 71-1130).","contact":{"name":"Lexispect","url":"https://lexispect.com"}},"servers":[{"url":"https://lexispect.com/api/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Clé au format `lxp_live_…`, transmise en en-tête `Authorization: Bearer …`. La clé n’est affichée qu’à sa création et ne peut pas être retrouvée ensuite."}},"schemas":{"AnalyseSummary":{"type":"object","properties":{"id":{"type":"integer","example":1247},"reference":{"type":"string","example":"LX-260825-K7F3B2"},"title":{"type":"string"},"category":{"type":["string","null"],"example":"assurance_emprunteur"},"country":{"type":"string","enum":["fr","be"],"example":"fr"},"created_at":{"type":"string","format":"date-time"},"score":{"type":"object","description":"Score du contrat. ⚠ `toxicity` va de 0 (sain) à 10 (toxique) — `health` en est l’inverse. Ne pas confondre les deux orientations.","properties":{"toxicity":{"type":"number","minimum":0,"maximum":10,"example":7.2},"health":{"type":"number","minimum":0,"maximum":10,"example":2.8},"band":{"type":"string","enum":["sain","attention","risque","toxique"]},"deterministic":{"type":"boolean","description":"true = score recalculé depuis la grille du vertical. false = heuristique de repli (analyse antérieure au format V2)."}}}}},"Error":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}},"responses":{"Unauthorized":{"description":"Clé absente, invalide ou révoquée.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}},"RateLimited":{"description":"Limite de requêtes par minute atteinte pour cette clé. Les en-têtes `X-RateLimit-Limit`, `X-RateLimit-Remaining` et `Retry-After` accompagnent chaque réponse.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}}}},"paths":{"/me":{"get":{"summary":"Identité, plan et quota restant","description":"Premier appel à effectuer pour vérifier une clé.","responses":{"200":{"description":"Informations du compte.","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"integer"},"email":{"type":"string"},"plan":{"type":"string"}}},"api_key":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"prefix":{"type":"string","example":"lxp_live_a1b2c3d4"}}},"quota":{"type":["object","null"],"properties":{"total":{"type":"integer"},"remaining":{"type":"integer"},"kind":{"type":"string"}}},"analyses_count":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/analyses":{"get":{"summary":"Lister ses analyses","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}}],"responses":{"200":{"description":"Analyses, les plus récentes d’abord.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AnalyseSummary"}},"count":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Analyser un contrat","description":"Analyse synchrone : la réponse arrive une fois l’analyse terminée. Prévoyez un délai d’attente client généreux — la durée dépend de la longueur du document. Le PDF n'est pas généré par cet appel.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":200,"maxLength":200000,"description":"Texte intégral du contrat."},"title":{"type":"string","maxLength":120},"category":{"type":"string","description":"Force la catégorie et court-circuite le classifieur. Omettre pour une détection automatique."},"country":{"type":"string","enum":["fr","be"],"default":"fr","description":"Pays de référence du contrat : détermine le barème fiscal et les repères réglementaires cités dans le rapport."}}}}}},"responses":{"201":{"description":"Analyse créée.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyseSummary"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Quota d’analyses du plan épuisé.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}},"422":{"description":"Requête invalide, ou catégorie non couverte par un rapport. Dans ce dernier cas, aucun quota n’est décompté.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"502":{"description":"L’analyse n’a pas abouti (échec du modèle et de son repli).","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}},"503":{"description":"Plafond de dépense IA atteint pour la journée.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}}}}},"/analyses/{id}":{"get":{"summary":"Détail d’une analyse","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Analyse, avec son rapport structuré complet.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AnalyseSummary"},{"type":"object","properties":{"report_data":{"type":["object","null"],"description":"Rapport structuré complet (score, coûts, risques, conditions de sortie, plan d’action, glossaire, mentions)."}}}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Analyse inexistante, ou appartenant à un autre compte.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"quota_exceeded"},"message":{"type":"string"}}}}}},"429":{"$ref":"#/components/responses/RateLimited"}}}}}}