{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/multimail-dev/json-schema/multimail-dev-pricing-checkout-request-schema.json",
  "title": "PricingCheckoutRequest",
  "description": "Paid signup + Stripe checkout body for POST /v1/billing/pricing-checkout. Named (rather than inline) so scripts/verify-api-shield-sync.sh can confirm the Turnstile maxLength cap, mirroring SignupRequest (see lesson #18).",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/multimail-dev-openapi.yml#/components/schemas/PricingCheckoutRequest",
  "type": "object",
  "required": [
    "operator_name",
    "oversight_email",
    "plan",
    "accepted_tos",
    "accepted_operator_agreement",
    "accepted_anti_spam_policy"
  ],
  "properties": {
    "operator_name": {
      "type": "string"
    },
    "oversight_email": {
      "type": "string",
      "format": "email"
    },
    "plan": {
      "type": "string",
      "enum": [
        "builder",
        "pro",
        "scale"
      ]
    },
    "interval": {
      "type": "string",
      "enum": [
        "monthly",
        "annual"
      ],
      "default": "monthly"
    },
    "accepted_tos": {
      "type": "boolean"
    },
    "accepted_operator_agreement": {
      "type": "boolean"
    },
    "accepted_anti_spam_policy": {
      "type": "boolean"
    },
    "cf_challenge_response": {
      "type": "string",
      "maxLength": 4096,
      "description": "Preferred browser Turnstile token field (mirrors SignupRequest). Not read by this endpoint — Stripe handles fraud on paid checkout — but declared so API Shield's body-size cap stays above the ~1.6KB token if a browser sends one (see lesson #18)."
    },
    "turnstile_token": {
      "type": "string",
      "maxLength": 4096,
      "deprecated": true,
      "description": "Legacy Turnstile token field. maxLength keeps API Shield's auto-learned body-size cap above the ~1.6KB token (see lesson #18)."
    },
    "use_case": {
      "type": "string"
    },
    "oversight_mode": {
      "type": "string",
      "enum": [
        "gated_all",
        "gated_send",
        "monitored"
      ]
    },
    "attribution": {
      "$ref": "#/$defs/AttributionPayload"
    }
  },
  "$defs": {
    "AttributionPayload": {
      "type": "object",
      "description": "Optional client-captured conversion attribution (Phase 2 of plan 2026-04-27-003). The browser persists this in localStorage.mm_attribution_v1 and forwards it on signup. Server-side validator at src/lib/attribution.ts is the source of truth — bad shapes are silently dropped, NEVER reject the signup. additionalProperties:false on this object AND its sub-objects keeps the API Shield body-size cap honest even if the per-operation mitigation pin in scripts/sync-api-shield.sh is ever undone: an attacker cannot pad the body with arbitrary unknown keys to bypass the per-field maxLengths (adversary review iter1 finding ATTR-1).",
      "additionalProperties": false,
      "properties": {
        "first": {
          "$ref": "#/$defs/AttributionVisit"
        },
        "last": {
          "$ref": "#/$defs/AttributionVisit"
        },
        "visits": {
          "type": "integer",
          "format": "int32",
          "minimum": 1,
          "maximum": 1000000,
          "description": "Visit counter, incremented client-side. Server validator coerces missing/zero/negative values to 1."
        },
        "version": {
          "type": "integer",
          "format": "int32",
          "enum": [
            1
          ],
          "description": "Schema version. Only 1 is currently accepted; future bumps will rotate the localStorage key client-side and add new branches server-side."
        }
      }
    },
    "AttributionVisit": {
      "type": "object",
      "description": "A single landing event — first or last touch.",
      "additionalProperties": false,
      "properties": {
        "ts": {
          "type": "integer",
          "format": "int64",
          "description": "Epoch milliseconds at landing."
        },
        "landing_path": {
          "type": "string",
          "maxLength": 256,
          "description": "Pathname of the landing page (no host)."
        },
        "params": {
          "type": "object",
          "description": "Tracked URL params present on the landing page. All keys optional; unknown keys are dropped server-side. additionalProperties:false enforces the allowlist at the schema layer too (adversary review iter1 ATTR-1).",
          "additionalProperties": false,
          "properties": {
            "utm_source": {
              "type": "string",
              "maxLength": 256
            },
            "utm_medium": {
              "type": "string",
              "maxLength": 256
            },
            "utm_campaign": {
              "type": "string",
              "maxLength": 256
            },
            "utm_content": {
              "type": "string",
              "maxLength": 256
            },
            "utm_term": {
              "type": "string",
              "maxLength": 256
            },
            "gclid": {
              "type": "string",
              "maxLength": 256
            },
            "fbclid": {
              "type": "string",
              "maxLength": 256
            },
            "msclkid": {
              "type": "string",
              "maxLength": 256
            }
          }
        }
      }
    }
  }
}