{"openapi":"3.0.0","info":{"title":"diagram.bhk.dev API","version":"1.0.0","description":"Diagram rendering API for AI agents"},"servers":[{"url":"http://localhost:8787","description":"Local development"},{"url":"https://diagram.bhk.dev"}],"components":{"schemas":{},"parameters":{}},"paths":{"/api/render":{"post":{"tags":["Diagrams"],"description":"Store Mermaid source and return the website viewer URL plus the raw source URL","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":1,"description":"Diagram source code"},"type":{"type":"string","enum":["mermaid"],"description":"Diagram type"}},"required":["code","type"]}}}},"responses":{"200":{"description":"Diagram already existed in system and was returned from cache","content":{"application/json":{"schema":{"type":"object","properties":{"hash":{"type":"string","description":"Content hash"},"type":{"type":"string","description":"Diagram type to render on the frontend"},"url":{"type":"string","description":"Public viewer URL"},"raw":{"type":"string","description":"Raw API URL for fetching diagram source"},"cached":{"type":"boolean","description":"True when the diagram already exists"}},"required":["hash","type","url","raw","cached"]}}}},"201":{"description":"Diagram was stored successfully and a new viewer URL was created","content":{"application/json":{"schema":{"type":"object","properties":{"hash":{"type":"string","description":"Content hash"},"type":{"type":"string","description":"Diagram type to render on the frontend"},"url":{"type":"string","description":"Public viewer URL"},"raw":{"type":"string","description":"Raw API URL for fetching diagram source"},"cached":{"type":"boolean","description":"True when the diagram already exists"}},"required":["hash","type","url","raw","cached"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"402":{"description":"Payment required. Retry with MPP credential from the challenge response."},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"500":{"description":"Payment middleware misconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/d/{hash}":{"get":{"tags":["Diagrams"],"description":"Get diagram by hash","parameters":[{"schema":{"type":"string","pattern":"^[a-f0-9]{16}$"},"required":true,"name":"hash","in":"path"}],"responses":{"200":{"description":"Diagram data","content":{"application/json":{"schema":{"type":"object","properties":{"hash":{"type":"string"},"code":{"type":"string"},"type":{"type":"string"},"createdAt":{"type":"string"},"codeLength":{"type":"number"}},"required":["hash","code","type","createdAt","codeLength"]}}}},"400":{"description":"Invalid hash format","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"404":{"description":"Diagram not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/d/{hash}/raw":{"get":{"tags":["Diagrams"],"description":"Get raw diagram source","parameters":[{"schema":{"type":"string","pattern":"^[a-f0-9]{16}$"},"required":true,"name":"hash","in":"path"}],"responses":{"200":{"description":"Raw diagram source","content":{"text/plain":{"schema":{"type":"string"}}}},"400":{"description":"Invalid hash format","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"404":{"description":"Diagram not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/health":{"get":{"tags":["System"],"description":"Health check endpoint","responses":{"200":{"description":"Health check","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"timestamp":{"type":"string"}},"required":["status","timestamp"]}}}}}}}}}