{
  "openapi": "3.1.0",
  "info": {
    "title": "KOVEL Registry API",
    "version": "1.0",
    "description": "Verify AI agent authority against signed KOVEL mandates and service agreements."
  },
  "servers": [
    {
      "url": "https://kovelapp.fun"
    }
  ],
  "paths": {
    "/api/verify": {
      "get": {
        "operationId": "verifyAuthorization",
        "summary": "Check whether an agent is authorized to perform an action",
        "parameters": [
          {
            "name": "agent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "counterparty",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pact",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Agent pacts and, when an action is given, an authorization decision"
          }
        }
      }
    },
    "/api/pacts/{id}": {
      "get": {
        "operationId": "getPact",
        "summary": "Get a pact record",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "KVL-7KQ2M-X94RD"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pact record"
          }
        }
      }
    },
    "/api/pacts/{id}/spec.json": {
      "get": {
        "operationId": "getPactSpec",
        "summary": "Get the signed machine-readable spec",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "KVL-7KQ2M-X94RD"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Spec"
          }
        }
      }
    },
    "/api/events": {
      "get": {
        "operationId": "listEvents",
        "summary": "Recent registry events",
        "parameters": [
          {
            "name": "agent",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events"
          }
        }
      }
    },
    "/api/clauses": {
      "get": {
        "operationId": "getClauses",
        "summary": "Clause Library",
        "responses": {
          "200": {
            "description": "Clauses"
          }
        }
      }
    },
    "/api/webhooks": {
      "post": {
        "operationId": "createWebhook",
        "summary": "Subscribe a URL to registry events",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "agent_id": {
                    "type": "string"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "pact.registered",
                        "pact.signed",
                        "pact.activated",
                        "pact.revoked",
                        "authorization.checked"
                      ]
                    }
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook id and signing secret"
          }
        }
      }
    }
  }
}