{
  "openapi": "3.1.0",
  "info": {
    "title": "RootFlow ERP Open API",
    "version": "1.0.0",
    "description": "面向第三方 ERP 的订单预报与仓库履约接口。\n\n**鉴权**：点击 **Authorize** 输入平台签发的 SK，请求会自动携带 `Authorization: Bearer <SK>`。每个接口标有所需权限。SK 用于调用 RootFlow，授权店铺时填写该店铺的 Ozon API Key。\n\n**接入顺序**：创建业务用户 → 批量绑定店铺并核对订阅状态 → 查询仓库与已同步订单 → 提交预报 → 查询任务进度与仓库回执。走库存发货时，先完成 SKU 选仓、创建库存卡及实物入库。\n\n**当前试点**：查询接口可用。业务写入暂停，持有写权限的调用方会收到 `503 WRITES_PAUSED`。示例中的用户、店铺、订单和服务代码为演示值，请用实际查询结果替换。\n\n**分页和重试**：列表默认每页 50 条，最多 100 条。将响应中的 `nextAfterId` 作为下一页的 `afterId`。批量绑店、建卡、入库和预报需要 `Idempotency-Key`。超时后重试时保留原键和原请求内容。同键换内容会返回 `409`。\n\n**错误排查**：响应包含 `code`、`message`、`data` 和 `requestId`。常见状态为 `401` 密钥无效、`403` 权限不足、`404` 资源不存在或不可见、`402` 余额不足、`409` 业务或幂等冲突、`422` 参数错误和 `429` 限流。联系技术支持时提供 `requestId`。"
  },
  "servers": [
    {
      "url": "/api/open/v1"
    }
  ],
  "security": [
    {
      "SecretKey": []
    }
  ],
  "paths": {
    "/users": {
      "post": {
        "operationId": "create_user",
        "summary": "创建或找回业务用户",
        "x-rootflow-scope": "users:write",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalUserId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z0-9._:-]+$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "externalUserId",
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "externalUserId": "seller-demo-001",
                "name": "示例卖家"
              }
            }
          }
        },
        "description": "传入调用方系统内稳定的 `externalUserId` 和展示名 `name`。首次创建返回 `201`，重复使用同一编号返回原用户和 `200`。保存返回的 `userId`，用于后续店铺、仓库、库存和订单接口。\n\n所需权限 `users:write`。"
      }
    },
    "/users/{userId}/shops/batch": {
      "post": {
        "operationId": "batch_shops",
        "summary": "批量绑定 Ozon 店铺",
        "x-rootflow-scope": "shops:write",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Batch"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "调用方生成的唯一请求键。同一请求重试使用同一个键。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shops": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ShopInput"
                    },
                    "minItems": 1,
                    "maxItems": 50
                  }
                },
                "required": [
                  "shops"
                ],
                "additionalProperties": false
              },
              "example": {
                "shops": [
                  {
                    "externalShopId": "shop-demo-001",
                    "name": "示例店铺",
                    "clientId": "123456",
                    "apiKey": "<该店铺的 Ozon API Key>"
                  }
                ]
              }
            }
          }
        },
        "description": "每批 1–50 家。每项填写 `externalShopId`、`name`、数字字符串 `clientId` 和该店铺的 Ozon `apiKey`。HTTP `200` 后逐项检查 `data.items` 的 `status`；存在 `retryable: true` 的条目时可按原请求重试。订单通知异步订阅，通过店铺列表确认。\n\n所需权限 `shops:write`。"
      }
    },
    "/users/{userId}/shops": {
      "get": {
        "operationId": "list_shops",
        "summary": "查询店铺及订单通知状态",
        "x-rootflow-scope": "shops:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ShopPage"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "afterId",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "下一页使用上一次返回的 nextAfterId，首请求可省略。"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "每页记录数，默认 50，最大 100。"
          }
        ],
        "description": "返回店铺 `shopId`、启用状态及 `notification.status`。状态 `verified` 或 `repaired` 表示已从 Ozon 读回确认。下一页传 `afterId=nextAfterId`，结果为 `null` 时已到末页。\n\n所需权限 `shops:read`。"
      }
    },
    "/users/{userId}/warehouses": {
      "get": {
        "operationId": "list_warehouses",
        "summary": "查询可用仓库与物流服务",
        "x-rootflow-scope": "warehouses:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Warehouses"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          }
        ],
        "description": "返回该用户可用的 `warehouseId`、仓库名称和 `services[]`。提交订单预报时，使用对应服务的 `services[].code` 作为 `serviceCode`。上海试点仓编号为 `2367`。\n\n所需权限 `warehouses:read`。"
      }
    },
    "/users/{userId}/sku-warehouses/{sku}": {
      "put": {
        "operationId": "assign_warehouse",
        "summary": "设置 SKU 的履约仓",
        "x-rootflow-scope": "warehouses:write",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SkuWarehouse"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "sku",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[1-9][0-9]*$"
            },
            "description": "Ozon SKU，使用数字字符串。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "warehouseId": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  }
                },
                "required": [
                  "warehouseId"
                ],
                "additionalProperties": false
              },
              "example": {
                "warehouseId": 2367
              }
            }
          }
        },
        "description": "路径中的 `sku` 为 Ozon SKU，使用数字字符串。请求体填写仓库查询返回的 `warehouseId`。已冻结履约仓的订单继续走原仓。\n\n所需权限 `warehouses:write`。"
      }
    },
    "/users/{userId}/inventory/cards": {
      "post": {
        "operationId": "create_card",
        "summary": "创建库存卡",
        "x-rootflow-scope": "inventory:write",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CardCreated"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "调用方生成的唯一请求键。同一请求重试使用同一个键。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "warehouseId": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  "sku": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "pattern": "^[1-9][0-9]*$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  }
                },
                "required": [
                  "warehouseId",
                  "sku",
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "warehouseId": 2367,
                "sku": "123456789",
                "name": "示例商品"
              }
            }
          }
        },
        "description": "（库存发货）填写 `warehouseId`、Ozon `sku` 和卡片 `name`。返回 `cardId`。新卡实存为零，随后提交入库预报，由仓库确认收货。\n\n所需权限 `inventory:write`。"
      }
    },
    "/users/{userId}/inventory/cards/{cardId}": {
      "get": {
        "operationId": "get_card",
        "summary": "查询库存卡数量",
        "x-rootflow-scope": "inventory:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Card"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "cardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "创建库存卡返回的 ID。"
          }
        ],
        "description": "带上建卡返回的 `cardId`。响应中的 `quantity` 为实存，`availableQuantity` 为可用数量。\n\n所需权限 `inventory:read`。"
      }
    },
    "/users/{userId}/inventory/cards/{cardId}/inbounds": {
      "post": {
        "operationId": "create_inbound",
        "summary": "提交库存卡入库预报",
        "x-rootflow-scope": "inventory:write",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/InboundCreated"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "cardId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "创建库存卡返回的 ID。"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "调用方生成的唯一请求键。同一请求重试使用同一个键。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "trackingNumber": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[A-Za-z0-9%_.-]{8,100}$"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 999999
                  }
                },
                "required": [
                  "trackingNumber",
                  "quantity"
                ],
                "additionalProperties": false
              },
              "example": {
                "trackingNumber": "SF1234567890",
                "quantity": 10
              }
            }
          }
        },
        "description": "填写国内快递 `trackingNumber` 和申请入库的实物件数 `quantity`（1–999999 的整数）。返回 `inboundId`、申请单号和状态。实存按仓库确认收货的数量更新。\n\n所需权限 `inventory:write`。"
      }
    },
    "/users/{userId}/inventory/inbounds/{inboundId}": {
      "get": {
        "operationId": "get_inbound",
        "summary": "查询入库审核与实收",
        "x-rootflow-scope": "inventory:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Inbound"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "inboundId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "提交入库预报返回的 ID。"
          }
        ],
        "description": "带上提交时返回的 `inboundId`。用 `quantity` 读取申请数量，用 `receivedQuantity` 读取实收数量。尚未确认实收时该字段可能为空。\n\n所需权限 `inventory:read`。"
      }
    },
    "/users/{userId}/orders": {
      "get": {
        "operationId": "list_orders",
        "summary": "查询已同步的 Ozon 订单",
        "x-rootflow-scope": "orders:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderPage"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "afterId",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "下一页使用上一次返回的 nextAfterId，首请求可省略。"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "每页记录数，默认 50，最大 100。"
          },
          {
            "name": "shopId",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "RootFlow 店铺 ID，由绑店或店铺列表返回。"
          }
        ],
        "description": "可按 RootFlow 的 `shopId` 过滤。列表提供 `postingNumber`、状态、SKU 和件数。提交预报时使用同一条订单的 `shopId` 和 `postingNumber`。支持游标分页。\n\n所需权限 `orders:read`。"
      }
    },
    "/users/{userId}/forecasts": {
      "post": {
        "operationId": "create_forecast",
        "summary": "提交订单预报",
        "x-rootflow-scope": "forecasts:write",
        "responses": {
          "202": {
            "description": "Operation accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ForecastCreated"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "调用方生成的唯一请求键。同一请求重试使用同一个键。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shopId": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  "postingNumber": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z0-9._:-]+$"
                  },
                  "mode": {
                    "enum": [
                      "courier",
                      "inventory"
                    ]
                  },
                  "serviceCode": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128,
                    "pattern": "^[A-Za-z0-9._:-]+$"
                  },
                  "warehouseId": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  "trackingNumber": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[A-Za-z0-9%_.-]{8,100}$"
                  }
                },
                "required": [
                  "shopId",
                  "postingNumber",
                  "mode",
                  "serviceCode"
                ],
                "additionalProperties": false,
                "if": {
                  "properties": {
                    "mode": {
                      "const": "courier"
                    }
                  }
                },
                "then": {
                  "required": [
                    "trackingNumber"
                  ]
                },
                "else": {
                  "not": {
                    "required": [
                      "trackingNumber"
                    ]
                  }
                }
              },
              "examples": {
                "courier": {
                  "summary": "快递到仓",
                  "value": {
                    "shopId": 123,
                    "postingNumber": "123456789-0001-1",
                    "mode": "courier",
                    "serviceCode": "DEMO_SERVICE",
                    "trackingNumber": "SF1234567890",
                    "warehouseId": 2367
                  }
                },
                "inventory": {
                  "summary": "库存发货",
                  "value": {
                    "shopId": 123,
                    "postingNumber": "123456789-0001-1",
                    "mode": "inventory",
                    "serviceCode": "DEMO_STOCK_SERVICE"
                  }
                }
              }
            }
          }
        },
        "description": "必填 `shopId`、`postingNumber`、`mode`、`serviceCode`。`courier` 为快递到仓，必填国内运单号 `trackingNumber`。`inventory` 为库存发货，件数按已同步订单计算，请省略 `trackingNumber`。可选的 `warehouseId` 须与系统确定的履约仓一致。返回 `202` 和 `forecastId` 表示已入队，请继续查询任务进度。\n\n所需权限 `forecasts:write`。"
      }
    },
    "/users/{userId}/forecasts/{forecastId}": {
      "get": {
        "operationId": "get_forecast",
        "summary": "查询预报任务进度",
        "x-rootflow-scope": "orders:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Forecast"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "forecastId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "提交订单预报返回的任务 ID。"
          }
        ],
        "description": "填写提交时返回的 `forecastId`。查看 `status`、`forecasted`、`failed` 和 `completedAt`。仓库实物作业结果通过订单物流回执查询。\n\n所需权限 `orders:read`。"
      }
    },
    "/users/{userId}/orders/{shopId}/{postingNumber}/receipt": {
      "get": {
        "operationId": "get_receipt",
        "summary": "查询订单物流回执",
        "x-rootflow-scope": "orders:read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Receipt"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request or dependency error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "ERP 业务用户 ID，由创建用户接口返回。"
          },
          {
            "name": "shopId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "description": "RootFlow 店铺 ID，由绑店或店铺列表返回。"
          },
          {
            "name": "postingNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "已同步订单中的 Ozon 货件号。"
          }
        ],
        "description": "填写订单所属的 `shopId` 和 Ozon `postingNumber`。返回签收 `signedAt`、出库 `outboundAt`、实测克重 `weightGrams`、称重时间 `weighedAt` 和分阶段照片 `photos`。尚无对应证据时字段为空或返回空数组。照片链接为短时授权链接。\n\n所需权限 `orders:read`。"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SecretKey": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "externalUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "required": [
          "userId",
          "externalUserId",
          "name"
        ],
        "additionalProperties": false
      },
      "ShopInput": {
        "type": "object",
        "properties": {
          "externalShopId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "clientId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[0-9]+$"
          },
          "apiKey": {
            "type": "string",
            "maxLength": 512,
            "writeOnly": true
          }
        },
        "required": [
          "externalShopId",
          "name",
          "clientId",
          "apiKey"
        ],
        "additionalProperties": false
      },
      "Shop": {
        "type": "object",
        "properties": {
          "shopId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "externalShopId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "clientId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "enabled": {
            "type": "boolean"
          },
          "notification": {
            "type": "object",
            "properties": {
              "status": {
                "enum": [
                  "pending",
                  "verified",
                  "repaired",
                  "authorization_failed",
                  "retry"
                ]
              },
              "upstreamStatus": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2147483647
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "status",
              "upstreamStatus"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "shopId",
          "externalShopId",
          "clientId",
          "name",
          "enabled",
          "notification"
        ],
        "additionalProperties": false
      },
      "Batch": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalShopId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[A-Za-z0-9._:-]+$"
                },
                "status": {
                  "enum": [
                    "bound",
                    "failed"
                  ]
                },
                "shopId": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 2147483647
                },
                "code": {
                  "type": "string"
                },
                "retryable": {
                  "type": "boolean"
                }
              },
              "required": [
                "externalShopId",
                "status"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "ShopPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Shop"
            }
          },
          "nextAfterId": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 2147483647
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "nextAfterId"
        ],
        "additionalProperties": false
      },
      "Warehouses": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "warehouseId": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 2147483647
                },
                "name": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 255
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "services": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 128,
                        "pattern": "^[A-Za-z0-9._:-]+$"
                      },
                      "name": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "code",
                      "name"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "warehouseId",
                "name",
                "services"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "items"
        ],
        "additionalProperties": false
      },
      "SkuWarehouse": {
        "type": "object",
        "properties": {
          "sku": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[1-9][0-9]*$"
          },
          "warehouseId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          }
        },
        "required": [
          "sku",
          "warehouseId"
        ],
        "additionalProperties": false
      },
      "CardCreated": {
        "type": "object",
        "properties": {
          "cardId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "warehouseId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "sku": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[1-9][0-9]*$"
          }
        },
        "required": [
          "cardId",
          "warehouseId",
          "sku"
        ],
        "additionalProperties": false
      },
      "Card": {
        "type": "object",
        "properties": {
          "cardId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "warehouseId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "name": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ]
          },
          "quantity": {
            "type": "integer"
          },
          "availableQuantity": {
            "type": "integer"
          }
        },
        "required": [
          "cardId",
          "warehouseId",
          "name",
          "quantity",
          "availableQuantity"
        ],
        "additionalProperties": false
      },
      "InboundCreated": {
        "type": "object",
        "properties": {
          "inboundId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "requestNo": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "cardId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "warehouseId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "inboundId",
          "requestNo",
          "cardId",
          "warehouseId",
          "quantity",
          "status"
        ],
        "additionalProperties": false
      },
      "Inbound": {
        "type": "object",
        "properties": {
          "inboundId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "requestNo": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "cardId": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 2147483647
              },
              {
                "type": "null"
              }
            ]
          },
          "warehouseId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999
          },
          "status": {
            "type": "string"
          },
          "receivedQuantity": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0
              },
              {
                "type": "null"
              }
            ]
          },
          "reviewNote": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "reviewedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "inboundId",
          "requestNo",
          "cardId",
          "warehouseId",
          "quantity",
          "status",
          "receivedQuantity",
          "reviewNote",
          "reviewedAt"
        ],
        "additionalProperties": false
      },
      "OrderPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 2147483647
                },
                "shopId": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 2147483647
                },
                "postingNumber": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[A-Za-z0-9._:-]+$"
                },
                "status": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "createdAt": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "products": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "sku": {
                        "type": "string"
                      },
                      "quantity": {
                        "anyOf": [
                          {
                            "type": "integer"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "sku",
                      "quantity"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "orderId",
                "shopId",
                "postingNumber",
                "status",
                "createdAt",
                "products"
              ],
              "additionalProperties": false
            }
          },
          "nextAfterId": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 2147483647
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "nextAfterId"
        ],
        "additionalProperties": false
      },
      "ForecastCreated": {
        "type": "object",
        "properties": {
          "forecastId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "status": {
            "const": "queued"
          }
        },
        "required": [
          "forecastId",
          "status"
        ],
        "additionalProperties": false
      },
      "Forecast": {
        "type": "object",
        "properties": {
          "forecastId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "status": {
            "type": "string"
          },
          "forecasted": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "createdAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "forecastId",
          "status",
          "forecasted",
          "failed",
          "createdAt",
          "completedAt"
        ],
        "additionalProperties": false
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "shopId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "postingNumber": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "signedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "outboundAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "weightGrams": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 2147483647
              },
              {
                "type": "null"
              }
            ]
          },
          "weighedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "stage": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "required": [
                "stage",
                "url"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "shopId",
          "postingNumber",
          "status",
          "signedAt",
          "outboundAt",
          "weightGrams",
          "weighedAt",
          "photos"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "data": {
            "type": "null"
          }
        },
        "required": [
          "code",
          "message",
          "requestId",
          "data"
        ],
        "additionalProperties": false
      }
    }
  }
}
