{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Paylead Bridge API",
  "version": "1.0.0",
  "description": "JSON-RPC 2.0 postMessage bridge between the Paylead webapp and native WebView shells.",
  "methods": {
    "browser.open": {
      "description": "Opens a URL in the device's native browser (outside the WebView).",
      "params": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url": {
            "type": "string",
            "pattern": "^https://",
            "maxLength": 2048,
            "description": "URL to open. Must use the https:// scheme.",
            "examples": ["https://www.paylead.fr"]
          }
        },
        "additionalProperties": false
      },
      "result": {
        "type": "object",
        "description": "Empty acknowledgment — the method returns no data on success. Per JSON-RPC 2.0, the presence of `result` (vs `error`) is what signals success.",
        "additionalProperties": false
      }
    },
    "clipboard.write": {
      "description": "Copies text to the device clipboard.",
      "params": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 4096,
            "description": "Text to copy to clipboard.",
            "examples": ["voucher:89d89a45-4f57-4e68-9f61-dc71434b2f26"]
          }
        },
        "additionalProperties": false
      },
      "result": {
        "type": "object",
        "description": "Empty acknowledgment — the method returns no data on success. Per JSON-RPC 2.0, the presence of `result` (vs `error`) is what signals success.",
        "additionalProperties": false
      }
    },
    "file.download": {
      "description": "Downloads a file and presents it to the user.",
      "params": {
        "type": "object",
        "required": ["url"],
        "properties": {
          "url": {
            "type": "string",
            "pattern": "^https://",
            "maxLength": 200,
            "description": "URL of the file to download. Must use the https:// scheme.",
            "examples": ["https://api.paylead.fr/voucher/89d89a45-4f57-4e68-9f61-dc71434b2f26.pdf"]
          },
          "filename": {
            "type": "string",
            "maxLength": 255,
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_\\-.]*$",
            "description": "Suggested filename. Allowed characters: letters, digits, underscore, hyphen, dot. Must start with a letter or digit. The native app must still sanitise before writing to disk.",
            "examples": ["89d89a45-4f57-4e68-9f61-dc71434b2f26.pdf"]
          },
          "mimeType": {
            "type": "string",
            "description": "MIME type hint (e.g. application/pdf).",
            "examples": ["application/pdf"],
            "enum": [
                  "application/pdf",
                  "text/csv",
                  "image/jpeg",
                  "image/jpg",
                  "image/png"
           ]
          }
        },
        "additionalProperties": false
      },
      "result": {
        "type": "object",
        "description": "Empty acknowledgment — the method returns no data on success. Per JSON-RPC 2.0, the presence of `result` (vs `error`) is what signals success.",
        "additionalProperties": false
      }
    }
  },
  "errors": {
    "-32600": "Invalid JSON-RPC 2.0 request",
    "-32601": "Method not found",
    "-32602": "Invalid or missing params",
    "-32000": "Runtime error (scheme blocked, download failed, etc.) — error.message must not contain stack traces or filesystem paths",
    "-32001": "Permission denied (location, etc.) — error.message must not contain stack traces or filesystem paths"
  }
}
