{
  "openapi": "3.1.0",
  "info": {
    "title": "Embassia Agentic Web API",
    "description": "Embassia is an agentic data layer for websites. It models a website's underlying capabilities and resources, then lets agents retrieve the right information through those capabilities.",
    "version": "1.1.0",
    "contact": {
      "name": "Embassia",
      "email": "founders@embassia.com",
      "url": "https://embassia.com"
    },
    "license": {
      "name": "Public Access",
      "url": "https://embassia.com"
    }
  },
  "servers": [
    {
      "url": "https://embassia.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/.well-known/embassia.json": {
      "get": {
        "operationId": "getDiscovery",
        "summary": "Discovery Document",
        "description": "Canonical entry point for all machine interfaces. Lists all available APIs, content endpoints, and protocol details.",
        "tags": [
          "Discovery"
        ],
        "responses": {
          "200": {
            "description": "Discovery document with all interface URLs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiscoveryDocument"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/mcp.json": {
      "get": {
        "operationId": "getMCPManifest",
        "summary": "MCP Manifest",
        "description": "Anthropic Model Context Protocol manifest listing available tools and resources for discovery.",
        "tags": [
          "Discovery"
        ],
        "responses": {
          "200": {
            "description": "MCP manifest",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getLlmsTxt",
        "summary": "llms.txt Agent Discovery Guide",
        "description": "Plaintext discovery document for AI agents, following the llms.txt convention.",
        "tags": [
          "Discovery"
        ],
        "responses": {
          "200": {
            "description": "llms.txt content",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/llms-full.txt": {
      "get": {
        "operationId": "getLlmsFullTxt",
        "summary": "Full Site Content (plaintext)",
        "description": "Complete site content as plaintext, optimized for AI context windows.",
        "tags": [
          "Content"
        ],
        "responses": {
          "200": {
            "description": "Full site content",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent": {
      "post": {
        "operationId": "queryOnSiteAgent",
        "summary": "Live On-Site Agent Query",
        "description": "Submit a natural language query via JSON body to retrieve matching structured data.",
        "tags": [
          "Search"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "query"
                ],
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "The question or topic you want to retrieve data for."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent resolution result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request"
          }
        }
      },
      "get": {
        "operationId": "queryOnSiteAgentGet",
        "summary": "Live On-Site Agent Query (GET fallback)",
        "description": "Submit a natural language query via URL parameter to retrieve matching structured data.",
        "tags": [
          "Search"
        ],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The natural language query to submit. If omitted, an onboarding/discovery message is returned."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful query execution or agent onboarding message",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AgentResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "usage": {
                          "type": "object"
                        },
                        "discovery": {
                          "type": "object"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Malformed request"
          }
        }
      }
    },
    "/api/v1/agent/q/{question}": {
      "get": {
        "operationId": "queryOnSiteAgentPath",
        "summary": "Live On-Site Agent Query (path-based)",
        "description": "Submit a natural language question via URL path (no query string needed). The question must be URL-encoded in the path segment. Delegates to the same retrieval pipeline as GET /api/v1/agent?query=... and returns the identical JSON schema. Maximum 500 characters after decoding.",
        "tags": [
          "Search"
        ],
        "parameters": [
          {
            "name": "question",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 500
            },
            "description": "URL-encoded natural language question. Example: What%20does%20Embassia%20do%3F"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent resolution result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request — missing question, too long (>500 chars), invalid encoding, or control characters"
          }
        }
      }
    },
    "/api/v1/capabilities/index.json": {
      "get": {
        "summary": "Get Capability Registry",
        "description": "Retrieve the canonical registry of active read capabilities supported by this site.",
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "executeMcpRequest",
        "summary": "MCP JSON-RPC Endpoint",
        "description": "Executes MCP requests via JSON-RPC 2.0 using the modern Streamable HTTP protocol (2026-07-28). The client must first execute a server/discover call to negotiate versions, and subsequently attach metadata to every request.",
        "parameters": [
          {
            "name": "Mcp-Protocol-Version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The MCP protocol version requested by the client. Must be 2026-07-28 for modern."
          },
          {
            "name": "Mcp-Method",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Must match the method field inside the JSON-RPC request."
          },
          {
            "name": "Mcp-Name",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required for tools/call and resources/read. Must match the name of the tool or resource being invoked."
          },
          {
            "name": "Accept",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Must include application/json and text/event-stream."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {
                    "type": [
                      "string",
                      "number",
                      "null"
                    ]
                  },
                  "method": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object",
                    "properties": {
                      "_meta": {
                        "type": "object",
                        "properties": {
                          "io.modelcontextprotocol/protocolVersion": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful JSON-RPC response, possibly containing JSON-RPC errors (like ToolNotFound).",
            "headers": {
              "Content-Type": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "application/json; charset=utf-8"
                  ]
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "jsonrpc"
                  ],
                  "properties": {
                    "jsonrpc": {
                      "type": "string",
                      "enum": [
                        "2.0"
                      ]
                    },
                    "id": {
                      "type": [
                        "string",
                        "number",
                        "null"
                      ]
                    },
                    "result": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        },
                        "data": {
                          "type": "object"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. Thrown for UnsupportedProtocolVersion or HeaderMismatch."
          },
          "403": {
            "description": "Forbidden. Invalid Origin."
          },
          "404": {
            "description": "Not Found. Unknown JSON-RPC method."
          },
          "405": {
            "description": "Method Not Allowed. Must use POST."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DiscoveryDocument": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "api_version": {
            "type": "string"
          },
          "interfaces": {
            "type": "object"
          },
          "content": {
            "type": "object"
          },
          "protocols": {
            "type": "object"
          },
          "access": {
            "type": "object"
          }
        }
      },
      "ContentIndex": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "total_documents": {
            "type": "integer"
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContentIndexEntry"
            }
          }
        }
      },
      "ContentIndexEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "content_type": {
            "type": "string",
            "enum": [
              "page",
              "faq",
              "feature",
              "product"
            ]
          },
          "canonical_url": {
            "type": "string",
            "format": "uri"
          },
          "api_url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ContentDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "canonical_url": {
            "type": "string",
            "format": "uri"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "content": {
            "type": "object"
          },
          "metadata": {
            "type": "object"
          }
        }
      },
      "FAQEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "question": {
            "type": "string"
          },
          "answer": {
            "type": "string"
          }
        }
      },
      "SearchIndex": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "api_url": {
                  "type": "string",
                  "format": "uri"
                },
                "keywords": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "AgentResponse": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "resolved": {
            "type": "boolean"
          },
          "gap": {
            "type": "boolean"
          },
          "intent": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              }
            }
          },
          "capability": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              }
            }
          },
          "arguments": {
            "type": "object"
          },
          "data": {
            "type": "object"
          },
          "execution_status": {
            "type": "string"
          },
          "provenance": {
            "type": "object"
          },
          "freshness": {
            "type": "object"
          },
          "match_score": {
            "type": "number"
          },
          "query_logged": {
            "type": "boolean"
          },
          "meta": {
            "type": "object"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Discovery",
      "description": "Entry points and discovery documents for AI agents"
    },
    {
      "name": "Content",
      "description": "Structured content documents"
    },
    {
      "name": "Search",
      "description": "Content search capabilities"
    },
    {
      "name": "FAQ",
      "description": "Frequently asked questions"
    },
    {
      "name": "Infrastructure",
      "description": "Architecture and infrastructure endpoints"
    }
  ]
}