{
  "openapi": "3.1.0",
  "info": {
    "title": "ScrubGuard - Deterministic PII & Secret Scrubber API for LLMs",
    "version": "1.0.0",
    "description": "Sub-2ms in-memory PII redaction, Luhn-validated credit card & IBAN scrubbing, secret detection, and reversible LLM tokenization."
  },
  "servers": [
    {
      "url": "https://scrubguard-api.scrubguard.workers.dev"
    }
  ],
  "paths": {
    "/v1/scrub": {
      "post": {
        "summary": "Scrub or reversibly tokenize PII & secrets in text",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "maxLength": 262144
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "tokenize",
                      "redact",
                      "mask"
                    ],
                    "default": "tokenize"
                  },
                  "types": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "enum": [
                        "PRIVATE_KEY",
                        "API_SECRET",
                        "JWT_TOKEN",
                        "CREDIT_CARD",
                        "IBAN",
                        "US_SSN",
                        "EMAIL",
                        "IPV4",
                        "PHONE"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scrubbed text and reversible token vault"
          }
        }
      }
    },
    "/v1/rehydrate": {
      "post": {
        "summary": "Restore tokenized placeholders ([EMAIL_1], [US_SSN_1]) in LLM responses",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text",
                  "vault"
                ],
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "vault": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rehydrated output string"
          }
        }
      }
    },
    "/v1/scrub-json": {
      "post": {
        "summary": "Deeply scrub nested JSON payloads & sensitive key names while preserving schema",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "data"
                ],
                "properties": {
                  "data": {},
                  "mode": {
                    "type": "string",
                    "enum": [
                      "tokenize",
                      "redact",
                      "mask"
                    ],
                    "default": "tokenize"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scrubbed JSON structure and reversible vault"
          }
        }
      }
    }
  }
}