{
  "openapi": "3.1.0",
  "info": {
    "title": "火花后端自动接入API",
    "version": "3.0.0",
    "description": "供游戏开发AI使用。正文最大64KiB，Bearer从游戏环境读取，不在公开文档提供。管理后台审核接口不属于游戏AI的权限。"
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "security": [
    {
      "GameIntegrationToken": []
    }
  ],
  "paths": {
    "/api/sdk/applications/{category}/{integratedApplicationId}": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getIntegrationState",
        "description": "按phase和审核反馈决定下一步；建议60秒轮询",
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/State"
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/applications/{category}/{integratedApplicationId}/submission": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "put": {
        "operationId": "submitGame",
        "description": "提交资料与任务建议；相同正文重试不增加revision",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Submission"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 2147483647
                    }
                  },
                  "required": [
                    "revision"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/applications/{category}/{integratedApplicationId}/manifest": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getManifest",
        "description": "审核后自动生成任务要求；409时读取状态并等待",
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManifestResponse"
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/applications/{category}/{integratedApplicationId}/trials": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "operationId": "submitTrial",
        "description": "同eventId同内容幂等，不同内容409；只校验字段与条件，不经过游戏/中转/钱包",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrialRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxReceipt"
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "resetTrials",
        "description": "仅可重置本版本未审核通过的测试，清除全部覆盖记录",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "manifestVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  }
                },
                "required": [
                  "manifestVersion"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cleared": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "cleared"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/applications/{category}/{integratedApplicationId}/trials/{eventId}": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "eventId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        }
      ],
      "get": {
        "operationId": "getTrialReceipt",
        "description": "读取当前清单版本已保存的隔离回执",
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxReceipt"
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/applications/{category}/{integratedApplicationId}/receipts/{eventId}": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "integratedApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "eventId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        }
      ],
      "get": {
        "operationId": "getPlatformReceipt",
        "description": "读取已有正式签名上报链路的处理结果；不等于奖励到账",
        "responses": {
          "200": {
            "description": "成功；联调还必须检查receipt.valid与qualified",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "environment": {
                      "const": "production"
                    },
                    "processedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "result": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "additionalProperties": true
                    },
                    "meaning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "environment",
                    "processedAt",
                    "result",
                    "meaning"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "参数或JSON无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "凭据无效，停止重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "记录不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "待审核、版本过期或业务冲突，读取状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "正文超过64KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "本轮测试已满，按协议重置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务故障，退避重试",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/enrollments/applications": {
      "post": {
        "operationId": "applyForEnrollment",
        "description": "应用后端自动生成UUID和随机凭据，发送自身已有资料；不使用人工表单或邀请码。相同资料重试幂等。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Enrollment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "申请或审核结果；通过后使用返回的sdkPath。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentState"
                }
              }
            }
          }
        }
      }
    },
    "/api/sdk/enrollments/applications/{category}/{externalApplicationId}": {
      "parameters": [
        {
          "name": "category",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        {
          "name": "externalApplicationId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "operationId": "getEnrollment",
        "description": "使用申请时自动生成的同一凭据查询，建议60秒；审核通过不等于正式启用。",
        "responses": {
          "200": {
            "description": "申请或审核结果；通过后使用返回的sdkPath。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentState"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "GameIntegrationToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "SDK_PORTAL_TOKEN；不是微信密钥、本机服务令牌或中转签名密钥"
      }
    },
    "schemas": {
      "Field": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-zA-Z_][a-zA-Z0-9_]{0,63}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "\\S"
          },
          "type": {
            "enum": [
              "number",
              "boolean",
              "string"
            ]
          },
          "unit": {
            "type": "string",
            "minLength": 0,
            "maxLength": 30
          },
          "meaning": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "pattern": "\\S"
          },
          "trigger": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "pattern": "\\S"
          }
        },
        "required": [
          "name",
          "label",
          "type",
          "unit",
          "meaning",
          "trigger"
        ],
        "additionalProperties": false
      },
      "TaskProposal": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-zA-Z0-9_-]{1,64}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "\\S"
          },
          "conditionType": {
            "type": "string",
            "minLength": 0,
            "maxLength": 64
          },
          "conditionValue": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "bountyRewardAmountFen": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000000
          },
          "maxParticipants": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          }
        },
        "required": [
          "key",
          "name",
          "conditionType",
          "conditionValue",
          "bountyRewardAmountFen",
          "maxParticipants"
        ],
        "additionalProperties": false
      },
      "Submission": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "\\S"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "pattern": "\\S"
          },
          "iconUrl": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "format": "uri"
          },
          "entryUrl": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "format": "uri"
          },
          "serviceVersion": {
            "type": "string",
            "pattern": "^\\d+\\.\\d+\\.\\d+$"
          },
          "capabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Field"
            },
            "minItems": 1,
            "maxItems": 64
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskProposal"
            },
            "minItems": 1,
            "maxItems": 64
          }
        },
        "required": [
          "name",
          "description",
          "iconUrl",
          "entryUrl",
          "serviceVersion",
          "capabilities",
          "tasks"
        ],
        "additionalProperties": false,
        "description": "capabilities.name与tasks.key分别唯一；conditionType必须引用capabilities.name；布尔任务目标必须为1。maxParticipants是推广参与名额，不是奖励预算。"
      },
      "TrialRequest": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_.:-]{1,100}$"
          },
          "manifestVersion": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "userId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "data": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                },
                {
                  "type": "string",
                  "minLength": 0,
                  "maxLength": 1000
                }
              ]
            }
          }
        },
        "required": [
          "eventId",
          "manifestVersion",
          "userId",
          "data"
        ],
        "additionalProperties": false
      },
      "TaskResult": {
        "type": "object",
        "properties": {
          "bountyTaskId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "qualified": {
            "type": "boolean"
          },
          "progress": {
            "type": [
              "number",
              "null"
            ]
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "bountyTaskId",
          "qualified",
          "progress",
          "reason"
        ],
        "additionalProperties": false
      },
      "TrialReceipt": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string"
          },
          "digest": {
            "type": "string"
          },
          "manifestVersion": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "userId": {
            "type": "string"
          },
          "valid": {
            "type": "boolean"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskResult"
            },
            "minItems": 0,
            "maxItems": 64
          }
        },
        "required": [
          "eventId",
          "digest",
          "manifestVersion",
          "receivedAt",
          "userId",
          "valid",
          "errors",
          "results"
        ],
        "additionalProperties": false
      },
      "Task": {
        "type": "object",
        "properties": {
          "bountyTaskId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "name": {
            "type": "string"
          },
          "conditionType": {
            "type": "string"
          },
          "conditionValue": {
            "type": "integer"
          },
          "bountyRewardAmountFen": {
            "type": "integer"
          },
          "maxParticipants": {
            "type": [
              "integer",
              "null"
            ]
          },
          "ruleVersion": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "bountyTaskStatus": {
            "enum": [
              0,
              1
            ]
          },
          "startAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "endAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "bountyTaskId",
          "name",
          "conditionType",
          "conditionValue",
          "bountyRewardAmountFen",
          "maxParticipants",
          "ruleVersion",
          "bountyTaskStatus",
          "startAt",
          "endAt"
        ],
        "additionalProperties": false
      },
      "Manifest": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sourceHash": {
            "type": "string"
          },
          "submissionRevision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Field"
            },
            "minItems": 1,
            "maxItems": 64
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Task"
            },
            "minItems": 1,
            "maxItems": 64
          }
        },
        "required": [
          "version",
          "publishedAt",
          "sourceHash",
          "submissionRevision",
          "fields",
          "tasks"
        ],
        "additionalProperties": false
      },
      "State": {
        "type": "object",
        "properties": {
          "protocolVersion": {
            "type": "integer"
          },
          "revision": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2147483647
          },
          "submission": {
            "$ref": "#/components/schemas/Submission"
          },
          "manifest": {
            "$ref": "#/components/schemas/Manifest"
          },
          "managedTaskIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "minItems": 0,
            "maxItems": 64
          },
          "taskReview": {
            "enum": [
              "pending",
              "accepted",
              "changes_requested"
            ]
          },
          "review": {
            "enum": [
              "pending",
              "accepted",
              "changes_requested"
            ]
          },
          "feedback": {
            "type": "string"
          },
          "trials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrialReceipt"
            },
            "minItems": 0,
            "maxItems": 200
          },
          "credentialConfigured": {
            "type": "boolean"
          },
          "manifestStale": {
            "type": "boolean"
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "bountyTaskId": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 2147483647
                },
                "positive": {
                  "type": "boolean"
                },
                "negative": {
                  "type": "boolean"
                }
              },
              "required": [
                "bountyTaskId",
                "positive",
                "negative"
              ],
              "additionalProperties": false
            },
            "minItems": 0,
            "maxItems": 64
          },
          "ready": {
            "type": "boolean"
          },
          "phase": {
            "enum": [
              "awaiting_submission",
              "awaiting_tasks_review",
              "integrating",
              "awaiting_review",
              "changes_requested",
              "approved"
            ]
          },
          "category": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          }
        },
        "required": [
          "revision",
          "review",
          "feedback",
          "trials",
          "credentialConfigured",
          "manifestStale",
          "checks",
          "ready",
          "phase"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "SandboxReceipt": {
        "type": "object",
        "properties": {
          "environment": {
            "const": "sandbox"
          },
          "settlement": {
            "const": "disabled"
          },
          "receipt": {
            "$ref": "#/components/schemas/TrialReceipt"
          }
        },
        "required": [
          "environment",
          "settlement",
          "receipt"
        ],
        "additionalProperties": false
      },
      "ManifestResponse": {
        "type": "object",
        "properties": {
          "manifest": {
            "$ref": "#/components/schemas/Manifest"
          },
          "review": {
            "enum": [
              "pending",
              "accepted",
              "changes_requested"
            ]
          },
          "feedback": {
            "type": "string"
          }
        },
        "required": [
          "manifest",
          "review",
          "feedback"
        ],
        "additionalProperties": false
      },
      "Enrollment": {
        "type": "object",
        "properties": {
          "externalApplicationId": {
            "type": "string",
            "format": "uuid"
          },
          "applicationCategoryCode": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          },
          "applicationChannelCode": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          },
          "applicationChannelName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "subject": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "contact": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "required": [
              "name",
              "contact"
            ],
            "additionalProperties": false
          },
          "submission": {
            "$ref": "#/components/schemas/Submission"
          }
        },
        "required": [
          "externalApplicationId",
          "applicationCategoryCode",
          "applicationChannelCode",
          "subject",
          "submission"
        ],
        "additionalProperties": false
      },
      "EnrollmentState": {
        "type": "object",
        "properties": {
          "externalApplicationId": {
            "type": "string",
            "format": "uuid"
          },
          "applicationCategoryCode": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,63}$"
          },
          "applicationCategoryLabel": {
            "type": "string"
          },
          "enrollmentStatus": {
            "enum": [
              "pending",
              "accepted",
              "rejected"
            ]
          },
          "enrollmentRevision": {
            "type": "integer",
            "minimum": 1
          },
          "integratedApplicationId": {
            "type": "string",
            "format": "uuid"
          },
          "sdkPath": {
            "type": "string"
          },
          "feedback": {
            "type": "string"
          }
        },
        "required": [
          "externalApplicationId",
          "applicationCategoryCode",
          "enrollmentStatus",
          "enrollmentRevision",
          "feedback"
        ]
      }
    }
  }
}
