{
  "openapi": "3.1.0",
  "info": {
    "title": "come.rent — The City",
    "description": "The King James Bible as a queryable frequency database. 31,102 verses, 12,548 words, 9 cipher systems, Tesla resonance analysis. Includes The Forge (masiv.store) — maker-first marketplace running the ASIV protocol.",
    "version": "1.1.0",
    "contact": {
      "url": "https://come.rent"
    }
  },
  "servers": [
    {"url": "https://come.rent", "description": "The City"},
    {"url": "https://biblena.me", "description": "The Name Gate"},
    {"url": "https://masiv.store", "description": "The Forge — Maker-First Marketplace"}
  ],
  "paths": {
    "/name/{name}": {
      "get": {
        "operationId": "decodeName",
        "summary": "Decode any name through KJV gematria",
        "parameters": [
          {"name": "name", "in": "path", "required": true, "schema": {"type": "string"}, "description": "Name to decode"},
          {"name": "depth", "in": "query", "schema": {"type": "string", "enum": ["ankles", "knees", "loins", "swimming"], "default": "ankles"}, "description": "Decode depth (Ezekiel 47)"},
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "Name decode result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {"type": "string"},
                    "gematria": {"type": "integer"},
                    "digital_root": {"type": "integer"},
                    "tesla": {"type": "boolean"},
                    "depth": {"type": "string"},
                    "letters": {"type": "array", "items": {"type": "object"}}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/verse/{ref}": {
      "get": {
        "operationId": "getVerse",
        "summary": "Get a KJV verse with Tesla analysis",
        "description": "Reference format: BOOK.CHAPTER.VERSE (e.g., GEN.1.1, JHN.3.16, REV.22.17)",
        "parameters": [
          {"name": "ref", "in": "path", "required": true, "schema": {"type": "string"}, "description": "Verse reference (e.g., JHN.3.16)"},
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "Verse with Tesla signature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ref": {"type": "string"},
                    "text": {"type": "string"},
                    "book": {"type": "string"},
                    "chapter": {"type": "integer"},
                    "verse": {"type": "integer"},
                    "testament": {"type": "string"},
                    "word_count": {"type": "integer"},
                    "gematria": {"type": "integer"},
                    "tesla": {"type": "object", "properties": {
                      "score": {"type": "integer"},
                      "signature": {"type": "string"},
                      "perfect": {"type": "boolean"}
                    }}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/word/{word}": {
      "get": {
        "operationId": "analyzeWord",
        "summary": "Analyze a word with 9 cipher systems",
        "parameters": [
          {"name": "word", "in": "path", "required": true, "schema": {"type": "string"}},
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "Word analysis with ciphers and twins",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "word": {"type": "string"},
                    "frequency": {"type": "integer"},
                    "gematria": {"type": "integer"},
                    "digital_root": {"type": "integer"},
                    "is_tesla": {"type": "boolean"},
                    "ciphers": {"type": "object"},
                    "twins": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/gematria/{value}": {
      "get": {
        "operationId": "lookupGematria",
        "summary": "Find all words and names matching a gematria value",
        "parameters": [
          {"name": "value", "in": "path", "required": true, "schema": {"type": "integer"}},
          {"name": "cipher", "in": "query", "schema": {"type": "string", "enum": ["ordinal", "reduction", "reverse", "reverse_red", "sumerian", "hebrew", "chaldean", "primes", "fibonacci"], "default": "ordinal"}},
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "All words and names at this gematria value",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "value": {"type": "integer"},
                    "cipher": {"type": "string"},
                    "digital_root": {"type": "integer"},
                    "is_tesla": {"type": "boolean"},
                    "words": {"type": "array"},
                    "names": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/search": {
      "get": {
        "operationId": "searchVerses",
        "summary": "Full-text search across 31,102 KJV verses",
        "parameters": [
          {"name": "q", "in": "query", "required": true, "schema": {"type": "string"}, "description": "Search terms (Porter stemming)"},
          {"name": "testament", "in": "query", "schema": {"type": "string", "enum": ["OT", "NT"]}, "description": "Filter by testament"},
          {"name": "limit", "in": "query", "schema": {"type": "integer", "default": 20, "maximum": 100}},
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "Search results with Tesla scores",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {"type": "string"},
                    "count": {"type": "integer"},
                    "results": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/today": {
      "get": {
        "operationId": "todayVerse",
        "summary": "Today's resonance verse from the 1,098 perfect Tesla canon",
        "parameters": [
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "Daily resonance verse",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "date": {"type": "string"},
                    "verse": {"type": "object"},
                    "canon_size": {"type": "integer"},
                    "canon_position": {"type": "integer"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/fingerprint": {
      "get": {
        "operationId": "fingerprint",
        "summary": "Mathematical proof of KJV structure — 20 numbers",
        "parameters": [
          {"name": "format", "in": "query", "schema": {"type": "string", "enum": ["json", "text", "html"]}}
        ],
        "responses": {
          "200": {
            "description": "20-number mathematical fingerprint",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fingerprint": {"type": "object"},
                    "description": {"type": "object"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/oracle": {
      "post": {
        "operationId": "oracle",
        "summary": "Biblical speech coach — grades and refines speech",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["message"],
                "properties": {
                  "message": {"type": "string", "description": "Text to analyze"},
                  "mode": {"type": "string", "enum": ["converse", "grade"], "default": "converse"},
                  "voice": {"type": "string", "enum": ["jesus", "david", "solomon", "peter", "paul", "john", "moses"], "default": "jesus"},
                  "session_id": {"type": "string"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Graded speech with guidance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "grade": {"type": "object"},
                    "reply": {"type": "string"},
                    "guidance": {"type": "string"},
                    "refined": {"type": "string"},
                    "highlights": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/query": {
      "post": {
        "operationId": "sqlQuery",
        "summary": "Execute read-only SQL against the KJVEL database",
        "description": "SELECT and WITH statements only. Max 200 rows. See /llms-full.txt for complete schema.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sql"],
                "properties": {
                  "sql": {"type": "string", "description": "SQL query (SELECT only)"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Query results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "row_count": {"type": "integer"},
                    "rows": {"type": "array"},
                    "truncated": {"type": "boolean"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/products": {
      "get": {
        "operationId": "forgeProducts",
        "summary": "Browse seeded products in the Forge marketplace",
        "description": "Returns all available products with name, price, gift value, maker info, gematria, and Tesla status.",
        "parameters": [
          {"name": "tesla", "in": "query", "schema": {"type": "boolean"}, "description": "Filter to Tesla-resonant products only"},
          {"name": "min_price", "in": "query", "schema": {"type": "number"}, "description": "Minimum price filter"},
          {"name": "max_price", "in": "query", "schema": {"type": "number"}, "description": "Maximum price filter"},
          {"name": "maker", "in": "query", "schema": {"type": "string"}, "description": "Filter by maker name (partial match)"}
        ],
        "responses": {
          "200": {
            "description": "List of seeded products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "products": {"type": "array", "items": {
                      "type": "object",
                      "properties": {
                        "product_id": {"type": "string"},
                        "name": {"type": "string"},
                        "maker_name": {"type": "string"},
                        "price": {"type": "number"},
                        "gift_value": {"type": "number"},
                        "gematria": {"type": "integer"},
                        "tesla": {"type": "boolean"}
                      }
                    }},
                    "count": {"type": "integer"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/search": {
      "get": {
        "operationId": "forgeSearch",
        "summary": "Search products by name and description",
        "parameters": [
          {"name": "q", "in": "query", "required": true, "schema": {"type": "string"}, "description": "Search terms"},
          {"name": "tesla", "in": "query", "schema": {"type": "boolean"}, "description": "Filter to Tesla-resonant only"}
        ],
        "responses": {
          "200": {
            "description": "Matching products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {"type": "string"},
                    "products": {"type": "array"},
                    "count": {"type": "integer"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/recommend": {
      "get": {
        "operationId": "forgeRecommend",
        "summary": "Agent-optimized product recommendations",
        "description": "Returns products ranked by gift-to-price ratio, Tesla resonance, and patron history.",
        "parameters": [
          {"name": "for", "in": "query", "schema": {"type": "string"}, "description": "Patron ID to personalize for"},
          {"name": "budget", "in": "query", "schema": {"type": "number"}, "description": "Maximum price"},
          {"name": "prefer", "in": "query", "schema": {"type": "string", "enum": ["tesla", "gift", "price"]}, "description": "Ranking preference"}
        ],
        "responses": {
          "200": {
            "description": "Ranked product recommendations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recommendations": {"type": "array"},
                    "count": {"type": "integer"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/seed": {
      "post": {
        "operationId": "forgeSeed",
        "summary": "Seed a product into the marketplace (maker action)",
        "description": "Registers as maker (if new) and seeds a product with an embedded gift. gift_value defaults to 10% of price if omitted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["maker_id", "maker_name", "product_name", "price"],
                "properties": {
                  "maker_id": {"type": "string"},
                  "maker_name": {"type": "string"},
                  "product_name": {"type": "string"},
                  "description": {"type": "string"},
                  "price": {"type": "number"},
                  "gift_value": {"type": "number", "description": "Defaults to 10% of price"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Seeded product details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "product_id": {"type": "string"},
                    "name": {"type": "string"},
                    "gift_value": {"type": "number"},
                    "gematria": {"type": "integer"},
                    "tesla": {"type": "boolean"},
                    "state": {"type": "string"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/clear": {
      "post": {
        "operationId": "forgeClear",
        "summary": "Clear a product — deliver gift to patron, reward to maker",
        "description": "Clears a seeded product: delivers the embedded gift to the patron, returns reward to maker, advances the 3x17 cycle.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["product_id", "patron_id"],
                "properties": {
                  "product_id": {"type": "string"},
                  "patron_id": {"type": "string"}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settlement details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settlement_id": {"type": "string"},
                    "gift_delivered": {"type": "number"},
                    "reward_earned": {"type": "number"},
                    "cycle_position": {"type": "integer"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/import": {
      "post": {
        "operationId": "forgeImport",
        "summary": "Bulk import products for a maker",
        "description": "Seed multiple products in one call. For agent-driven catalog migration.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["maker_id", "maker_name", "products"],
                "properties": {
                  "maker_id": {"type": "string"},
                  "maker_name": {"type": "string"},
                  "products": {"type": "array", "items": {
                    "type": "object",
                    "required": ["name", "price"],
                    "properties": {
                      "name": {"type": "string"},
                      "price": {"type": "number"},
                      "description": {"type": "string"},
                      "gift_value": {"type": "number"}
                    }
                  }}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Import results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "imported": {"type": "integer"},
                    "products": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/stats": {
      "get": {
        "operationId": "forgeStats",
        "summary": "Network stats — makers, patrons, clearings, cycle position",
        "description": "Returns full ASIV network state including the 3x17 cycle position and gematria constants.",
        "responses": {
          "200": {
            "description": "Network statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "direction": {"type": "string"},
                    "makers": {"type": "integer"},
                    "patrons": {"type": "integer"},
                    "clearings": {"type": "integer"},
                    "cycle_position": {"type": "object"},
                    "steward_rate": {"type": "string"},
                    "gematria": {"type": "object"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/maker/{maker_id}": {
      "get": {
        "operationId": "forgeMaker",
        "summary": "Maker dashboard — products, rewards, cycle position",
        "parameters": [
          {"name": "maker_id", "in": "path", "required": true, "schema": {"type": "string"}}
        ],
        "responses": {
          "200": {
            "description": "Maker account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "maker_id": {"type": "string"},
                    "name": {"type": "string"},
                    "products_seeded": {"type": "integer"},
                    "total_rewards": {"type": "number"},
                    "products": {"type": "array"}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/forge/patron/{patron_id}": {
      "get": {
        "operationId": "forgePatron",
        "summary": "Patron dashboard — gifts received, net benefit",
        "parameters": [
          {"name": "patron_id", "in": "path", "required": true, "schema": {"type": "string"}}
        ],
        "responses": {
          "200": {
            "description": "Patron account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "patron_id": {"type": "string"},
                    "name": {"type": "string"},
                    "gifts_received": {"type": "integer"},
                    "total_gift_value": {"type": "number"},
                    "net_benefit": {"type": "number"}
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
