Z Zise Developers 简体中文

Update an address

PATCH /v1/shipping-addresses/{id} scope: addresses:write
On behalf of a member · x-on-behalf-of required Requires x-idempotency-key

⚠ Replaces the entire address; it does not merge fields. All six required items must be present, just as when adding an address. With merging, omitting line2 could mean either clear it or leave it unchanged; that ambiguity can cause a parcel to be lost.

⚠ Does not change the default flag. Setting the default uses a separate endpoint. Updating content must not implicitly change where cards are shipped, a common unintended side effect of such APIs.

⚠ Existing physical card orders using this address are unaffected: the address is snapshotted into the order when it is placed. Updating the address neither reroutes parcels in transit nor changes the shipping address on historical orders.

Path Parameters

FieldTypeRequiredDescription
id string Required
FieldTypeRequiredDescription
x-idempotency-key string Required
x-on-behalf-of string Required

Request Body

Request body fields have not been declared in the specification for this operation.

Response

200Updated
400invalid_fields (with fields[].key) · idempotency_key_required
404not_found
Request
curl -X PATCH 'https://api.zinfra.vip/v1/shipping-addresses/{id}' \
  -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 '{
    "country": "HK",
    "recipient_last": "陈",
    "recipient_first": "小明",
    "phone_code": "852",
    "phone_number": "51234567",
    "city": "香港",
    "line1": "皇后大道中 15 号",
    "postal_code": "000000"
  }'
const res = await fetch("https://api.zinfra.vip/v1/shipping-addresses/{id}", {
  method: "PATCH",
  headers: {
    "x-auth-token": "Bearer $TOKEN",
    "x-on-behalf-of": "$MEMBER_ID",
    "x-idempotency-key": "$IDEMPOTENCY_KEY",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "country": "HK",
    "recipient_last": "陈",
    "recipient_first": "小明",
    "phone_code": "852",
    "phone_number": "51234567",
    "city": "香港",
    "line1": "皇后大道中 15 号",
    "postal_code": "000000"
  }),
});
// Keep monetary amounts as strings, never numbers.
const data = await res.json();
import requests

res = requests.patch(
    "https://api.zinfra.vip/v1/shipping-addresses/{id}",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "x-idempotency-key": "$IDEMPOTENCY_KEY",
        "content-type": "application/json",
    },
    json={
      "country": "HK",
      "recipient_last": "陈",
      "recipient_first": "小明",
      "phone_code": "852",
      "phone_number": "51234567",
      "city": "香港",
      "line1": "皇后大道中 15 号",
      "postal_code": "000000"
    },
)
# Use Decimal(str(...)) for amounts, not float.
data = res.json()
req, _ := http.NewRequest("PATCH", "https://api.zinfra.vip/v1/shipping-addresses/{id}",
    strings.NewReader(`{
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "line1": "皇后大道中 15 号",
  "postal_code": "000000"
}`))
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)
// Decode amount fields as string, not float64.
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.zinfra.vip/v1/shipping-addresses/{id}"))
    .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("PATCH", HttpRequest.BodyPublishers.ofString("""
{
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "line1": "皇后大道中 15 号",
  "postal_code": "000000"
}
"""))
    .build();
// Use String / BigDecimal for amounts, not double.
$ch = curl_init('https://api.zinfra.vip/v1/shipping-addresses/{id}');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  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'
{
  "country": "HK",
  "recipient_last": "陈",
  "recipient_first": "小明",
  "phone_code": "852",
  "phone_number": "51234567",
  "city": "香港",
  "line1": "皇后大道中 15 号",
  "postal_code": "000000"
}
JSON,
]);
$res = curl_exec($ch);
// Use bcmath / strings for amounts, not floatval.
200
// No response example is declared in the specification for this operation.