Z Zise Developers

新增邮寄地址

POST /v1/shipping-addresses scope: addresses:write
代会员调用 · 必带 x-on-behalf-of x-idempotency-key

第一条自动成为默认,不用再调一次设默认。要新增并直接设为默认,传 is_default: true

── 必填与选填 ──必填:country(ISO 3166-1 alpha-2,两位大写)· 收件人姓名(recipient_last / recipient_first 至少有一个)· phone_code · phone_number · line1 · city · postal_code。选填:label · province · district · line2

province / district 选填是刻意的 —— 不是每个国家都有省级行政区(新加坡、摩纳哥…),做成必填只会逼出假数据。

⚠ 姓与名只要有一个就行:不是每种文化都把名字拆成两截。

postal_code 是必填。已知代价:香港、澳门、阿联酋等地没有邮政编码,那里的用户通常填 000000

phone_code不带 + 的纯数字phone_number 只留数字 ——你传 +852 / 5123-4567 我方会自己清洗,读回来是清洗后的形态。

⚠ 字段长度上限刻意放宽(姓名 40 / 地址行 120 …),比多数发卡机构的限制松。真正的校验在开卡下单那一步按目的国和承运商各自认定 ——在录入这一步按猜测收紧,只会把本来能寄的地址挡在门外。

每人最多 20 条,撞上限回 limit_exceeded

字段类型必填说明
x-idempotency-key string 必填
x-on-behalf-of string 必填

请求体

这个 operation 还没有在 spec 里声明请求体字段。

响应

201已创建
400invalid_fields —— 响应里的 fields[].key 点名是哪一个字段country / recipient_last / phone_code / phone_number / line1 / city / postal_code),据此把用户送回出错的那一步 · limit_exceeded 已有 20 条 · idempotency_key_required · member_context_required
请求
curl -X POST 'https://api.zise.com/v1/shipping-addresses' \
  -H 'x-auth-token: Bearer $TOKEN' \
  -H 'x-on-behalf-of: $MEMBER_ID' \
  -H 'x-idempotency-key: $IDEMPOTENCY_KEY' \
  -H 'content-type: application/json' \
  -d '{
    "label": "家",
    "country": "HK",
    "recipient_last": "陈",
    "recipient_first": "小明",
    "phone_code": "852",
    "phone_number": "51234567",
    "city": "香港",
    "district": "中西区",
    "line1": "干诺道中 200 号",
    "postal_code": "000000",
    "is_default": true
  }'
const res = await fetch("https://api.zise.com/v1/shipping-addresses", {
  method: "POST",
  headers: {
    "x-auth-token": "Bearer $TOKEN",
    "x-on-behalf-of": "$MEMBER_ID",
    "x-idempotency-key": "$IDEMPOTENCY_KEY",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "label": "家",
    "country": "HK",
    "recipient_last": "陈",
    "recipient_first": "小明",
    "phone_code": "852",
    "phone_number": "51234567",
    "city": "香港",
    "district": "中西区",
    "line1": "干诺道中 200 号",
    "postal_code": "000000",
    "is_default": true
  }),
});
// 金额按字符串读,别让它变成 number
const data = await res.json();
import requests

res = requests.post(
    "https://api.zise.com/v1/shipping-addresses",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "x-idempotency-key": "$IDEMPOTENCY_KEY",
        "content-type": "application/json",
    },
    json={
      "label": "家",
      "country": "HK",
      "recipient_last": "陈",
      "recipient_first": "小明",
      "phone_code": "852",
      "phone_number": "51234567",
      "city": "香港",
      "district": "中西区",
      "line1": "干诺道中 200 号",
      "postal_code": "000000",
      "is_default": true
    },
)
# 金额用 Decimal(str(...)),不要 float
data = res.json()
req, _ := http.NewRequest("POST", "https://api.zise.com/v1/shipping-addresses",
    strings.NewReader(`{
  "label": "家",
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "district": "中西区",
  "line1": "干诺道中 200 号",
  "postal_code": "000000",
  "is_default": true
}`))
req.Header.Set("x-auth-token", "Bearer $TOKEN")
req.Header.Set("x-on-behalf-of", "$MEMBER_ID")
req.Header.Set("x-idempotency-key", "$IDEMPOTENCY_KEY")
req.Header.Set("content-type", "application/json")
res, err := http.DefaultClient.Do(req)
// 金额字段用 string 接,不要 float64
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.zise.com/v1/shipping-addresses"))
    .header("x-auth-token", "Bearer $TOKEN")
    .header("x-on-behalf-of", "$MEMBER_ID")
    .header("x-idempotency-key", "$IDEMPOTENCY_KEY")
    .header("content-type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
{
  "label": "家",
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "district": "中西区",
  "line1": "干诺道中 200 号",
  "postal_code": "000000",
  "is_default": true
}
"""))
    .build();
// 金额字段用 String / BigDecimal,不要 double
$ch = curl_init('https://api.zise.com/v1/shipping-addresses');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'x-auth-token: Bearer $TOKEN',
    'x-on-behalf-of: $MEMBER_ID',
    'x-idempotency-key: $IDEMPOTENCY_KEY',
    'content-type: application/json',
  ],
  CURLOPT_POSTFIELDS => <<<'JSON'
{
  "label": "家",
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "district": "中西区",
  "line1": "干诺道中 200 号",
  "postal_code": "000000",
  "is_default": true
}
JSON,
]);
$res = curl_exec($ch);
// 金额用 bcmath / 字符串,不要 floatval
201
// spec 里还没有这个 operation 的响应示例