{
  "openapi": "3.1.0",
  "info": {
    "title": "CrossBorder A402 API — 跨境商品多语言本地化与合规风控",
    "version": "1.0.0",
    "description": "Alipay Machine Pay (HTTP 402 / A2M) pay-per-call API powered by Cloudflare Workers, D1, and Unisound LLM."
  },
  "servers": [
    {
      "url": "https://a402.spacechats.net"
    }
  ],
  "paths": {
    "/v1/listing/localize": {
      "post": {
        "summary": "跨境商品多语言本地化与合规风控（HTTP 402 按次计费）",
        "parameters": [
          {
            "name": "Payment-Proof",
            "in": "header",
            "required": false,
            "description": "Base64URL-encoded Alipay A402 payment proof after completing payment.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "便携式迷你挂脖风扇 静音无叶 USB充电 3档风力"
                  },
                  "highlights": {
                    "type": "string",
                    "example": "4000mAh长续航、防卷发安全设计、Type-C快充、仅重210g"
                  },
                  "marketplace": {
                    "type": "string",
                    "enum": [
                      "ozon-ru",
                      "amazon-en",
                      "rakuten-ja",
                      "shopee-th",
                      "shopee-en"
                    ],
                    "default": "ozon-ru"
                  },
                  "price_cny": {
                    "type": "number",
                    "example": 38
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment verified, fulfillment confirmed, localized listing delivered.",
            "headers": {
              "Payment-Validation": {
                "description": "Base64URL-encoded JSON verification receipt.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required (¥0.01 CNY). Returns signed Payment-Needed header.",
            "headers": {
              "Payment-Needed": {
                "description": "Base64URL-encoded JSON bill signed with seller RSA2 key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "GET 兼容入口（支持通过 Query 参数调用）",
        "parameters": [
          {
            "name": "title",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "highlights",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "marketplace",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "price_cny",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "Payment-Proof",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Localized listing JSON with Payment-Validation header."
          },
          "402": {
            "description": "Payment Required with Payment-Needed header."
          }
        }
      }
    },
    "/skill.md": {
      "get": {
        "summary": "Alipay A402 Merchant Agent Skill definition",
        "responses": {
          "200": {
            "description": "Markdown Skill document"
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Service readiness check",
        "responses": {
          "200": {
            "description": "JSON status object"
          }
        }
      }
    }
  }
}