{
    "openapi": "3.1.0",
    "info": {
        "title": "Cloudsign User API Isolated Sandbox",
        "version": "0.1.0-preview.1",
        "description": "使用自己的沙箱凭据练习身份查询、模拟应用、版本或签名任务。先以支持的只读操作确认请求，再按逻辑操作列表练习写入。用响应的 environment 和 simulated 确认结果属于沙箱。"
    },
    "servers": [
        {
            "url": "https://www.onesignios.com"
        }
    ],
    "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": "根据 x-cloudsign-logical-operations 中对应操作的 input_example 填写 JSON 对象。请求正文最多 16 KiB。"
                            }
                        }
                    }
                }
            }
        }
    },
    "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，module 可填 enterprise 或 distribution。返回的 next_after 有值时，将它用作下一页的 after。"
        },
        {
            "method": "POST",
            "resource": "/api/v1/apps",
            "actions": [
                "{module}:CreateApps"
            ],
            "description": "创建模拟应用，同时准备一个可通过版本列表查询的模拟版本。企业签名的 platform 填 ipa。保存响应的应用 ID 后再查询版本。",
            "input_example": {
                "module": "distribution",
                "platform": "ipa",
                "name": "沙箱应用",
                "bundle_id": "test.cloudsign.example"
            }
        },
        {
            "method": "GET",
            "resource": "/api/v1/apps/{app_id}",
            "actions": [
                "{module}:ReadApps"
            ],
            "description": "按完整应用 ID 查询自己的模拟应用。"
        },
        {
            "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。练习企业签名时，从 items 中保存模拟版本 ID。"
        },
        {
            "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": "用该应用的模拟版本 ID 创建签名任务。保存返回的任务 ID，再查询原任务，核对 state 和 result_kind=simulation-only。",
            "input_example": {
                "source_version_id": "{version_id}"
            }
        },
        {
            "method": "GET",
            "resource": "/api/v1/jobs/{job_id}",
            "actions": [
                "enterprise:ReadJobs"
            ],
            "description": "用创建签名返回的任务 ID 查询模拟状态，并核对 app_id 和 source_version_id。"
        },
        {
            "method": "POST",
            "resource": "/api/v1/apps/{app_id}/trash",
            "actions": [
                "{module}:TrashApps"
            ],
            "description": "确认模拟应用 ID 后删除该应用。只处理指定沙箱应用。",
            "input_example": {
                "confirm_app_id": "{app_id}"
            }
        }
    ],
    "x-cloudsign-usage": {
        "identity": "使用开发者中心创建的独立沙箱 AccessKey（AKS）与对应 Secret，并将请求环境设为 sandbox。",
        "resource": "从自己的沙箱响应取得完整应用、版本与签名任务 ID，分别以 A、V 和 J 开头，后接 32 位小写十六进制字符。{module} 按应用所属产品填写。",
        "signing": "使用 CS1-HMAC-SHA256。Host 为网站主机名，签名路径为 /sandbox.php。规范查询包含 resource，将参数按 RFC 3986 编码并排序。正文 SHA-256、UTC 日期、新 nonce、sandbox 环境行和 POST 幂等键均参与签名。",
        "limits": "正文最多 16 KiB，请求时间允许 300 秒偏差。写入响应未知时，在原沙箱使用同一 AKS、原路径、正文和幂等键，并为重试生成新 nonce。",
        "unsupported": "请以逻辑操作列表为准。沙箱只返回模拟结果。请求未支持的操作时返回 SandboxUnsupported。",
        "response": "所有成功结果含 environment=sandbox 与 simulated=true；模拟任务不代表真实签名成功。"
    }
}
