{
  "openapi": "3.1.0",
  "info": {
    "title": "Proticom.ai Public API",
    "version": "2.7.0",
    "description": "Public and agent-facing HTTP surfaces for proticom.ai. Prefer MCP for structured agent tools; use these HTTP routes for health, contact intake, and discovery.\n\n**Versioning:** Current endpoints are stable. Breaking changes will be versioned via URL path (e.g., /v2/) or communicated via Sunset/Deprecation headers with at least 6 months notice.\n\n**Rate Limits:** Rate-limited endpoints return RFC RateLimit-* headers and Retry-After on 429 responses.",
    "contact": {
      "name": "Proticom",
      "email": "contact@proticom.com",
      "url": "https://proticom.ai/contact"
    }
  },
  "servers": [
    {
      "url": "https://proticom.ai"
    }
  ],
  "components": {
    "schemas": {
      "ApiError": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Machine-readable error code"
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message"
          },
          "resolution": {
            "type": "string",
            "description": "Suggested resolution steps"
          },
          "details": {
            "type": "object",
            "description": "Additional error context",
            "additionalProperties": true
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": ["status", "service", "version"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["ok"]
          },
          "service": {
            "type": "string",
            "example": "proticom.ai"
          },
          "version": {
            "type": "string",
            "example": "2.7.0"
          }
        }
      },
      "AgentRegisterRequest": {
        "type": "object",
        "required": ["email"],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320
          },
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "purpose": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "AgentRegisterResponse": {
        "type": "object",
        "required": ["success", "registration_completion", "message", "email"],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "registration_completion": {
            "type": "string",
            "enum": ["human_required"]
          },
          "message": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "next": {
            "type": "object",
            "properties": {
              "auth_md": {
                "type": "string"
              },
              "contact": {
                "type": "string"
              },
              "mcp": {
                "type": "string"
              }
            }
          }
        }
      },
      "ContactRequest": {
        "type": "object",
        "required": ["subject", "body", "turnstileToken"],
        "properties": {
          "intent": {
            "type": "string",
            "enum": ["support", "bug", "feature"]
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8000
          },
          "turnstileToken": {
            "type": "string",
            "minLength": 1
          },
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "firstName": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "ContactResponse": {
        "type": "object",
        "required": ["success"],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "confirmationMessage": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded",
        "headers": {
          "RateLimit-Limit": {
            "description": "Request limit per window",
            "schema": {
              "type": "string"
            }
          },
          "RateLimit-Remaining": {
            "description": "Remaining requests in current window",
            "schema": {
              "type": "string"
            }
          },
          "RateLimit-Reset": {
            "description": "Unix timestamp when the window resets",
            "schema": {
              "type": "string"
            }
          },
          "Retry-After": {
            "description": "Seconds until next request allowed",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Health check",
        "description": "Returns service health status and version. Not rate-limited.",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "operationId": "mcpJsonRpc",
        "summary": "MCP Streamable HTTP JSON-RPC endpoint",
        "description": "Model Context Protocol endpoint advertising public discovery tools. Public tools do not require authentication.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "JSON-RPC 2.0 request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "JSON-RPC 2.0 response or error"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/agent/register": {
      "post": {
        "operationId": "agentRegister",
        "summary": "Start verified-email agent registration",
        "description": "Register an agent on behalf of a human. Requires human email confirmation before credential issuance. Rate-limited: 5 requests per minute per IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentRegisterRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registration accepted; human confirmation required",
            "headers": {
              "RateLimit-Limit": {
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentRegisterResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/contact": {
      "post": {
        "operationId": "submitContact",
        "summary": "Human contact / support intake (Turnstile-protected)",
        "description": "Submit a contact request, support ticket, bug report, or feature request. Requires Cloudflare Turnstile token. Rate-limited: 5 requests per minute per IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Contact request accepted",
            "headers": {
              "RateLimit-Limit": {
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  }
}
