{"openapi":"3.1.0","info":{"title":"SDeeka Legal Search & Pleading API","version":"2.0.0","description":"API for Thai Supreme Court Deka search, Administrative Court search, OCS statute Law Search V2, and locked Thai pleading/petition tools. Manage API keys via Google or verified Email Magic Link at https://sdeeka.com/account/api-keys."},"servers":[{"url":"https://api.sdeeka.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer"},"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key"}},"schemas":{"Error":{"type":"object","properties":{"ok":{"type":"boolean","example":false},"error":{"type":"string"},"details":{"type":"object"}}},"CaseSummary":{"type":"object","properties":{"case_id":{"type":"integer"},"deka_no":{"type":"string","example":"2289/2568"},"title":{"type":"string"},"document_type":{"type":"string"},"year_be":{"type":"integer"},"short_text":{"type":"string"},"rank_score":{"type":"number"},"matched_terms":{"type":"array","items":{"type":"string"}},"ranking_explain":{"type":"array","items":{"type":"string"}}}},"ApiResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"tool":{"type":"string"},"data":{"type":"object"}}},"TextSearchRequest":{"type":"object","required":["query"],"properties":{"query":{"type":"string","maxLength":1024},"top_k":{"type":"integer","minimum":1,"maximum":30,"default":10},"response_detail":{"type":"string","enum":["compact","evidence"],"default":"compact"},"law_code":{"type":"string"},"sections":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"year_from":{"type":"integer"},"year_to":{"type":"integer"},"document_type":{"type":"string","enum":["judgment","order","decision","all"],"default":"judgment","description":"judgment = คำพิพากษาศาลฎีกา (ค่าเริ่มต้น), order = คำสั่งคำร้อง/คำสั่งศาลฎีกา, decision = คำวินิจฉัย"},"section_match":{"type":"string","enum":["any","all"],"default":"any"},"mode":{"type":"string","enum":["fast","deep"],"default":"fast"}}},"LawSearchRequest":{"type":"object","required":["law_code"],"properties":{"law_code":{"type":"string","example":"ป.วิ.อ."},"sections":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"provision_type":{"type":"string"},"top_k":{"type":"integer","minimum":1,"maximum":30,"default":10},"response_detail":{"type":"string","enum":["compact","evidence"],"default":"compact"},"document_type":{"type":"string","enum":["judgment","order","decision","all"],"default":"judgment"},"section_match":{"type":"string","enum":["any","all"],"default":"any"},"mode":{"type":"string","enum":["fast","deep"],"default":"fast"}}},"AiSearchRequest":{"type":"object","required":["question"],"properties":{"question":{"type":"string","maxLength":1024},"top_k":{"type":"integer","minimum":1,"maximum":30,"default":10},"response_detail":{"type":"string","enum":["compact","evidence"],"default":"compact"},"mode":{"type":"string","enum":["fast","deep"],"default":"fast"}}},"CaseRequest":{"type":"object","properties":{"deka_no":{"type":"string","example":"2289/2568"},"case_id":{"type":"integer","minimum":1},"include_law_refs":{"type":"boolean","default":true},"include_long_text":{"type":"boolean","default":false},"max_long_text_chars":{"type":"integer","maximum":30000},"document_type":{"type":"string","enum":["judgment","order","decision","all"],"default":"judgment","description":"ไม่พบประเภทที่ขอจะคืน found=false พร้อม alternatives"},"long_text_offset":{"type":"integer","minimum":0,"default":0,"description":"ตำแหน่ง code-point ของช่วงที่จะอ่าน ใช้ next_offset ไล่ต่อจน null"}}},"LawCatalogV2Request":{"type":"object","properties":{"query":{"type":"string","maxLength":1024},"topic_code":{"type":"string"},"law_type_code":{"type":"string"},"fetch_status":{"type":"string","default":"ok"},"has_text":{"type":"boolean"},"law_scope":{"type":"string","enum":["primary","sublaw","all"]},"lifecycle_status":{"type":"string","enum":["current_or_future","active_listing","future_effective","cancelled","all"],"default":"current_or_future"},"top_k":{"type":"integer","minimum":1,"maximum":20,"default":10}}},"LawHistoryV2Request":{"type":"object","properties":{"query":{"type":"string","maxLength":1024},"law_code":{"type":"string"},"law_scope":{"type":"string","enum":["primary","sublaw","all"]},"lifecycle_status":{"type":"string","enum":["all","history","current_or_future","active_listing","future_effective","cancelled","amendment_or_related"],"default":"all"},"top_k":{"type":"integer","minimum":1,"maximum":20,"default":10}}},"LawSectionsV2Request":{"type":"object","required":["query"],"properties":{"query":{"type":"string","maxLength":1024},"law_code":{"type":"string"},"doc_key":{"type":"string"},"topic_code":{"type":"string"},"section_no":{"oneOf":[{"type":"string"},{"type":"integer"}]},"law_scope":{"type":"string","enum":["primary","sublaw","all"]},"lifecycle_status":{"type":"string","enum":["current_or_future","active_listing","future_effective","cancelled","all"],"default":"current_or_future"},"top_k":{"type":"integer","minimum":1,"maximum":20,"default":10},"text_chars":{"type":"integer","minimum":120,"maximum":5000,"default":800}}},"LawSectionV2Request":{"type":"object","properties":{"section_key":{"type":"string"},"doc_key":{"type":"string"},"law_code":{"type":"string"},"section_no":{"oneOf":[{"type":"string"},{"type":"integer"}]},"include_html":{"type":"boolean","default":false},"max_text_chars":{"type":"integer","minimum":500,"maximum":30000,"default":30000}}},"CreateApiKeyRequest":{"type":"object","properties":{"name":{"type":"string","maxLength":80,"default":"default"}}}}},"paths":{"/":{"get":{"security":[],"summary":"Public SLegalTools home page","responses":{"200":{"description":"HTML home page"}}}},"/privacy":{"get":{"security":[],"summary":"Privacy policy","responses":{"200":{"description":"HTML privacy policy"}}}},"/terms":{"get":{"security":[],"summary":"Terms of service","responses":{"200":{"description":"HTML terms of service"}}}},"/health":{"get":{"security":[],"summary":"Public health check","responses":{"200":{"description":"Health status"}}}},"/dashboard":{"get":{"security":[],"summary":"Google login dashboard for API key management","responses":{"200":{"description":"HTML dashboard"}}}},"/install":{"get":{"security":[],"summary":"AI and MCP client installation guide","responses":{"200":{"description":"HTML install guide"}}}},"/install/ai-prompt.txt":{"get":{"security":[],"summary":"Prompt users can give to an AI installer","responses":{"200":{"description":"Plain text install prompt"}}}},"/install/ai-update-v1-prompt.txt":{"get":{"security":[],"summary":"Prompt existing V1 users can give to an AI updater","responses":{"200":{"description":"Plain text V1 update prompt"}}}},"/install/sdeeka_mcp_bridge.py":{"get":{"security":[],"summary":"Downloadable local stdio SDeeka MCP bridge","responses":{"200":{"description":"Python MCP bridge source"}}}},"/install/slegaltools_deka_mcp_bridge.py":{"get":{"security":[],"summary":"Downloadable local stdio MCP bridge (backwards-compatible alias)","responses":{"200":{"description":"Python MCP bridge source"}}}},"/install/requirements.txt":{"get":{"security":[],"summary":"Python dependencies for the local MCP bridge","responses":{"200":{"description":"requirements.txt"}}}},"/install/claude-desktop.example.json":{"get":{"security":[],"summary":"Example stdio MCP server config","responses":{"200":{"description":"Example MCP JSON config"}}}},"/login":{"get":{"security":[],"summary":"Short alias for the Google login dashboard","responses":{"200":{"description":"HTML login page"}}}},"/auth/google/login":{"get":{"security":[],"summary":"Start Google OAuth login","responses":{"302":{"description":"Redirect to Google"},"503":{"description":"OAuth not configured"}}}},"/auth/me":{"get":{"security":[],"summary":"Current dashboard session user","responses":{"200":{"description":"Authenticated user"},"401":{"description":"Not logged in"}}}},"/auth/api-keys":{"get":{"security":[],"summary":"List API keys for the logged-in Google user","responses":{"200":{"description":"API key records"},"401":{"description":"Login required"}}},"post":{"security":[],"summary":"Create API key for logged-in Google user","requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyRequest"}}}},"responses":{"200":{"description":"New API key. The plain key is returned once only."},"401":{"description":"Login required"}}}},"/auth/api-keys/{key_id}/revoke":{"post":{"security":[],"summary":"Revoke one API key for logged-in user","parameters":[{"name":"key_id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Revocation result"},"401":{"description":"Login required"}}}},"/api/search/ai":{"post":{"summary":"One-shot AI-facing Deka search","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSearchRequest"}}}},"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/api/search/text":{"post":{"summary":"Keyword/law-filter text search","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TextSearchRequest"}}}},"responses":{"200":{"description":"Search results"}}}},"/api/search/law":{"post":{"summary":"Search by law code and sections","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LawSearchRequest"}}}},"responses":{"200":{"description":"Law search results"}}}},"/api/tool/get_deka_case":{"post":{"summary":"Get one Deka case by number","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseRequest"}}}},"responses":{"200":{"description":"Case result"}}}},"/api/tool/law_v2_stats":{"post":{"summary":"Return OCS Law Search V2 corpus statistics","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Law V2 statistics"}}}},"/api/tool/law_search_guide_v2":{"post":{"summary":"Return usage rules for Law Search V2 tools","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Law V2 usage guide"}}}},"/api/tool/search_laws_v2":{"post":{"summary":"Search OCS law catalog by title, alias, topic, type, or law code","requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LawCatalogV2Request"}}}},"responses":{"200":{"description":"Law catalog candidates"}}}},"/api/tool/search_law_history_v2":{"post":{"summary":"Search OCS law lifecycle/history metadata including cancelled and amendment rows","requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LawHistoryV2Request"}}}},"responses":{"200":{"description":"Law lifecycle/history candidates"}}}},"/api/tool/search_law_sections_v2":{"post":{"summary":"Search OCS statute sections with FTS and Thai LIKE fallback","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LawSectionsV2Request"}}}},"responses":{"200":{"description":"Statutory section search results"}}}},"/api/tool/get_law_section_v2":{"post":{"summary":"Get full text for one OCS statute section","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LawSectionV2Request"}}}},"responses":{"200":{"description":"One statute section"}}}},"/api/account/entitlements":{"get":{"summary":"Return Deka/Law Free Forever status and Templates Pro Add-on entitlement status","responses":{"200":{"description":"Entitlement summary"}}}},"/api/templates/categories":{"get":{"summary":"List Thai legal pleading template categories (Free)","responses":{"200":{"description":"Template categories"}}},"post":{"summary":"List Thai legal pleading template categories (Free)","responses":{"200":{"description":"Template categories"}}}},"/api/templates/search":{"post":{"summary":"Search Thai legal pleading templates (Requires templates_pro Add-on)","responses":{"200":{"description":"Template search results"},"402":{"description":"Add-on package required"}}}},"/api/templates/{template_id}":{"get":{"summary":"Get one Thai legal pleading template by ID (Requires templates_pro Add-on)","parameters":[{"name":"template_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Template details"},"402":{"description":"Add-on package required"}}}},"/api/pleading/patterns":{"get":{"summary":"List locked Thai pleading block patterns and checklists (Free)","responses":{"200":{"description":"Locked pleading patterns"}}}},"/api/pleading/render":{"post":{"summary":"Validate and render locked Thai pleading paragraphs from packet (Requires templates_pro Add-on)","responses":{"200":{"description":"Rendered locked paragraphs"},"402":{"description":"Add-on package required"}}}},"/api/pleading/check":{"post":{"summary":"Verify a Thai complaint draft against locked pleading paragraphs (Requires templates_pro Add-on)","responses":{"200":{"description":"Draft verification result"},"402":{"description":"Add-on package required"}}}},"/api/petition/patterns":{"get":{"summary":"List 78 locked Thai court petition patterns (Free)","responses":{"200":{"description":"Locked petition patterns"}}},"post":{"summary":"List 78 locked Thai court petition patterns (Free)","responses":{"200":{"description":"Locked petition patterns"}}}},"/api/petition/inspect":{"get":{"summary":"Inspect one locked Thai court petition pattern and required slots (Requires templates_pro Add-on)","responses":{"200":{"description":"Petition pattern inspection"},"402":{"description":"Add-on package required"}}},"post":{"summary":"Inspect one locked Thai court petition pattern and required slots (Requires templates_pro Add-on)","responses":{"200":{"description":"Petition pattern inspection"},"402":{"description":"Add-on package required"}}}},"/api/petition/scan":{"post":{"summary":"Check which required slots and facts are still missing in a Thai court petition packet (Requires templates_pro Add-on)","responses":{"200":{"description":"Petition packet scan result"},"402":{"description":"Add-on package required"}}}},"/api/petition/render":{"post":{"summary":"Validate and render a locked 3-part Thai court petition from packet (Requires templates_pro Add-on)","responses":{"200":{"description":"Rendered 3-part petition"},"402":{"description":"Add-on package required"}}}},"/api/petition/check":{"post":{"summary":"Verify a Thai court petition draft against locked 3-part clauses (Requires templates_pro Add-on)","responses":{"200":{"description":"Petition draft verification result"},"402":{"description":"Add-on package required"}}}},"/api/tool/list_admin_facets":{"post":{"summary":"List Thai Administrative Court (ศาลปกครอง) corpus statistics, 37 categories, and 25 procedural tags (Use ONLY for ศาลปกครอง/คดีปกครอง)","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"AdminCourt facets and stats"}}}},"/api/tool/search_admin_cases":{"post":{"summary":"Hybrid search over Thai Administrative Court (ศาลปกครอง) judgments and orders (Requires admincourt_pro Add-on; DO NOT use as fallback for normal ศาลฎีกา searches)","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"AdminCourt hybrid search results"},"402":{"description":"Add-on package required"}}}},"/api/tool/search_admin_by_law":{"post":{"summary":"Search Thai Administrative Court (ศาลปกครอง) decisions by statute name/code and section number (Requires admincourt_pro Add-on)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"AdminCourt law search results"},"402":{"description":"Add-on package required"}}}},"/api/tool/get_admin_case":{"post":{"summary":"Get one Thai Administrative Court (ศาลปกครอง) case by case_id or red_no (Requires admincourt_pro Add-on)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"AdminCourt case detail"},"402":{"description":"Add-on package required"}}}},"/api/tool/admin_citation_pack":{"post":{"summary":"Build a citation pack for 1-10 Thai Administrative Court (ศาลปกครอง) cases with legal principles and reasoning chunks (Requires admincourt_pro Add-on)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"AdminCourt citation pack"},"402":{"description":"Add-on package required"}}}},"/api/tool/{tool_name}":{"post":{"summary":"Call an allowed SDeeka MCP-compatible tool","parameters":[{"name":"tool_name","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Tool result"},"402":{"description":"Add-on package required"},"404":{"description":"Tool not allowed"}}}}}}