退货 API
Last updated
开启退货附加功能后,ChannelDock REST API v2 会为每笔退货提供更多信息,并新增一个用于执行操作的端点。您现有的集成照常运作:所有现有字段保持不变,新数据添加在额外的键中。本文面向开发人员。有关身份验证和 API 密钥,请参阅 ChannelDock REST API 文档。
步骤
- 在 设置 → API 和 Webhook 下创建 API 密钥。在 退货 端点上允许您需要的方法:
GET用于读取,POST用于发送操作。操作端点遵循退货端点的权限。 - 每个请求都使用 HTTP Basic 身份验证(API 密钥作为用户名,API 密钥密码作为密码)发送,或使用请求头
Api-Key和Api-Secret。 POST请求使用 JSON 请求体并设置Content-Type: application/json。- 使用
GET /portal/api/v2/seller/returns读取退货。现在每笔退货和每个退货行都有一个platform对象。 - 将操作发送到
POST /portal/api/v2/seller/returns/actions,并带上action字段。
平台字段
GET /portal/api/v2/seller/returns 会为每笔退货添加一个 platform 对象:
"platform": {
"return_number": "RE-2026-0418",
"public_code": "K7M2Q9XA",
"state": "return-processing",
"source": "portal",
"form_id": 10,
"return_status_id": 3,
"tags": ["Frequent returner"],
"shipping_fee": 4.95,
"free_return": false,
"resolved_at": null,
"resolutions": [
{"id": 12, "type": "refund", "status": "done", "channel": "shopify", "currency": "EUR", "amount_incl": 74.95, "amount_excl": 61.94, "reference": "gid://shopify/Refund/1", "created_at": "2026-11-28 15:10:00", "completed_at": "2026-11-28 15:10:04"}
],
"customer": {"name": "Sanne de Vries", "email": "[email protected]", "phone": "", "language": "nl"}
}
state:request-pending、withdrawal-request-pending、return-announced、return-shipped、return-processing、return-resolved、return-cancelled、return-expired或imported(平台启用之前的退货或来自平台市场的退货)。resolutions:每笔退款、余额及其他结算。type为refund、manual_refund、external_refund、credit、coupon、gift_card、exchange、repair、replace或goodwill。status为pending、processing、done、failed或cancelled。
每个退货行都有自己的 platform 对象:
"platform": {"quantity_received": 1, "grade": "A", "disposition": "restock", "resolution_type": "refund", "unit_price_paid": 74.95, "vat_rate": 21, "reason_code": "size_too_small"}
grade:A、B、C或defect。disposition:restock、b_stock、supplier、refurbish或scrap。
操作
GET /portal/api/v2/seller/returns/actions 列出等待决定的申请,返回 counts 和 requests。添加 tab = all、held 或 withdrawal 可进行筛选。
POST /portal/api/v2/seller/returns/actions 接受以下操作之一:
action |
字段 | 作用 |
|---|---|---|
note |
return_id、text,可选 public |
添加备注。public: true 会在状态页上向客户显示。 |
tag / untag |
return_id、tag |
按名称添加或移除标签。标签不存在时,tag 会创建该标签。 |
decide |
request_id、decision |
approve、keep(客户保留商品)、reject、cancel_order 或 too_late。后两个用于撤回;撤回不能被拒绝。cancel_order 接受 cancel_at_channel(默认 false)。 |
status |
return_id、status |
按 ID 或名称设置您自己的某个退货状态。 |
receive |
return_product_id、received,可选 grade、disposition |
记录收到多少件以及如何分级。 |
resolve |
return_id、key、items,可选 adjustment、refund_shipping、notify |
结算退货。见下文。 |
lookup |
form_id、order_number,可选 language |
显示客户通过某个退货表单可以退回订单中的哪些商品。 |
create_return |
form_id、order_number、items、customer,可选 shipping_method_id、answers、files、language |
像客户一样通过退货表单创建退货。 |
return_link |
order_number |
返回一个已签名的链接,可在商品步骤打开该订单的退货表单。 |
示例:添加一条内部备注。
POST /portal/api/v2/seller/returns/actions
{"action": "note", "return_id": 12345, "text": "Box was damaged on arrival."}
结算退货
resolve 遵循与 ChannelDock 中处理页面相同的规则:退款金额绝不能超过仍可退款的金额,并且只有在开启实时退款时,退款才会发送到销售渠道。key 为必填项:8 到 48 个字母、数字、- 或 _,每次结算唯一。如果再次发送相同的 key,退货只会结算一次。items 是 {return_product_id, type, quantity} 的列表,type 为 refund、coupon 或 exchange(视退货提供的选项而定)。refund_shipping 和 notify 默认为 true。响应包含 entries、resolved 和金额汇总 summary。
从您自己的网店退货(无头模式)
使用 lookup 和 create_return,可以在您自己的网店或应用中构建退货流程,而不使用退货门户。
- 使用表单和订单号调用
lookup。响应包含status(found、not_found、marketplace、unshipped或all_returned),找到时还包含可退货的lines、reasons、表单提供的resolutions以及questions。 - 调用
create_return,带上items([{order_product_id, quantity, reason_id, resolution, exchange_for?}])和customer({name, email, phone?, street?, postcode?, city?, country?})。答案以answers({question_id: value})发送,照片以files([{question_id, filename, content_base64}],最多 10 个;JPG、PNG、HEIC、WebP、MP4、MOV 或 PDF)发送。
POST /portal/api/v2/seller/returns/actions
{"action": "create_return", "form_id": 10, "order_number": "1001", "items": [{"order_product_id": 5512, "quantity": 1, "reason_id": 3, "resolution": "refund"}], "customer": {"name": "Sam Jansen", "email": "[email protected]"}}
表单的规则与门户中完全一样地运行:申请、保留商品、费用、标签、测试模式和客户邮件。响应包含 request_id、status(approved、pending、rejected 或 test)、return_id(尚未创建退货时为 0)以及供客户使用的 status_url。缺少必填答案或照片时会被拒绝,并附有指明该问题的消息。
须知
- 操作端点只在开启退货附加功能时可用,否则返回 HTTP 403。
- 被拒绝的操作返回 HTTP 400,并附有说明原因的
message。 - 当您的 API 关闭了个人数据时,
platform对象中不包含customer。如需更改此设置,请联系支持团队。 - 履约中心通过
GET /portal/api/v2/center/returns获取已开通附加功能的关联卖家的platform对象,但不含客户信息。它们使用GET和POST /portal/api/v2/center/returns/actions,可执行note、receive和decide(approve、keep或reject,仅限卖家允许履约中心决定的情况)操作。申请列表会为每个申请显示fc_can_decide。 - 如需接收变更通知而不是轮询,请使用 退货 Webhook。
相关文章
Was this helpful?