{
  "openapi": "3.1.0",
  "info": {
    "title": "Radbit Studios API",
    "description": "API for Radbit Studios services, ontology, and lead capture. Radbit Studios builds websites, enquiry systems, and business workflows for SMEs in Zimbabwe and Southern Africa.",
    "version": "1.0.0",
    "contact": {
      "name": "Radbit Studios",
      "email": "brandontinoz@gmail.com",
      "url": "https://www.radbitstudios.co.zw"
    },
    "x-versioning": "URL path versioning (/api/v1/, /api/v2/). Current version: v1. Deprecation signaled via Sunset and Deprecation headers with 90-day notice.",
    "x-deprecation-policy": "Deprecated endpoints return Deprecation: true and Sunset headers with a date. Agents should migrate before the Sunset date."
  },
  "servers": [
    {
      "url": "https://www.radbitstudios.co.zw",
      "description": "Production (current)"
    },
    {
      "url": "https://www.radbitstudios.co.zw/api/v1",
      "description": "Versioned API (v1)"
    }
  ],
  "paths": {
    "/api/services": {
      "get": {
        "summary": "List all services",
        "description": "Returns the machine-readable service catalog with names, descriptions, outcomes, capabilities, process steps, and FAQs.",
        "responses": {
          "200": {
            "description": "Service catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organization": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "contact": {
                      "type": "object"
                    },
                    "services": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Service"
                      }
                    },
                    "meta": {
                      "type": "object"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "get_services"
      }
    },
    "/api/ontology": {
      "get": {
        "summary": "Knowledge graph (ontology)",
        "description": "Returns a JSON-LD knowledge graph of Radbit's services, problems, projects, and outcomes with relationships.",
        "responses": {
          "200": {
            "description": "Ontology graph",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "@context": {
                      "type": "string"
                    },
                    "@graph": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "meta": {
                      "type": "object"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "get_ontology"
      }
    },
    "/api/enquiries/whatsapp": {
      "post": {
        "summary": "Submit a WhatsApp enquiry (lead capture)",
        "description": "Creates a lead in Firestore and returns a WhatsApp deep link with a pre-filled message.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "fullName"
                ],
                "properties": {
                  "fullName": {
                    "type": "string"
                  },
                  "workEmail": {
                    "type": "string",
                    "format": "email"
                  },
                  "companyName": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Enquiry saved, WhatsApp link returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "leadId": {
                      "type": "string"
                    },
                    "whatsappUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "400": {
            "description": "Invalid enquiry details",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "503": {
            "description": "Could not save enquiry",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_enquiries_whatsapp"
      }
    },
    "/api/auth/refresh-session": {
      "post": {
        "summary": "Refresh session cookie",
        "description": "Verifies a Firebase ID token and sets it as a session cookie. Pass empty idToken to clear the session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idToken": {
                    "type": "string"
                  },
                  "expiresIn": {
                    "type": "integer",
                    "default": 3600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Session refreshed or cleared",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "401": {
            "description": "Invalid or expired token",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "429": {
            "description": "Too many attempts",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "post_auth_refresh_session"
      }
    },
    "/api/leads": {
      "post": {
        "summary": "Submit a lead inquiry",
        "description": "Creates a lead in Firestore with full inquiry details, notifies admins via email and WhatsApp, and creates a project record.",
        "responses": {
          "200": {
            "description": "Lead submitted successfully",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "500": {
            "description": "Failed to submit inquiry",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Maximum requests per window"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Remaining requests in current window"
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp when the window resets"
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit limit"
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit remaining"
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "RFC rate limit reset"
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying"
              }
            }
          }
        },
        "operationId": "post_leads"
      }
    },
    "/api/mcp": {
      "get": {
        "operationId": "getMcpInfo",
        "summary": "MCP server info",
        "description": "Returns MCP server metadata and available tools. Implements Model Context Protocol (Streamable HTTP transport).",
        "responses": {
          "200": {
            "description": "MCP server info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "mcpJsonRpc",
        "summary": "MCP JSON-RPC endpoint",
        "description": "Handles MCP protocol requests (initialize, tools/list, tools/call) via JSON-RPC 2.0 over Streamable HTTP transport.",
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Service": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "intro": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "outcomes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "process": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "faq": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable error code"
          },
          "code": {
            "type": "string",
            "description": "Error code (e.g., NOT_FOUND, RATE_LIMITED)"
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message"
          },
          "hint": {
            "type": "string",
            "description": "Resolution hint for agents"
          },
          "retryAfter": {
            "type": "integer",
            "description": "Seconds to wait before retrying (on 429)"
          }
        },
        "required": [
          "error",
          "message"
        ]
      }
    }
  }
}