{
 "openapi": "3.0.3",
 "info": {
  "title": "mcpgarden.com — API per agenti",
  "version": "1.0",
  "description": "Dati di riferimento ufficiali italiani (tassi BCE, cambi, aliquote IVA, partite IVA, bandi pubblici) e inferenza LLM, pagati per chiamata. Ogni valore riporta fonte, data di vigore e ultima verifica: la risposta e' auditabile.\n\nPagamento: due strade indipendenti. (1) x402 — il server risponde 402 con l'header PAYMENT-REQUIRED (base64 del PaymentRequired), il client firma (EIP-3009) e ripete la richiesta con l'header PAYMENT-SIGNATURE; la risposta porta PAYMENT-RESPONSE. (2) Credito prepagato — il client compra un pacchetto via POST /v1/acquisto, riceve una chiave API e usa Authorization: Bearer <chiave>. Vedi l'estensione x-x402 sui path a pagamento per le reti e gli indirizzi."
 },
 "servers": [
  {
   "url": "https://api.mcpgarden.com"
  }
 ],
 "securitySchemes": {
  "bearer": {
   "type": "http",
   "scheme": "bearer",
   "description": "Chiave API del credito prepagato (agents_live_...)."
  }
 },
 "tags": [
  {
   "name": "gratuiti",
   "description": "Accesso libero, senza pagamento."
  },
  {
   "name": "pagati",
   "description": "x402 (USDC) o credito prepagato (Bearer)."
  },
  {
   "name": "credito",
   "description": "Acquisto e gestione del credito prepagato."
  }
 ],
 "paths": {
  "/health": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Stato del servizio: db, coda task, pool di inferenza.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          },
          "db": {
           "type": "string"
          },
          "tasks": {
           "type": "object"
          },
          "pool": {
           "type": "object",
           "properties": {
            "window_id": {
             "type": "integer"
            },
            "window_seconds": {
             "type": "integer"
            },
            "providers": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "model": {
                "type": "string"
               },
               "quota_per_window": {
                "type": "integer"
               },
               "used": {
                "type": "integer"
               },
               "remaining": {
                "type": [
                 "integer",
                 "null"
                ]
               },
               "quota_dichiarata": {
                "type": "boolean"
               },
               "price_usd_per_call": {
                "type": "number"
               },
               "enabled": {
                "type": "boolean"
               },
               "circuit": {
                "type": "object",
                "properties": {
                 "stato": {
                  "type": "string",
                  "enum": [
                   "closed",
                   "open",
                   "half-open"
                  ]
                 },
                 "fallimenti": {
                  "type": "integer"
                 },
                 "ultimo_errore": {
                  "type": [
                   "string",
                   "null"
                  ]
                 }
                }
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/scrape": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Scrape di una pagina pubblica: si scarica, si ripulisce e si restituisce il testo; con modalita'='strutturato' si tirano fuori i dati richiesti in JSON.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "url": {
           "type": "string"
          },
          "url_finale": {
           "type": "string"
          },
          "titolo": {
           "type": "string"
          },
          "modalita": {
           "type": "string"
          },
          "caratteri": {
           "type": "integer"
          },
          "testo": {
           "type": "string"
          },
          "estratto": {
           "type": "object"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/immagine": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Genera un'immagine da un prompt testuale. Il provider concede 300 generazioni al giorno: quando il tetto e' raggiunto si risponde 502 e il cliente non paga.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "modello": {
           "type": "string"
          },
          "dimensione": {
           "type": "string"
          },
          "latency_ms": {
           "type": "integer"
          },
          "immagini": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "b64_json": {
              "type": "string"
             },
             "url": {
              "type": "string"
             },
             "bytes": {
              "type": "integer"
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/listino": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Il listino: i prezzi fissi di ogni servizio, in USD ed EUR, e i pacchetti venduti in blocco a prezzo scontato.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/pacchetto": {
   "post": {
    "tags": [
     "credito"
    ],
    "summary": "Compra un pacchetto di credito in blocco: si paga una volta sola con la carta e si accredita piu' credito di quanto si paga.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/nlp": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Task NLP su un testo: classificazione, sentiment, keyword, outline.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/token-verdict": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Dati on-chain di un token ERC-20 su Base e verdetto del modello, con i motivi.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/dns-whois": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Lookup DNS (A, MX, TXT, NS) e WHOIS di un dominio.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/email-check": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Valida un indirizzo email: formato e record MX del dominio.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/security-headers": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Controlla gli header di sicurezza di una URL (HSTS, CSP, X-Frame-Options...) e dice cosa manca.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/barcode": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Identifica un prodotto alimentare da codice EAN/UPC (Open Food Facts).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/barcode-image": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Immagine del prodotto alimentare di un codice EAN/UPC, in base64 o come URL.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/product-search": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Cerca prodotti alimentari per nome, categoria o paese. Il prezzo e' per record.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/product-ai": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Interroga in linguaggio naturale il database dei prodotti alimentari.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/search": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Ricerca sul web e sintesi in linguaggio naturale, con i risultati citati.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/band-search": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Cerca fra i bandi pubblici raccolti: testo, ente, fonte, importo e scadenza.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/pdf": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Estrae il testo di un PDF da una URL o da un base64, con pagine e metadati.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/timezone": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Converte fusi orari e date.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/fx": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Cambi valuta (tassi BCE del giorno) e conversione di un importo.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/utils": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Validazione JSON, regex, hash, base64, slug, conversioni di unita'.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/uptime": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Controlla se una URL risponde: stato HTTP, tempo e dimensione.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/webhook": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Manda una POST a una URL e restituisce la risposta.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/rpc-proxy": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Inoltra una chiamata JSON-RPC a un nodo pubblico (Base, Ethereum, Polygon, Arbitrum).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/conversioni": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Finestra di 30 minuti in cui la sfida 402 resta valida, e quante ne sono state emesse.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/politica-spazio": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "La policy degli spazi web: durata, quota di disco e come si accetta.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/traduzione": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Traduce un testo o una lista di testi in un'altra lingua.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/screenshot": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Renderizza una pagina pubblica con Chromium headless e restituisce il PNG in base64.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/dati": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "CSV in JSON tipizzato, in SQL o in un punteggio KPI pesato.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/csv-json": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "CSV in JSON con i tipi indovinati.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/csv-sql": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "CSV in SQL (Postgres, SQLite, MySQL).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/kpi": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Punteggio KPI pesato sulle colonne.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/spazio": {
   "post": {
    "tags": [
     "a pagamento"
    ],
    "summary": "Crea uno spazio web: dominio sotto mcpgarden.com, un utente limitato a quello spazio e un sito iniziale scritto dall'AI. Tetto di 20 spazi al giorno.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "dominio": {
           "type": "string"
          },
          "utente": {
           "type": "string"
          },
          "password": {
           "type": "string"
          },
          "ip_server": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/.well-known/x402": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Scheda del servizio x402: servizi, prezzi, reti accettate e come si paga (per chi non conosce x402).",
    "responses": {
     "200": {
      "description": "JSON",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/conversioni": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "L'imbuto: quante sfide di pagamento sono state emesse e quante sono diventate un pagamento.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/pagamento": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Pagina del binario carta: crea la sessione Stripe e manda al checkout. E' la CTA della landing.",
    "responses": {
     "200": {
      "description": "Pagina HTML",
      "content": {
       "text/html": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  },
  "/pool": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Pool di inferenza: quota residua e circuit breaker.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "window_id": {
           "type": "integer"
          },
          "window_seconds": {
           "type": "integer"
          },
          "providers": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "model": {
              "type": "string"
             },
             "quota_per_window": {
              "type": "integer"
             },
             "used": {
              "type": "integer"
             },
             "remaining": {
              "type": [
               "integer",
               "null"
              ]
             },
             "quota_dichiarata": {
              "type": "boolean"
             },
             "price_usd_per_call": {
              "type": "number"
             },
             "enabled": {
              "type": "boolean"
             },
             "circuit": {
              "type": "object",
              "properties": {
               "stato": {
                "type": "string",
                "enum": [
                 "closed",
                 "open",
                 "half-open"
                ]
               },
               "fallimenti": {
                "type": "integer"
               },
               "ultimo_errore": {
                "type": [
                 "string",
                 "null"
                ]
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/domini": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Ricerca domini: dice se un nome e' libero e quanto costa. Sola lettura, non compra.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "description": "Nome o parti di nome separate da spazi ('fetch atlas').",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "tlds",
      "in": "query",
      "required": false,
      "description": "TLD da verificare, separati da virgola.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "n",
      "in": "query",
      "required": false,
      "description": "Quanti risultati (max 50).",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "nome": {
           "type": "string"
          },
          "quota_giorniera_residua": {
           "type": "integer"
          },
          "risultati": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "dominio": {
              "type": "string"
             },
             "registrazione_usd": {
              "type": "number"
             },
             "rinnovo_annuo_usd": {
              "type": "number"
             },
             "acquisto": {
              "type": "string"
             }
            }
           }
          }
         },
         "nota": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   }
  },
  "/itaref": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Dataset itaref completo (tassi BCE, cambi, aliquote IVA, partite IVA).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "allOf": [
             {
              "type": "object",
              "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
              "properties": {
               "key": {
                "type": "string"
               },
               "kind": {
                "type": "string"
               },
               "value": {
                "type": "object"
               },
               "source": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "effective_from": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "verified_at": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "updated_at": {
                "type": "number"
               }
              }
             },
             {
              "properties": {
               "value": {
                "type": "object",
                "description": "tassi_bce / cambi: {valore, unita, descrizione, fonte, fonte_istituzione}; aliquote_iva: valore in percentuale; partite_iva: validita' e dati da VIES."
               }
              }
             }
            ]
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/itaref/{key}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Una voce del dataset itaref per chiave.",
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "es. tasso_bce_riferimento, aliquota_iva_ordinaria"
     }
    ],
    "responses": {
     "200": {
      "description": "La voce",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
         "properties": {
          "key": {
           "type": "string"
          },
          "kind": {
           "type": "string"
          },
          "value": {
           "type": "object"
          },
          "source": {
           "type": [
            "string",
            "null"
           ]
          },
          "effective_from": {
           "type": [
            "string",
            "null"
           ]
          },
          "verified_at": {
           "type": [
            "string",
            "null"
           ]
          },
          "updated_at": {
           "type": "number"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Non trovata",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/bandi": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Bandi pubblici italiani strutturati; con q/fonte/n cerca nell'archivio, con live=1&q= interroga l'API TED in tempo reale.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Chiave di ricerca (sottostringa case-insensitive su tutti i campi)"
     },
     {
      "name": "fonte",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Filtro per provenienza (es. TED, Comune di Milano)"
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "Numero massimo di risultati (default 50, max 500)"
     },
     {
      "name": "attivi",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Se '1', solo bandi non scaduti (scadenza nel futuro o non dichiarata)"
     },
     {
      "name": "live",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Se '1', q viene usata come query TED expert (o termine per notice-title) e interroga l'API live; query non valida -> 400"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "allOf": [
             {
              "type": "object",
              "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
              "properties": {
               "key": {
                "type": "string"
               },
               "kind": {
                "type": "string"
               },
               "value": {
                "type": "object"
               },
               "source": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "effective_from": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "verified_at": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "updated_at": {
                "type": "number"
               }
              }
             },
             {
              "properties": {
               "value": {
                "type": "object",
                "properties": {
                 "titolo": {
                  "type": "string"
                 },
                 "ente": {
                  "type": "string"
                 },
                 "luogo": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "importo": {
                  "type": [
                   "number",
                   "null"
                  ],
                  "description": "importo in EUR; null se non dichiarato"
                 },
                 "scadenza": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "riferimento": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "fonte": {
                  "type": "string"
                 },
                 "url": {
                  "type": "string"
                 },
                 "raccolto_il": {
                  "type": "string"
                 },
                 "tipo": {
                  "type": "string"
                 },
                 "modello_usato": {
                  "type": [
                   "string",
                   "null"
                  ]
                 }
                }
               }
              }
             }
            ]
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/bandi/storico": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Storico append-only dei bandi (eventi 'nuovo'/'aggiornato'); /bandi/storico/N o ?n=N limita gli eventi (max 1000), ?q= cerca, ?fonte= filtra.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Chiave di ricerca sul payload/titolo"
     },
     {
      "name": "fonte",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     },
     {
      "name": "da",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Data (YYYY-MM-DD o epoch): solo eventi da quella data in poi; la risposta riporta 'inizio_storico' (da quando partono i dati)"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/comuni": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Elenco dei comuni italiani (codice ISTAT a 5 cifre, provincia, regione, coordinate). Filtri: q, provincia, regione, n (max 500).",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Nome del comune (sottostringa, case-insensitive)"
     },
     {
      "name": "provincia",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "regione",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/comuni/{codice}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Un comune per codice ISTAT a 5 cifre (es. 001295).",
    "parameters": [
     {
      "name": "codice",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "404": {
      "description": "Non trovato",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/ateco": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Codici ATECO 2025 (ISTAT). Filtri: livello (1-6), padre (codice genitore), q (titolo o codice), n (max 500).",
    "parameters": [
     {
      "name": "livello",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "Livello gerarchico della classificazione (1-6)"
     },
     {
      "name": "padre",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Codice del padre, es. 58.1"
     },
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Titolo o codice (sottostringa, case-insensitive)"
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "type": "object"
           }
          },
          "n": {
           "type": "integer"
          },
          "totale": {
           "type": "integer"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/ateco/{codice}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Un codice ATECO 2025 (es. 62.01).",
    "parameters": [
     {
      "name": "codice",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "404": {
      "description": "Non trovato",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/riferimenti": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Elenco delle liste di riferimento italiane. 'con_dati' elenca quelle popolate, 'da_popolare' quelle con fonte ancora da definire.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "type": "object",
            "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
            "properties": {
             "key": {
              "type": "string"
             },
             "kind": {
              "type": "string"
             },
             "value": {
              "type": "object"
             },
             "source": {
              "type": [
               "string",
               "null"
              ]
             },
             "effective_from": {
              "type": [
               "string",
               "null"
              ]
             },
             "verified_at": {
              "type": [
               "string",
               "null"
              ]
             },
             "updated_at": {
              "type": "number"
             }
            }
           }
          },
          "con_dati": {
           "type": "array",
           "items": {
            "type": "string"
           }
          },
          "da_popolare": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/riferimenti/{lista}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Una lista di riferimento (festivita, tassi_moratori, tassi_legali, ateco, inflazione, catastale, tributi, minimi_retributivi, albi).",
    "parameters": [
     {
      "name": "lista",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "La lista",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
         "properties": {
          "key": {
           "type": "string"
          },
          "kind": {
           "type": "string"
          },
          "value": {
           "type": "object"
          },
          "source": {
           "type": [
            "string",
            "null"
           ]
          },
          "effective_from": {
           "type": [
            "string",
            "null"
           ]
          },
          "verified_at": {
           "type": [
            "string",
            "null"
           ]
          },
          "updated_at": {
           "type": "number"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Non trovata",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/fonti": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "DB dei candidati fonte: comuni, universita e programmi UE provati, con esito (ok/scartata), motivo, e prossima data di riprova.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/concorsi": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Concorsi pubblici (selezioni, assunzioni, esami) raccolti dai portali istituzionali; filtri q, attivi, n.",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "attivi",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Se '1', solo concorsi non scaduti"
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/concorsi/storico": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Storico append-only dei concorsi (eventi 'nuovo'/'aggiornato'); ?da= dal giorno, ?n= limite.",
    "parameters": [
     {
      "name": "da",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "n",
      "in": "query",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/salute": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Report della sentinella (ultimo giro).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/giudizio": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Report del giudice (audit dei dataset e dell'API).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/bug": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Problemi segnalati dalla sentinella.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/vendita": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Capacita' vendibile del pool e catalogo di vendita.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/marketing": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Ultimo giro dell'agente marketing: richieste ricevute, percorsi richiesti che non esistono, coerenza fra API e pagina, stato delle iscrizioni ai mercati e modifiche applicate al sito.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/controlli": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Ultimo controllo di coerenza fra cio' che esponde l'API, cio' che espone l'MCP, cio' che promuove la pagina e cio' che dice la skill: elenca i disallineamenti trovati.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/pagamenti": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Referto dei pagamenti: quali servizi sono stati richiesti, quante volte, e da quanti agenti con un wallet. Gli importi e gli indirizzi dei pagatori restano nel canale privato.",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/giornaliera": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Ultimo giornaliero: operazioni delle ultime 24 ore e soldi ricevuti (stesso testo che va sul canale Matrix con l'utente).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/partita-iva/{codice}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Verifica una partita IVA con VIES (API ufficiale della Commissione europea): valida, denominazione, indirizzo, data della verifica e fonte. Gratuita, con tetto di 10 verifiche all'ora per indirizzo.",
    "parameters": [
     {
      "name": "codice",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Partita IVA, con o senza prefisso IT"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/messaggio": {
   "post": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Lascia una domanda a un agente del servizio. Risponde 202 con un id; la risposta si ritira con GET /v1/messaggio/{id}. Gratis, con tetto (3 messaggi all'ora per indirizzo, 20 al giorno).",
    "responses": {
     "202": {
      "description": "Messaggio in coda",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/messaggio/{id}": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "La risposta a un messaggio lasciato con POST /v1/messaggio.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/mercato": {
   "get": {
    "tags": [
     "gratuiti"
    ],
    "summary": "Radar di mercato (giro mensile): domanda misurata dei servizi pagati dagli agenti, classifica per volume e per chiamate, lacune e candidati. Dati: x402-list.com (CC BY 4.0).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/prezzi": {
   "get": {
    "tags": [
     "credito"
    ],
    "summary": "Catalogo: servizi, prezzi e come pagare (gratuito).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/v1/itaref": {
   "get": {
    "tags": [
     "pagati"
    ],
    "summary": "Dataset itaref a pagamento.",
    "security": [
     {
      "bearer": [
       {}
      ]
     }
    ],
    "x-x402": {
     "prezzo_usd": 0.005,
     "reti": [
      {
       "id": "solana",
       "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
       "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
       "payTo": "3zTaVgBqHYmknMjtzkoF8RhSUByZ3VhX6bpz6z7paLLy",
       "facilitator": "https://facilitator.payai.network",
       "ruolo": "incasso (secondaria)"
      },
      {
       "id": "base",
       "network": "eip155:8453",
       "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
       "payTo": "0x5A570D96a1D73C67f6bD4B9eBc19D6c16882d4a4",
       "facilitator": "https://facilitator.radiustech.xyz",
       "ruolo": "incasso (primaria)"
      }
     ],
     "pagamento": "402 con PAYMENT-REQUIRED, oppure Authorization: Bearer <chiave credito>"
    },
    "responses": {
     "200": {
      "description": "OK (dopo pagamento)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "allOf": [
             {
              "type": "object",
              "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
              "properties": {
               "key": {
                "type": "string"
               },
               "kind": {
                "type": "string"
               },
               "value": {
                "type": "object"
               },
               "source": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "effective_from": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "verified_at": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "updated_at": {
                "type": "number"
               }
              }
             },
             {
              "properties": {
               "value": {
                "type": "object",
                "description": "tassi_bce / cambi: {valore, unita, descrizione, fonte, fonte_istituzione}; aliquote_iva: valore in percentuale; partite_iva: validita' e dati da VIES."
               }
              }
             }
            ]
           }
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "Payment Required (x402)",
      "headers": {
       "PAYMENT-REQUIRED": {
        "description": "base64 del PaymentRequired",
        "schema": {
         "type": "string"
        }
       }
      },
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "PaymentRequired (x402 v2): cosa pagare e come, per ogni rete.",
         "properties": {
          "x402Version": {
           "type": "integer"
          },
          "accepts": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "scheme": {
              "type": "string"
             },
             "network": {
              "type": "string"
             },
             "asset": {
              "type": "string"
             },
             "amount": {
              "type": "string",
              "description": "importo in unita' atomiche dell'asset"
             },
             "payTo": {
              "type": "string"
             },
             "maxTimeoutSeconds": {
              "type": "integer"
             },
             "extra": {
              "type": "object"
             }
            }
           }
          },
          "resource": {
           "type": "object"
          },
          "error": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Chiave credito non valida",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "503": {
      "description": "x402 non configurato",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/bandi": {
   "get": {
    "tags": [
     "pagati"
    ],
    "summary": "Bandi a pagamento.",
    "security": [
     {
      "bearer": [
       {}
      ]
     }
    ],
    "x-x402": {
     "prezzo_usd": 0.005,
     "reti": [
      {
       "id": "solana",
       "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
       "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
       "payTo": "3zTaVgBqHYmknMjtzkoF8RhSUByZ3VhX6bpz6z7paLLy",
       "facilitator": "https://facilitator.payai.network",
       "ruolo": "incasso (secondaria)"
      },
      {
       "id": "base",
       "network": "eip155:8453",
       "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
       "payTo": "0x5A570D96a1D73C67f6bD4B9eBc19D6c16882d4a4",
       "facilitator": "https://facilitator.radiustech.xyz",
       "ruolo": "incasso (primaria)"
      }
     ],
     "pagamento": "402 con PAYMENT-REQUIRED, oppure Bearer"
    },
    "responses": {
     "200": {
      "description": "OK (dopo pagamento)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "items": {
           "type": "array",
           "items": {
            "allOf": [
             {
              "type": "object",
              "description": "Riga di dataset: 'value' e' l'oggetto del dato, le altre colonne sono i metadati di audit (fonte, data di vigore, ultima verifica). I campi effective_from, verified_at e source sono NULL quando il tipo di dato non li ha.",
              "properties": {
               "key": {
                "type": "string"
               },
               "kind": {
                "type": "string"
               },
               "value": {
                "type": "object"
               },
               "source": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "effective_from": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "verified_at": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "updated_at": {
                "type": "number"
               }
              }
             },
             {
              "properties": {
               "value": {
                "type": "object",
                "properties": {
                 "titolo": {
                  "type": "string"
                 },
                 "ente": {
                  "type": "string"
                 },
                 "luogo": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "importo": {
                  "type": [
                   "number",
                   "null"
                  ],
                  "description": "importo in EUR; null se non dichiarato"
                 },
                 "scadenza": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "riferimento": {
                  "type": [
                   "string",
                   "null"
                  ]
                 },
                 "fonte": {
                  "type": "string"
                 },
                 "url": {
                  "type": "string"
                 },
                 "raccolto_il": {
                  "type": "string"
                 },
                 "tipo": {
                  "type": "string"
                 },
                 "modello_usato": {
                  "type": [
                   "string",
                   "null"
                  ]
                 }
                }
               }
              }
             }
            ]
           }
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "Payment Required (x402)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "PaymentRequired (x402 v2): cosa pagare e come, per ogni rete.",
         "properties": {
          "x402Version": {
           "type": "integer"
          },
          "accepts": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "scheme": {
              "type": "string"
             },
             "network": {
              "type": "string"
             },
             "asset": {
              "type": "string"
             },
             "amount": {
              "type": "string",
              "description": "importo in unita' atomiche dell'asset"
             },
             "payTo": {
              "type": "string"
             },
             "maxTimeoutSeconds": {
              "type": "integer"
             },
             "extra": {
              "type": "object"
             }
            }
           }
          },
          "resource": {
           "type": "object"
          },
          "error": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Chiave non valida",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/chat": {
   "post": {
    "tags": [
     "pagati"
    ],
    "summary": "Una chiamata di inferenza sul pool di modelli.",
    "security": [
     {
      "bearer": [
       {}
      ]
     }
    ],
    "x-x402": {
     "prezzo_usd": 0.01,
     "reti": [
      {
       "id": "solana",
       "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
       "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
       "payTo": "3zTaVgBqHYmknMjtzkoF8RhSUByZ3VhX6bpz6z7paLLy",
       "facilitator": "https://facilitator.payai.network",
       "ruolo": "incasso (secondaria)"
      },
      {
       "id": "base",
       "network": "eip155:8453",
       "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
       "payTo": "0x5A570D96a1D73C67f6bD4B9eBc19D6c16882d4a4",
       "facilitator": "https://facilitator.radiustech.xyz",
       "ruolo": "incasso (primaria)"
      }
     ],
     "pagamento": "402 con PAYMENT-REQUIRED, oppure Bearer"
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "messages"
        ],
        "properties": {
         "messages": {
          "type": "array",
          "items": {
           "type": "object",
           "required": [
            "role",
            "content"
           ],
           "properties": {
            "role": {
             "type": "string"
            },
            "content": {
             "type": "string"
            }
           }
          }
         },
         "model": {
          "type": [
           "string",
           "null"
          ],
          "description": "modello esplicito (default: scelta dal pool)"
         },
         "max_tokens": {
          "type": "integer",
          "default": 800
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK (dopo pagamento)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "risposta": {
           "type": "string"
          },
          "meta": {
           "type": "object"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Body non valido",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "Payment Required (x402)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "description": "PaymentRequired (x402 v2): cosa pagare e come, per ogni rete.",
         "properties": {
          "x402Version": {
           "type": "integer"
          },
          "accepts": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "scheme": {
              "type": "string"
             },
             "network": {
              "type": "string"
             },
             "asset": {
              "type": "string"
             },
             "amount": {
              "type": "string",
              "description": "importo in unita' atomiche dell'asset"
             },
             "payTo": {
              "type": "string"
             },
             "maxTimeoutSeconds": {
              "type": "integer"
             },
             "extra": {
              "type": "object"
             }
            }
           }
          },
          "resource": {
           "type": "object"
          },
          "error": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "503": {
      "description": "Pool esaurito o x402 non configurato",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/acquisto": {
   "post": {
    "tags": [
     "credito"
    ],
    "summary": "Compra credito prepagato con la carta (Stripe).",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "importo_eur"
        ],
        "properties": {
         "importo_eur": {
          "type": "number",
          "minimum": 5.0,
          "maximum": 500.0
         },
         "email": {
          "type": "string"
         },
         "etichetta": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK: url di checkout e chiave API (mostrata una volta)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "acquisto": {
           "type": "string"
          },
          "url": {
           "type": "string"
          },
          "conto": {
           "type": "string"
          },
          "api_key": {
           "type": "string"
          },
          "importo_eur": {
           "type": "number"
          },
          "come_pagare": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Importo fuori range",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "502": {
      "description": "Stripe non raggiungibile",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "503": {
      "description": "Stripe non configurato",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/acquisto/{id}": {
   "get": {
    "tags": [
     "credito"
    ],
    "summary": "Stato di un acquisto Stripe.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "stato": {
           "type": "string"
          },
          "pagato": {
           "type": "boolean"
          },
          "importo_eur": {
           "type": "number"
          },
          "conto": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/saldo": {
   "get": {
    "tags": [
     "credito"
    ],
    "summary": "Saldo e movimenti del credito prepagato.",
    "security": [
     {
      "bearer": [
       {}
      ]
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "conto": {
           "type": "string"
          },
          "saldo_eur": {
           "type": "number"
          },
          "saldo_usd": {
           "type": "number"
          },
          "movimenti": {
           "type": "array"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Serve Authorization: Bearer",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "errore": {
           "type": "string"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/stripe/webhook": {
   "post": {
    "tags": [
     "credito"
    ],
    "summary": "Webhook Stripe (checkout.session.completed).",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  }
 }
}