按 SKU 创建 Resend
Enterprise-only. Creates a resend by supplying warehouse-scoped SKU quantities instead of explicit return inventory IDs. The service selects eligible pending return inventory records itself (LIFO by default), then reuses the standard create-resend workflow. The whole request is processed atomically — either every requested unit is allocated and one resend is created, or nothing is.
何时使用本接口,而非 Create resend order
- 当您以 SKU 与数量追踪库存、且不想管理单个
returnInventoryId值时,使用按 SKU 创建 Resend。 - 当您已持有想补寄的特定
returnInventoryId值(例如从newInventoryCreatedwebhook 缓存而来)时,使用 Create resend order。
前置条件
- 您的账户已启用 SKU 库存模块(Enterprise)。
- 该仓库中每个请求的 SKU 都有足够、符合补寄资格的库存。请先以 搜索 SKU 库存(
availableQuantity)确认汇总量,但请注意通过汇总检查并非保证——见下文。 shipmentServiceType是 Shipment Service Type(不是 Return Service Type)。有效代码请见 获取 Warehouse 可用的 Shipment Service Types。
挑选机制
分配分三个阶段,且只有最后一个阶段具权威性:- 验证。 您的请求行会被规范化(SKU trim + 转大写),重复的 SKU 会被合并。验证会依
warehouseId+ 规范化后 SKU 检查availableQuantity。通过此检查仅代表汇总量看起来足够——不会预留或分配任何东西。 - 挑选。 系统查询符合您
warehouseId与规范化 SKU 且具补寄资格的实际退件库存记录,再依挑货策略恰好挑出所请求的数量。若符合资格的记录少于请求量,整笔请求会被拒绝。 - 分配。 在事务内,将被挑选的行加锁并重新检查;若有任何一行不再符合资格,事务回滚且请求失败。否则所有被挑选的记录会被推进至 resend / in-progress,并在同一事务内创建补寄。
资格规则
退件库存记录唯有在符合以下条件时才可被挑选:- 符合请求的
warehouseId与规范化后 SKU; handlingStatusCode= pending;- 可转换至 resend / in-progress;且
- 无待处理 VAS,包含任何未完成的 VAS Split。
availableQuantity(后者仍可能计入带待处理 VAS 的记录)。当发生此情况时,请求会以 fail-closed 方式失败,而非补寄不符资格的项目。
挑货策略
挑选默认采用 LIFO:最新createOn 优先,并以最大的退件库存 ID 作为决胜依据。此策略置于工厂(factory)之后,未来可切换为 FIFO 而无需更动分配逻辑。
错误与重试
- 验证失败会以 HTTP 200 搭配
meta.status: 400返回(标准的软错误封套——见错误处理)。 - 当某个 SKU 可用量不足时,会整笔拒绝请求。基于安全考量,错误不会披露剩余可用量。
- 当并发请求争用相同库存时,未能锁定记录的请求会被拒绝,并可重试。
相关
- 搜索 SKU 库存 — 在请求前确认
availableQuantity。 - Create resend order — 以明确的退件库存 ID 补寄;亦涵盖面单生成(自动 vs 手动服务类型)与取消截止时间,这些同样适用于此处创建的补寄。
- 取消补寄订单 — 在仓库发货前中止。
- Webhooks — resend-status-update 事件会将生命周期变更推送至您的端点。
授权
Your API key
Your API token — keep this private
请求体
Create a resend by warehouse-scoped SKU quantities. companyName is not part of this request.
Warehouse to fulfil the resend from. Must be greater than 0 and owned by the authenticated account. All selected inventory comes from this single warehouse.
Shipment service type code (not a return service type). Non-others values are validated against the available shipment service and service zone for the warehouse and destination.
Non-empty list of SKU + quantity lines. The number of raw lines is limited to 100; the combined quantity across all lines is limited to 100.
Destination address for the resend shipment.
Optional seller reference number. When provided, 1-50 characters with no invisible characters. Stored on the created resend shipment and echoed back in the response.
50Optional free-text description for the resend order.
Optional free-text merchant remarks for the resend order.
Optional free-text remarks addressed to the warehouse.
响应
Success
Wraps CreateResendBySkuReply under data, alongside the standard correlationId and meta envelope.
Create resend by SKU result.