{"openapi": "3.1.0", "info": {"title": "Patent-Anything API — Deterministic Public IP Intelligence & Claim-Element Pre-Screening Engine", "version": "1.0.0", "summary": "Deterministic patent claim tree parsing, All-Elements Rule FTO matrix, USPTO/EPO/WIPO statutory expiry & maintenance-fee calculator, lawful design-around spec compiler, 45-class Nice trademark conflict radar, and patent family white-space analyzer.", "description": "Patent-Anything is a deterministic public patent and trademark intelligence and claim-element pre-screening software tool. It is not a law firm and does not provide legal advice, legal representation, or a formal FTO legal opinion. Zero client data resale commitment: submitted claim texts, product specs, and brand drafts are never sold or used to train third-party models. Fixed non-contingent prepaid credit packs via Creem.io ($29 / $99 / $299) and zero charge ($0) on empty or invalid HTTP 422 inputs.", "contact": {"name": "Patent-Anything Operations", "email": "patent-ops@fastmesh.dev", "url": "https://patent.fastmesh.dev"}}, "servers": [{"url": "https://patent.fastmesh.dev", "description": "Production HTTPS Gateway"}, {"url": "http://127.0.0.1:9010", "description": "Local Upstream Engine"}], "tags": [{"name": "Health", "description": "Service liveness and supported domain telemetry"}, {"name": "Analysis", "description": "Polymorphic IP pre-screening across 5 core modes plus combined full_ip_prescan and concurrent batch scanning"}, {"name": "Billing", "description": "Creem.io prepaid credit pack catalog, tenant balances, and HMAC-SHA256 webhook settlement"}, {"name": "MCP", "description": "Remote JSON-RPC 2.0 Model Context Protocol endpoint"}], "paths": {"/health": {"get": {"tags": ["Health"], "operationId": "getHealth", "summary": "Service health check and supported domain inventory", "responses": {"200": {"description": "Engine healthy and ready", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HealthResponse"}}}}}}}, "/v1/domains": {"get": {"tags": ["Analysis"], "operationId": "listDomains", "summary": "List all 5 supported IP intelligence modes and 45 Nice classification summaries", "responses": {"200": {"description": "Supported domains, modes, and Nice classes", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/DomainsResponse"}}}}}}}, "/v1/analyze": {"post": {"tags": ["Analysis"], "operationId": "analyzeIp", "summary": "Run deterministic IP pre-screen for any of the 5 modes or full_ip_prescan", "description": "Dispatches mode in {fto_claim_matrix, public_domain_expiry, design_around, trademark_nice, patent_family_gaps, full_ip_prescan}. Supports cross-tenant 7d-30d ArchiveCache metering via tenant_id or X-Tenant-Id header. Rejects invalid patent numbers, empty claims, or missing brand inputs at HTTP 422 with billed_micros=0. Also aliased at POST /api/analyze.", "parameters": [{"name": "X-Tenant-Id", "in": "header", "required": false, "description": "Optional tenant identifier fallback if omitted from the JSON request body.", "schema": {"type": "string"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AnalyzeRequest"}}}}, "responses": {"200": {"description": "Deterministic IP pre-screen report with SHA-256 evidence digest", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AnalyzeResponse"}}}}, "422": {"description": "Unbilled validation rejection (invalid patent number, empty claim, or missing required input; billed_micros=0)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UnbilledErrorResponse"}}}}}}}, "/api/analyze": {"post": {"tags": ["Analysis"], "operationId": "analyzeIpAlias", "summary": "Alias for POST /v1/analyze", "parameters": [{"name": "X-Tenant-Id", "in": "header", "required": false, "schema": {"type": "string"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AnalyzeRequest"}}}}, "responses": {"200": {"description": "Deterministic IP pre-screen report", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AnalyzeResponse"}}}}, "422": {"description": "Unbilled validation rejection (billed_micros=0)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UnbilledErrorResponse"}}}}}}}, "/v1/batch-analyze": {"post": {"tags": ["Analysis"], "operationId": "batchAnalyzeIp", "summary": "Concurrent batch IP pre-screen across multiple items with hard budget lock", "description": "Evaluates a list of IP pre-screen items concurrently under an ApprovalBudgetGuard cap (max_budget_usd / max_cost_micros), isolating invalid 422 items at $0 billed without blocking valid results.", "parameters": [{"name": "X-Tenant-Id", "in": "header", "required": false, "schema": {"type": "string"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/BatchAnalyzeRequest"}}}}, "responses": {"200": {"description": "Batch summary and per-item pre-screen reports", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/BatchAnalyzeResponse"}}}}, "422": {"description": "Empty or malformed batch payload (billed_micros=0)", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UnbilledErrorResponse"}}}}}}}, "/v1/billing/skus": {"get": {"tags": ["Billing"], "operationId": "listBillingSkus", "summary": "List Creem.io fixed-fee non-contingent prepaid credit packs ($29 / $99 / $299)", "responses": {"200": {"description": "Creem SKU catalog", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/BillingSkusResponse"}}}}}}}, "/v1/billing/balance": {"get": {"tags": ["Billing"], "operationId": "getBillingBalance", "summary": "Query current SQLite WAL prepaid credit balance for a tenant", "parameters": [{"name": "tenant_id", "in": "query", "required": false, "description": "Tenant ID or email (automatically redacted to SHA-256 12-hex prefix).", "schema": {"type": "string"}}, {"name": "X-Tenant-Id", "in": "header", "required": false, "schema": {"type": "string"}}], "responses": {"200": {"description": "Tenant balance and lifetime credit counters", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/BillingBalanceResponse"}}}}}}}, "/webhooks/creem": {"post": {"tags": ["Billing"], "operationId": "processCreemWebhook", "summary": "Verify Creem.io HMAC-SHA256 webhook and idempotently credit tenant ledger", "parameters": [{"name": "creem-signature", "in": "header", "required": true, "description": "HMAC-SHA256 hex digest of raw request body signed with CREEM_WEBHOOK_SECRET.", "schema": {"type": "string"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": true}}}}, "responses": {"200": {"description": "Webhook verified and idempotently recorded", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreemWebhookReceipt"}}}}, "401": {"description": "Invalid or missing creem-signature", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UnbilledErrorResponse"}}}}}}}, "/mcp": {"post": {"tags": ["MCP"], "operationId": "handleMcpJsonRpc", "summary": "Streamable HTTP JSON-RPC 2.0 MCP server endpoint (initialize, tools/list, tools/call)", "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/McpJsonRpcRequest"}}}}, "responses": {"200": {"description": "JSON-RPC 2.0 response payload", "content": {"application/json": {"schema": {"type": "object", "additionalProperties": true}}}}}}}}, "components": {"schemas": {"AnalysisMode": {"type": "string", "enum": ["fto_claim_matrix", "public_domain_expiry", "design_around", "trademark_nice", "patent_family_gaps", "full_ip_prescan"]}, "HealthResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "status": {"type": "string", "example": "ok"}, "service": {"type": "string", "example": "patent-anything"}, "domains": {"type": "array", "items": {"type": "string"}}, "compliance_notice": {"type": "string"}}}, "DomainsResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "domains": {"type": "array", "items": {"type": "object", "additionalProperties": true}}, "nice_classes": {"type": "object", "additionalProperties": true}, "compliance_notice": {"type": "string"}}}, "AnalyzeRequest": {"type": "object", "required": ["mode"], "properties": {"mode": {"$ref": "#/components/schemas/AnalysisMode"}, "claims_text": {"type": "string", "description": "Patent claim text (required for fto_claim_matrix and design_around; alias claim_text also accepted)."}, "claim_text": {"type": "string", "description": "Alias for claims_text."}, "product_spec": {"type": ["string", "object"], "description": "Product description or structured feature specification."}, "patent_number": {"type": "string", "description": "Patent publication or grant number (e.g., US10456789B2)."}, "filing_date": {"type": "string", "description": "Effective filing date (YYYY-MM-DD) for public_domain_expiry."}, "priority_date": {"type": "string", "description": "Optional priority date (YYYY-MM-DD)."}, "grant_date": {"type": "string", "description": "Optional grant/issue date (YYYY-MM-DD)."}, "patent_type": {"type": "string", "enum": ["utility", "design"], "default": "utility"}, "pta_days": {"type": "integer", "default": 0}, "pte_days": {"type": "integer", "default": 0}, "terminal_disclaimer_expiry": {"type": "string"}, "terminal_disclaimer_parent": {"type": "object", "additionalProperties": true}, "maintenance_fees_paid": {"type": ["array", "object"]}, "as_of_date": {"type": "string"}, "proposed_mark": {"type": "string", "description": "Brand wordmark for trademark_nice (alias brand_name also accepted)."}, "proposed_classes": {"type": "array", "items": {"type": "integer", "minimum": 1, "maximum": 45}, "description": "Nice classes 1-45 (alias nice_classes also accepted)."}, "brand_name": {"type": "string", "description": "Alias for proposed_mark."}, "nice_classes": {"type": "array", "items": {"type": "integer", "minimum": 1, "maximum": 45}}, "existing_marks": {"type": "array", "items": {"type": "object", "additionalProperties": true}}, "family_members": {"type": "array", "items": {"type": "object", "additionalProperties": true}}, "target_markets": {"type": "array", "items": {"type": "string"}}, "tenant_id": {"type": "string"}, "no_cache": {"type": "boolean", "default": false}}}, "AnalyzeResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "status_code": {"type": "integer"}, "mode": {"$ref": "#/components/schemas/AnalysisMode"}, "compliance_notice": {"type": "string"}, "sha256_proof": {"type": "string"}, "billed_micros": {"type": "integer"}, "cache_meta": {"type": "object", "additionalProperties": true}, "result": {"type": "object", "additionalProperties": true}}, "additionalProperties": true}, "BatchAnalyzeRequest": {"type": "object", "required": ["items"], "properties": {"items": {"type": "array", "minItems": 1, "items": {"$ref": "#/components/schemas/AnalyzeRequest"}}, "max_budget_usd": {"type": "number"}, "max_cost_micros": {"type": "integer"}, "tenant_id": {"type": "string"}, "no_cache": {"type": "boolean", "default": false}}}, "BatchAnalyzeResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "status_code": {"type": "integer"}, "total_items": {"type": "integer"}, "succeeded_count": {"type": "integer"}, "rejected_422_count": {"type": "integer"}, "budget_stopped_count": {"type": "integer"}, "total_billed_micros": {"type": "integer"}, "remaining_batch_budget_micros": {"type": "integer"}, "results": {"type": "array", "items": {"type": "object", "additionalProperties": true}}, "compliance_notice": {"type": "string"}}}, "BillingBalanceResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "tenant_id": {"type": "string"}, "payer_sha256_12": {"type": "string"}, "credits_balance": {"type": "integer"}, "total_credits_granted": {"type": "integer"}, "total_credits_consumed": {"type": "integer"}, "total_paid_cents": {"type": "integer"}, "updated_at_utc": {"type": ["string", "null"]}, "tool_disclaimer": {"type": "string"}}}, "BillingSkusResponse": {"type": "object", "properties": {"ok": {"type": "boolean"}, "packs": {"type": "array", "items": {"type": "object", "additionalProperties": true}}, "tool_disclaimer": {"type": "string"}}}, "CreemWebhookReceipt": {"type": "object", "properties": {"ok": {"type": "boolean"}, "status_code": {"type": "integer"}, "event_id": {"type": "string"}, "event_type": {"type": "string"}, "idempotent_duplicate": {"type": "boolean"}, "tenant_id": {"type": "string"}, "payer_sha256_12": {"type": "string"}, "sku_id": {"type": "string"}, "amount_cents": {"type": "integer"}, "currency": {"type": "string"}, "credits_added": {"type": "integer"}, "credits_balance": {"type": "integer"}, "receipt_sha256": {"type": "string"}, "recorded_at_utc": {"type": "string", "format": "date-time"}, "tool_disclaimer": {"type": "string"}}}, "McpJsonRpcRequest": {"type": "object", "required": ["jsonrpc", "method"], "properties": {"jsonrpc": {"type": "string", "const": "2.0"}, "id": {"type": ["string", "integer", "null"]}, "method": {"type": "string", "enum": ["initialize", "tools/list", "tools/call"]}, "params": {"type": "object", "additionalProperties": true}}}, "UnbilledErrorResponse": {"type": "object", "required": ["ok", "status_code", "billed_micros"], "properties": {"ok": {"type": "boolean", "const": false}, "status_code": {"type": "integer", "example": 422}, "billed_micros": {"type": "integer", "const": 0}, "credits_charged": {"type": "integer", "const": 0}, "error": {"type": "string"}, "error_detail": {"type": "string"}, "compliance_notice": {"type": "string"}}}}}}