{"openapi":"3.1.0","info":{"title":"ScanReport Decoder API","version":"1.0.0","description":"Interprets OBD-II diagnostic trouble codes and readiness monitor data for used-vehicle buyers. The diagnostic engine is independent of the web interface so the same rules can serve a future ChatGPT Action or MCP adapter. Responses never contain credentials and never claim live data that was not retrieved.","contact":{"name":"ScanReport Decoder","url":"/api-docs"}},"servers":[{"url":"https://scan.ratethispro.com/api/v1","description":"ScanReport Decoder (custom domain)"},{"url":"/api/v1","description":"Same origin as the app"}],"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"A Base44 app user access token. Required for anything that creates or reads a saved report."},"apiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Server-to-server key configured by the app operator. Allows stateless code lookups and analyses only."}},"schemas":{"DiagnosticCode":{"type":"object","properties":{"code":{"type":"string","examples":["P0420"]},"category":{"type":"string","enum":["P","B","C","U","unknown"]},"code_status":{"type":"string","enum":["stored","pending","permanent","current","historical","unknown"]},"provider":{"type":"string","nullable":true},"provider_title":{"type":"string","nullable":true},"provider_description":{"type":"string","nullable":true},"severity":{"type":"string","nullable":true},"safety_risk":{"type":"string","nullable":true},"emissions_related":{"type":"boolean","nullable":true},"lookup_status":{"type":"string","enum":["verified","not_found","unverified","error","not_configured"]},"confidence":{"type":"string","enum":["high","medium","low","none"]},"retrieved_at":{"type":"string","format":"date-time","nullable":true}}},"ReadinessMonitor":{"type":"object","properties":{"monitor_name":{"type":"string","examples":["Catalyst"]},"monitor_status":{"type":"string","enum":["ready","not_ready","not_supported","unknown"]}}},"Error":{"type":"object","properties":{"error":{"type":"string","examples":["invalid_code"]},"message":{"type":"string"}}}}},"paths":{"/health":{"get":{"summary":"Service and provider configuration health","security":[],"responses":{"200":{"description":"Database state, provider configuration flags and last-24h counters.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/dtc/lookup":{"post":{"summary":"Look up one diagnostic trouble code","description":"Runs the provider chain (CarVector, CarAPI, RapidAPI when verified, then the stored generic reference) and returns the normalised result with its source and retrieval time.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["code"],"properties":{"code":{"type":"string","examples":["P0300"]}}}}}},"responses":{"200":{"description":"Normalised code data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiagnosticCode"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Invalid code format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/scan/upload":{"post":{"summary":"Create a report from a file, text or code list","description":"Accepts multipart/form-data with a file field (PDF, JPG or PNG, 15 MB maximum) plus an optional JSON vehicle field, or JSON with text or a codes array. Creates a saved report owned by the caller in needs_confirmation state.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"},"vehicle":{"type":"string","description":"JSON string with year, make, model, engine, mileage"}}}},"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","description":"Raw scan text to parse"},"codes":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"status":{"type":"string"}}}},"vehicle":{"type":"object"}}}}}},"responses":{"201":{"description":"Report created","content":{"application/json":{"schema":{"type":"object"}}}},"402":{"description":"Free plan report limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A user token is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"File too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/scan/analyze":{"post":{"summary":"Run the interpretation engine","description":"With report_id (user token only) it analyses a saved report and persists codes, monitors and findings. With a codes array it returns a stateless analysis without saving anything.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"report_id":{"type":"string"},"codes":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"status":{"type":"string"}}}},"monitors":{"type":"array","items":{"$ref":"#/components/schemas/ReadinessMonitor"}},"vehicle":{"type":"object"}}}}}},"responses":{"200":{"description":"Assessment result","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Report not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Missing report_id or codes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/{report_id}":{"get":{"summary":"Read a saved report","description":"Returns the report, its codes, monitors and findings. Only the signed-in owner can read a report.","parameters":[{"name":"report_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Report bundle","content":{"application/json":{"schema":{"type":"object"}}}},"403":{"description":"A user token is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found or not owned by the caller","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}