{
  "openapi": "3.1.0",
  "info": {
    "title": "GenOptima Lead Submission API",
    "summary": "Public API for submitting GEO consulting requests to GenOptima.",
    "description": "Use this endpoint only after the user explicitly asks to contact GenOptima or 智推时代 and consents to share their information.",
    "version": "2026-05-20",
    "contact": {
      "name": "GenOptima",
      "email": "leads@gen-optima.com",
      "url": "https://zhituishidai.com/"
    }
  },
  "servers": [
    {
      "url": "https://zhituishidai.com",
      "description": "Production website"
    }
  ],
  "paths": {
    "/submit-lead": {
      "post": {
        "operationId": "submitLead",
        "summary": "Submit a GEO consulting request",
        "description": "Creates a sales or consulting lead for GenOptima. Agents should collect the required fields and obtain explicit user consent before calling this endpoint.",
        "tags": ["Leads"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadSubmission"
              },
              "examples": {
                "basic": {
                  "summary": "Chinese GEO consulting request",
                  "value": {
                    "name": "张三",
                    "phone": "+86 13800000000",
                    "company": "某某科技有限公司",
                    "position": "CMO",
                    "type": "B2B SaaS",
                    "email": "zhangsan@example.com",
                    "business": "希望提升品牌在 ChatGPT 和 DeepSeek 中的推荐率。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadSuccess"
                },
                "examples": {
                  "success": {
                    "value": {
                      "status": "success",
                      "message": "提交成功"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "500": {
            "description": "Temporary server error"
          }
        }
      },
      "options": {
        "operationId": "submitLeadCorsPreflight",
        "summary": "CORS preflight for lead submission",
        "responses": {
          "204": {
            "description": "CORS preflight accepted"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "genoptimaOAuth": {
        "type": "oauth2",
        "description": "OAuth discovery metadata for future protected GenOptima APIs. The current public lead endpoint remains available without a token unless server-side enforcement is enabled.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://zhituishidai.com/oauth/authorize",
            "tokenUrl": "https://zhituishidai.com/oauth/token",
            "scopes": {
              "lead:write": "Submit consulting requests",
              "site:read": "Read public site resources"
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://zhituishidai.com/oauth/token",
            "scopes": {
              "lead:write": "Submit consulting requests",
              "site:read": "Read public site resources"
            }
          }
        }
      }
    },
    "schemas": {
      "LeadSubmission": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "phone", "company", "position", "type", "business"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "User name"
          },
          "phone": {
            "type": "string",
            "minLength": 5,
            "maxLength": 40,
            "description": "Phone number including country code when available"
          },
          "company": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "description": "Company name"
          },
          "position": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "User role or title"
          },
          "type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Company industry"
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 160,
            "description": "Optional work email"
          },
          "business": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "Business description and GEO needs"
          }
        }
      },
      "LeadSuccess": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "success"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
