{
  "openapi": "3.1.0",
  "info": {
    "title": "Cloudsign User API Isolated Sandbox",
    "version": "0.1.0-preview.1",
    "description": "Independent AKS / CSS realm and synthetic data; only 12 documented logical operations. No production fallback, cloud storage, real signing, payment, device privacy or administrator actions."
  },
  "servers": [
    {
      "url": "https://www.fenfa.im"
    }
  ],
  "paths": {
    "/sandbox.php": {
      "get": {
        "operationId": "sandboxGet",
        "summary": "Independent sandbox GET",
        "security": [
          {
            "SandboxCS1": []
          }
        ],
        "parameters": [
          {
            "name": "resource",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^/api/v1(?:/[A-Za-z0-9_-]+)+$"
            },
            "description": "Logical sandbox resource from the 12-operation table; not forwarded to production."
          },
          {
            "name": "X-Api-Date",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "X-Api-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            }
          },
          {
            "name": "X-Api-Content-Sha256",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "X-Api-Environment",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "sandbox"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^A[a-f0-9]{32}$"
            }
          },
          {
            "name": "module",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "enterprise",
                "distribution"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Explicitly simulated data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or environment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired or revoked sandbox identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Action or native approval denied",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Own fixture not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Nonce replay, revision or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Bounded request or response exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Shared sandbox or edge request limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "501": {
            "description": "Explicitly unsupported; no production fallback",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Sandbox unavailable or capacity reached",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "sandboxPost",
        "summary": "Independent sandbox POST",
        "security": [
          {
            "SandboxCS1": []
          }
        ],
        "parameters": [
          {
            "name": "resource",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^/api/v1(?:/[A-Za-z0-9_-]+)+$"
            },
            "description": "Logical sandbox resource from the 12-operation table; not forwarded to production."
          },
          {
            "name": "X-Api-Date",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "X-Api-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            }
          },
          {
            "name": "X-Api-Content-Sha256",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "X-Api-Environment",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "sandbox"
            }
          },
          {
            "name": "X-Api-Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{16,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Explicitly simulated data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or environment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired or revoked sandbox identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Action or native approval denied",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Own fixture not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Nonce replay, revision or idempotency conflict",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Bounded request or response exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Shared sandbox or edge request limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "501": {
            "description": "Explicitly unsupported; no production fallback",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Sandbox unavailable or capacity reached",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "environment"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{32}$"
                    },
                    "environment": {
                      "const": "sandbox"
                    },
                    "data": {
                      "type": "object"
                    },
                    "error": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Operation-specific fields documented in OPENAPI_PHASE36.md; 16 KiB maximum."
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SandboxCS1": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "CS1-HMAC-SHA256 with AKS ID and CSS secret. Canonical path /sandbox.php; sorted RFC3986 query includes resource; environment line sandbox. Never send the CSS secret itself."
      }
    }
  },
  "x-cloudsign-logical-operations": [
    {
      "method": "GET",
      "resource": "/api/v1/whoami",
      "actions": [],
      "description": "当前测试凭据的动作与到期时间；不返回生产账号信息。"
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps",
      "actions": [
        "enterprise:ReadApps",
        "distribution:ReadApps"
      ],
      "description": "只列出获准模块的本人合成应用；limit 1–50，after 为上一页完整 A ID，module 可选 enterprise/distribution。"
    },
    {
      "method": "POST",
      "resource": "/api/v1/apps",
      "actions": [
        "{module}:CreateApps"
      ],
      "description": "创建合成应用及合成版本；企业模块只接受 ipa。",
      "input_example": {
        "module": "distribution",
        "platform": "ipa",
        "name": "沙箱应用",
        "bundle_id": "test.cloudsign.example"
      }
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps/{app_id}",
      "actions": [
        "{module}:ReadApps"
      ],
      "description": "查询本人合成应用。"
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps/{app_id}/metadata",
      "actions": [
        "{module}:ReadApps"
      ],
      "description": "查询名称、备注和并发控制 revision。"
    },
    {
      "method": "POST",
      "resource": "/api/v1/apps/{app_id}/metadata",
      "actions": [
        "{module}:UpdateMetadata"
      ],
      "description": "revision 必须匹配当前资料；失败后先重新查询。",
      "input_example": {
        "revision": 1,
        "name": "新的名称",
        "remark": "测试备注"
      }
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps/{app_id}/versions",
      "actions": [
        "{module}:ReadVersions"
      ],
      "description": "查询合成版本，size_bytes=0，没有真实安装包或下载链接。"
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps/{app_id}/statistics",
      "actions": [
        "{module}:ReadStatistics"
      ],
      "description": "返回标注 synthetic-fixture 的零统计，不能用于真实安装量判断。"
    },
    {
      "method": "GET",
      "resource": "/api/v1/apps/{app_id}/jobs",
      "actions": [
        "enterprise:ReadJobs"
      ],
      "description": "企业合成应用的模拟任务，最多返回 50 条。"
    },
    {
      "method": "POST",
      "resource": "/api/v1/apps/{app_id}/jobs",
      "actions": [
        "enterprise:CreateJobs"
      ],
      "description": "指定此应用自己的合成版本；只生成 simulation-only 结果，不运行真实签名。",
      "input_example": {
        "source_version_id": "{version_id}"
      }
    },
    {
      "method": "GET",
      "resource": "/api/v1/jobs/{job_id}",
      "actions": [
        "enterprise:ReadJobs"
      ],
      "description": "查询本人模拟任务。"
    },
    {
      "method": "POST",
      "resource": "/api/v1/apps/{app_id}/trash",
      "actions": [
        "{module}:TrashApps"
      ],
      "description": "确认后删除此合成应用，不影响任何生产应用或文件。",
      "input_example": {
        "confirm_app_id": "{app_id}"
      }
    }
  ],
  "x-cloudsign-usage": {
    "identity": "仅 AKS / CSS、环境 sandbox；在原生开发者中心经独立审批后创建。",
    "resource": "app_id 是完整 A+32小写hex，version_id 为 V+32小写hex，job_id 为 J+32小写hex；来自本人沙箱查询结果。{module} 由应用实际模块确定。",
    "signing": "CS1-HMAC-SHA256；Host 为网站主机名，路径固定 /sandbox.php，RFC3986 查询包含 resource 并排序，正文 SHA-256、UTC 日期、新 nonce、sandbox 环境行和 POST 稳定幂等键均参与签名。",
    "limits": "正文 16 KiB；请求时间窗口 300 秒；每次重试更新 nonce，保持写入内容和幂等键不变。",
    "unsupported": "真实上传/下载、云存储、证书、扣费、设备隐私、管理员动作返回 SandboxUnsupported；不会转发生产。",
    "response": "所有成功结果含 environment=sandbox 与 simulated=true；模拟任务不代表真实签名成功。"
  }
}
