Cancel an order
取消一个普通订单,或按顺序处理账户所属最多 100 个 ID 的批次。每个普通 API 订单仅在其自身提交前 15 秒的宽限窗口内符合取消条件。
POST
https://notpanel.com/api/v3action=cancel需要 API key受速率限制(共享账户 + IP + action)请求体:
application/x-www-form-urlencoded提供一个数字
order ID,或最多 100 个以逗号分隔的 orders ID。批量模式绝不会延长订单的取消窗口。参数
| 名称 | 类型 | 描述 |
|---|---|---|
| key必需 | string | 你的 API key。 |
| action必需 | string | 必须是字面字符串 “cancel”。 |
| order视情况 | string | 由 action=add 返回的、账户所属一个普通订单的数字 ID。 |
| orders视情况 | string (CSV) | 以逗号分隔的普通订单 ID,最多 100 个。响应保留输入顺序,并逐项返回成功或错误。 |
请求示例
将 YOUR_API_KEY 替换为在你仪表盘 API 页面下生成的 key。
curl -X POST https://notpanel.com/api/v3 \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "key=YOUR_API_KEY&action=cancel&order=7001"const res = await fetch("https://notpanel.com/api/v3", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
key: "YOUR_API_KEY",
action: "cancel",
order: "7001",
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://notpanel.com/api/v3",
data={
"key": "YOUR_API_KEY",
"action": "cancel",
"order": "7001",
},
)
print(res.json())<?php
$body = http_build_query([
'key' => 'YOUR_API_KEY',
'action' => 'cancel',
'order' => '7001',
]);
$response = file_get_contents('https://notpanel.com/api/v3', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => $body,
'ignore_errors' => true,
],
]));
print_r(json_decode($response, true));
响应示例
{
"order": 7001,
"status": "Canceled",
"status_key": "cancelled",
"cancel": 1,
"refund": "0.50",
"refund_pending": 0
}常见错误
| 状态 | 响应体 | 原因 |
|---|---|---|
| 409 | {"error":"Cancellation window has ended or the order has already started"} | 普通订单已离开 15 秒取消窗口,或不再处于 pending。单个请求返回 409。 |
| 409 | {"error":"Order is already completed"} | 该项目已处于不可取消的终态。若重试此前成功的取消,则返回相同的成功结果。 |
| 409 | {"error":"Order is already refunded"} | 该项目已处于不可取消的终态。若重试此前成功的取消,则返回相同的成功结果。 |
| 404 | {"error":"Order not found"} | 此账户没有该标识符对应的普通订单。单个请求返回 404。 |
| 429 | {"error":"Rate limit exceeded for cancel"} | 已达到取消 action 限制。请在报告的延迟后重试;响应为 429。 |