{"openapi":"3.0.3","info":{"title":"LLM Chat Messages Policy Proxy & Sanitizer API","version":"1.0.0","description":"Stateless edge policy proxy that accepts multi-turn OpenAI, Anthropic, and agent chat message arrays, scans user and tool turns for prompt injection, redacts PII and secrets with a unified cross-turn restoration map, and strips email reply quotes."},"servers":[{"url":"https://api.tinplate.dev","description":"Production Edge Gateway"}],"components":{"schemas":{"LlmMessagesGuardResponseData":{"type":"object","properties":{"safe":{"type":"boolean","example":true},"verdict":{"type":"string","enum":["allow","review","block"],"example":"allow"},"max_risk_score":{"type":"number","minimum":0,"maximum":100,"example":0},"sanitized_messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","developer","user","assistant","tool"],"example":"user"},"content":{"anyOf":[{"type":"string","maxLength":131072},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","minLength":1,"maxLength":64,"example":"text"},"text":{"type":"string","maxLength":131072,"example":"Hello, my email is alice@tinplate.dev"}},"required":["type"]},"minItems":1,"maxItems":32}],"example":"Please summarize my account. My email is alice@tinplate.dev and my key is sk-proj-1234567890abcdefghijklmnop."},"name":{"type":"string","maxLength":128},"tool_call_id":{"type":"string","maxLength":128}},"required":["role","content"]}},"restoration_map":{"type":"object","additionalProperties":{"type":"string"},"example":{"[PII_EMAIL_1]":"alice@tinplate.dev","[SECRET_OPENAI_API_KEY_1]":"sk-proj-1234567890abcdefghijklmnop"},"description":"Unified token-to-original map across all turns for stateless restoration after LLM completion."},"summary":{"type":"object","properties":{"total_messages":{"type":"integer","minimum":0,"example":2},"scanned_messages":{"type":"integer","minimum":0,"example":1},"blocked_turns":{"type":"integer","minimum":0,"example":0},"total_pii_redacted":{"type":"integer","minimum":0,"example":1},"total_secrets_redacted":{"type":"integer","minimum":0,"example":1},"injection_categories":{"type":"array","items":{"type":"string"},"example":[]}},"required":["total_messages","scanned_messages","blocked_turns","total_pii_redacted","total_secrets_redacted","injection_categories"]},"turn_findings":{"type":"array","items":{"type":"object","properties":{"turn_index":{"type":"integer","minimum":0,"example":1},"role":{"type":"string","enum":["system","developer","user","assistant","tool"],"example":"user"},"verdict":{"type":"string","enum":["allow","review","block"],"example":"allow"},"risk_score":{"type":"number","minimum":0,"maximum":100,"example":0},"injection_categories":{"type":"array","items":{"type":"string"},"example":[]},"pii_redacted_count":{"type":"integer","minimum":0,"example":1},"secrets_redacted_count":{"type":"integer","minimum":0,"example":1},"pii_types":{"type":"array","items":{"type":"string"},"example":["EMAIL"]},"secret_types":{"type":"array","items":{"type":"string"},"example":["OPENAI_API_KEY"]}},"required":["turn_index","role","verdict","risk_score","injection_categories","pii_redacted_count","secrets_redacted_count","pii_types","secret_types"]}}},"required":["safe","verdict","max_risk_score","sanitized_messages","restoration_map","summary","turn_findings"]},"LlmMessagesGuardRequest":{"type":"object","properties":{"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","developer","user","assistant","tool"],"example":"user"},"content":{"anyOf":[{"type":"string","maxLength":131072},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","minLength":1,"maxLength":64,"example":"text"},"text":{"type":"string","maxLength":131072,"example":"Hello, my email is alice@tinplate.dev"}},"required":["type"]},"minItems":1,"maxItems":32}],"example":"Please summarize my account. My email is alice@tinplate.dev and my key is sk-proj-1234567890abcdefghijklmnop."},"name":{"type":"string","maxLength":128},"tool_call_id":{"type":"string","maxLength":128}},"required":["role","content"]},"minItems":1,"maxItems":100,"description":"Array of OpenAI, Anthropic, or agent chat messages to inspect and sanitize in a single pass."},"sensitivity":{"type":"string","enum":["low","medium","high"],"default":"medium","example":"medium","description":"Prompt-injection threshold sensitivity preset."},"check_prompt_injection":{"type":"boolean","default":true,"example":true,"description":"Scan user and tool turns for prompt injection and jailbreaks."},"redact_pii":{"type":"boolean","default":true,"example":true,"description":"Mask emails, phones, IBANs, credit cards, and national IDs across turns."},"scan_secrets":{"type":"boolean","default":true,"example":true,"description":"Scrub leaked API keys, tokens, PEM keys, and credentials across turns."},"strip_email_quotes":{"type":"boolean","default":false,"example":false,"description":"Strip quoted email reply chains and signature blocks from user turns before scanning."},"locales":{"type":"array","items":{"type":"string","minLength":2,"maxLength":10},"maxItems":10,"default":["GLOBAL","EU","US"],"example":["GLOBAL","EU","US"],"description":"Locale sets for PII detection."}},"required":["messages"]},"ResponseMeta":{"type":"object","required":["request_id"],"properties":{"request_id":{"type":"string","format":"uuid"},"ms":{"type":"integer","minimum":0},"version":{"type":"string","example":"1.0.0"}}},"ErrorEnvelope":{"type":"object","required":["ok","error","meta"],"properties":{"ok":{"type":"boolean","enum":[false]},"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","example":"invalid_input"},"message":{"type":"string","example":"Request body failed validation"}}},"meta":{"$ref":"#/components/schemas/ResponseMeta"}}}},"parameters":{}},"paths":{"/v1/llm-messages-guard":{"post":{"tags":["37_LLM_MESSAGES_GUARD"],"summary":"Inspect and sanitize multi-turn OpenAI, Anthropic, and agent chat message arrays for prompt injection, PII, and leaked secrets in one call","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LlmMessagesGuardRequest"}}}},"responses":{"200":{"description":"Sanitized messages array, unified restoration map, and per-turn security findings","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"$ref":"#/components/schemas/LlmMessagesGuardResponseData"},"meta":{"$ref":"#/components/schemas/ResponseMeta"}},"required":["ok","data","meta"]}}}},"400":{"description":"Invalid input or malformed JSON request body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Missing or invalid authentication credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"413":{"description":"Request payload exceeds subscribed plan byte cap","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}}}}