{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/multimail-dev/json-schema/multimail-dev-signup-request-schema.json",
  "title": "SignupRequest",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/multimail-dev-openapi.yml#/components/schemas/SignupRequest",
  "type": "object",
  "required": [
    "operator_name",
    "accepted_tos",
    "accepted_operator_agreement",
    "accepted_anti_spam_policy",
    "oversight_email",
    "pow_solution"
  ],
  "properties": {
    "operator_name": {
      "type": "string",
      "description": "Company or individual name. Included in identity headers and signature block."
    },
    "payment_method": {
      "type": "string",
      "enum": [
        "stripe",
        "crypto"
      ],
      "description": "Signup intent source. Pricing page starter flow sends stripe."
    },
    "accepted_tos": {
      "type": "boolean",
      "description": "Must be true."
    },
    "accepted_operator_agreement": {
      "type": "boolean",
      "description": "Must be true."
    },
    "accepted_anti_spam_policy": {
      "type": "boolean",
      "description": "Must be true."
    },
    "email_use_type": {
      "type": "string",
      "enum": [
        "transactional",
        "marketing"
      ],
      "description": "Only transactional is accepted today."
    },
    "oversight_email": {
      "type": "string",
      "format": "email"
    },
    "slug": {
      "type": "string",
      "description": "URL-safe slug. Auto-generated from operator_name if omitted."
    },
    "physical_address": {
      "type": "string"
    },
    "use_case": {
      "type": "string"
    },
    "oversight_mode": {
      "type": "string",
      "enum": [
        "gated_all",
        "gated_send",
        "monitored"
      ],
      "description": "Optional initial mailbox oversight mode. Unsafe modes are rejected."
    },
    "cf_challenge_response": {
      "type": "string",
      "maxLength": 4096,
      "description": "Preferred browser Turnstile token field. Mirrors the hidden cf-turnstile-response input value. maxLength keeps API Shield's auto-learned body-size cap above the ~1.6KB Turnstile token (see lesson #18)."
    },
    "turnstile_token": {
      "type": "string",
      "maxLength": 4096,
      "deprecated": true,
      "description": "Legacy Turnstile token field. Accepted for backward compatibility. maxLength matches cf_challenge_response — see lesson #18."
    },
    "fingerprint": {
      "type": "string",
      "maxLength": 256,
      "description": "Optional browser fingerprint used for signup throttling."
    },
    "form_open_at": {
      "type": "integer",
      "format": "int64",
      "description": "Epoch milliseconds when the signup modal opened."
    },
    "pow_solution": {
      "type": "object",
      "required": [
        "algorithm",
        "challenge",
        "number",
        "salt",
        "signature"
      ],
      "description": "Solved ALTCHA proof-of-work challenge from POST /v1/account/challenge.",
      "properties": {
        "algorithm": {
          "type": "string"
        },
        "challenge": {
          "type": "string",
          "description": "Challenge hash from the challenge endpoint"
        },
        "number": {
          "type": "integer",
          "description": "Solved number N where SHA-256(salt + N) matches challenge"
        },
        "salt": {
          "type": "string",
          "description": "Salt from the challenge (echo back unchanged)"
        },
        "signature": {
          "type": "string",
          "description": "Signature from the challenge (echo back unchanged)"
        }
      }
    },
    "attribution": {
      "$ref": "#/$defs/AttributionPayload"
    },
    "agent_did": {
      "type": "string",
      "maxLength": 256,
      "description": "Optional Ed25519 did:key to bind to this account (DID bridge). Provide with did_challenge_id + did_signature; all three together or none."
    },
    "did_challenge_id": {
      "type": "string",
      "maxLength": 64,
      "description": "Opaque challenge_id from POST /v1/account/did-challenge."
    },
    "did_signature": {
      "type": "string",
      "maxLength": 96,
      "description": "base64url Ed25519 signature over the account-bound binding payload (64 raw bytes → ≤88 base64url chars; maxLength 96 keeps the API-Shield body cap above it — lesson #18)."
    }
  },
  "$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
            }
          }
        }
      }
    }
  }
}