{
  "openapi": "3.1.0",
  "info": {
    "title": "Meridian — endpoints exposés",
    "version": "1.0.0",
    "description": "Webhooks entrants des workflows et endpoints d'invocation des agents dont l'exposition API est activée."
  },
  "paths": {
    "/api/agents/agent.chat-clinique/invoke": {
      "post": {
        "operationId": "invoke_agent_chat_clinique",
        "summary": "Copilote clinique urgences",
        "description": "Assistant clinique du dossier patient aux urgences. Répond au médecin de façon concise et sourcée, en déléguant TOUT jugement médicamenteux et TOUT calcul aux outils déterministes de la plateforme.\n",
        "tags": [
          "agents"
        ],
        "security": [
          {
            "headerAuth_agent_chat_clinique": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "inputs": {
                    "type": "object",
                    "properties": {
                      "question": {
                        "type": "string"
                      },
                      "patientId": {
                        "type": "string"
                      },
                      "historique": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "question",
                      "patientId",
                      "historique"
                    ]
                  }
                },
                "required": [
                  "inputs"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sorties de l'agent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "outputs": {
                      "type": "object",
                      "properties": {
                        "answer": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Budget HTTP dépassé — le run continue, réponse à récupérer sur resultUrl.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "runId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "resultUrl": {
                      "type": "string",
                      "description": "GET (même authentification) pour suivre le run puis récupérer les sorties."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Entrées invalides (type ou champ requis)."
          },
          "401": {
            "description": "Authentification refusée."
          },
          "503": {
            "description": "Runner d'agent indisponible (adapter ou clé de provider absents)."
          }
        }
      }
    },
    "/api/agents/agent.chat-clinique/runs/{runId}": {
      "get": {
        "operationId": "agent_result_agent_chat_clinique",
        "summary": "Copilote clinique urgences — résultat",
        "description": "Suivi d'un run démarré par une invocation de cet agent : statut tant qu'il tourne, sorties (ou erreur) une fois terminé.",
        "tags": [
          "agents"
        ],
        "security": [
          {
            "headerAuth_agent_chat_clinique": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "État du run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "runId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "description": "running | completed | failed"
                    },
                    "outputs": {
                      "type": "object",
                      "properties": {
                        "answer": {
                          "type": "string"
                        }
                      }
                    },
                    "content": {
                      "type": "string",
                      "description": "Aplatissement conversationnel des sorties (celui de la surface OpenAI)."
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Authentification refusée."
          },
          "404": {
            "description": "Agent ou run inconnu."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "headerAuth_agent_chat_clinique": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      }
    }
  }
}