{
  "openapi": "3.1.0",
  "info": {
    "title": "Veyra — Commit Mode API",
    "description": "Commit mode for production AI agent actions. Trust discovery, authorization, verification, and settlement. MCP Pack: https://mcp.veyra.to/sse",
    "version": "2.4.1",
    "contact": {
      "name": "Veyra",
      "url": "https://veyra.to"
    }
  },
  "servers": [
    {
      "url": "https://api.veyra.to/v1",
      "description": "Veyra API"
    }
  ],
  "paths": {
    "/capability": {
      "get": {
        "operationId": "getCapability",
        "summary": "Get API capability manifest (free)",
        "responses": {
          "200": {
            "description": "Capability manifest",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "protocol": { "type": "string" },
                    "version": { "type": "string" },
                    "endpoints": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/trust-status/{domain}": {
      "get": {
        "operationId": "checkTrustStatus",
        "summary": "Check trust status of a domain (free)",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "example": "example.com"
          }
        ],
        "responses": {
          "200": {
            "description": "Trust status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domain": { "type": "string" },
                    "production_mode": { "type": "string", "enum": ["trusted", "open"] },
                    "commit_mode": { "type": "boolean" },
                    "commit_mode_provider": { "type": "string" },
                    "verify_endpoint": { "type": "string", "format": "uri" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/authorize-action": {
      "post": {
        "operationId": "authorizeAction",
        "summary": "Authorize a production write action",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id", "action_type", "tool_domain"],
                "properties": {
                  "agent_id": { "type": "string" },
                  "action_type": { "type": "string", "enum": ["create", "update", "delete", "send", "deploy"] },
                  "target": { "type": "string" },
                  "tool_domain": { "type": "string" },
                  "action_class": { "type": "string", "enum": ["A", "B", "C", "D"] },
                  "description": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action authorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": { "type": "string" },
                    "expires_at": { "type": "string", "format": "date-time" },
                    "action_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/verify-token": {
      "post": {
        "operationId": "verifyToken",
        "summary": "Verify a commit token (free)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["token"],
                "properties": {
                  "token": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": { "type": "boolean" },
                    "agent_id": { "type": "string" },
                    "action_type": { "type": "string" },
                    "action_class": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/submit-receipt": {
      "post": {
        "operationId": "submitReceipt",
        "summary": "Submit execution receipt for settlement",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["action_id", "token", "result"],
                "properties": {
                  "action_id": { "type": "string" },
                  "token": { "type": "string" },
                  "result": { "type": "string", "enum": ["success", "failure"] },
                  "metadata": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receipt settled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "receipt_id": { "type": "string" },
                    "settled": { "type": "boolean" },
                    "billed_amount": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/settle-action": {
      "post": {
        "operationId": "settleAction",
        "summary": "Settle an authorized action",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["action_id"],
                "properties": {
                  "action_id": { "type": "string" },
                  "metadata": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action settled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settled": { "type": "boolean" },
                    "billed_amount": { "type": "string" },
                    "settlement_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/public/stats": {
      "get": {
        "operationId": "getPublicStats",
        "summary": "Get public platform statistics (free)",
        "responses": {
          "200": {
            "description": "Public statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_actions_settled": { "type": "integer" },
                    "active_domains": { "type": "integer" },
                    "mcp_tools": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Veyra API key (tr_...)"
      }
    }
  }
}
