# 代发预配：逐条给出能不能配齐、缺多少、预售几时到货、要付多少

`POST /api/v1/dropship-orders/allocation-preview` — 需要 token · df:write · 写操作 · 2 点

代发订单

代发预配：逐条给出能不能配齐、缺多少、预售几时到货、要付多少。⚠️ 预配会占住库存——看完要么提交，要么调 DELETE …/{dropship_order_id}/allocation 释放

## 请求体（JSON）

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `warehouse_code` **必填** | string | 仓库编码：AU（澳洲（全部仓合计），合计视图）、AUSYD2（悉尼主仓（Rosehill））、AUSYD1（悉尼配件仓）、CN（中国（全部仓合计），合计视图）、CHNZJ1（中国镇江仓）。AU / CN 是公司级合计视图，其余是真实仓；完整清单看 GET /api/v1/warehouses。 |
| `dropship_order_ids` **必填** | array<string> | 代发流水号数组（建代发时返回的 serial_number）。一次最多 200 条。 (1–200) |
| `use_reservation` | boolean | 是否动用你的锁单（预留库存）来配这批货。不传 = 不动用。 |

## 响应

响应信封只看 HTTP 状态码：成功是 2xx，正文 `{ data: … }`（列表另带 `page / page_size / has_more` 或 `total_count`）；失败是 4xx / 5xx，正文 `{ error: { code, message, hint, request_id, doc_url } }`。

```json
{
  "data": { … }
}
```

成功响应里没有任何给人看的文字——没有 `code / result / msg`。`error.code` 是唯一该用程序判断的字段，`message` 跟随 `Accept-Language`。

> 写操作请带 `Idempotency-Key` 头（任意唯一串，如 UUID）：网络重试不会重复下单。下单默认只建草稿，由人在 ERP 确认后生效。

## 示例

### curl

```bash
curl -X POST "https://connect.everugg.net.au/api/v1/dropship-orders/allocation-preview" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <uuid>" \
  -d '{ "warehouse_code": "AU", "dropship_order_ids": [ "<dropship_order_id>" ] }'
```

### Python

```python
import requests

r = requests.post(
    "https://connect.everugg.net.au/api/v1/dropship-orders/allocation-preview",
    headers={"Authorization": "Bearer " + TOKEN, "Idempotency-Key": str(uuid.uuid4())},
    json={
      "warehouse_code": "AU",
      "dropship_order_ids": [
        "<dropship_order_id>"
      ]
    },
)
data = r.json()
r.raise_for_status()  # 4xx/5xx: data["error"]["code"] / ["hint"]
```

### Node

```js
const res = await fetch("https://connect.everugg.net.au/api/v1/dropship-orders/allocation-preview", {
  method: "POST",
  headers: { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({
    "warehouse_code": "AU",
    "dropship_order_ids": [
      "<dropship_order_id>"
    ]
  }),
})
const data = await res.json()
if (!res.ok) throw new Error(`${data.error?.code}: ${data.error?.message}`)
```

### Java

```java
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://connect.everugg.net.au/api/v1/dropship-orders/allocation-preview"))
    .header("Authorization", "Bearer " + token)
    .header("Content-Type", "application/json")
    .header("Idempotency-Key", UUID.randomUUID().toString())
    .POST(HttpRequest.BodyPublishers.ofString("{ \"warehouse_code\": \"AU\", \"dropship_order_ids\": [ \"<dropship_order_id>\" ] }"))
    .build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
```

---
Markdown 源: https://connect.everugg.net.au/reference/post-api-v1-dropship-orders-allocation-preview.md?lang=zh · 网页版: https://connect.everugg.net.au/reference?op=post-api-v1-dropship-orders-allocation-preview&lang=zh
