Z Zise Developers 简体中文

Change a card nickname

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

nickname is a label the member uses for their own reference, such as Travel card or Subscription card. It is separate from the printed name_on_card, which cannot be changed after issuance. Do not treat them as one field, or you may incorrectly assume the printed card has changed.

An empty string is valid and clears the nickname. Maximum 40 characters; longer values are truncated.

Path Parameters

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

Request Body

FieldTypeRequiredDescription
nickname string Required

Response

200Updated
{
  "id": "crd_9f2c81a4",
  "nickname": "差旅卡"
}
400invalid_fields: nickname is not a string. idempotency_key_required.
404not_found
Request
curl -X PATCH 'https://api.zinfra.vip/v1/cards/{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 '{
    "nickname": "差旅卡"
  }'
const res = await fetch("https://api.zinfra.vip/v1/cards/{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({
    "nickname": "差旅卡"
  }),
});
// Keep monetary amounts as strings, never numbers.
const data = await res.json();
import requests

res = requests.patch(
    "https://api.zinfra.vip/v1/cards/{id}",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "x-idempotency-key": "$IDEMPOTENCY_KEY",
        "content-type": "application/json",
    },
    json={
      "nickname": "差旅卡"
    },
)
# Use Decimal(str(...)) for amounts, not float.
data = res.json()
req, _ := http.NewRequest("PATCH", "https://api.zinfra.vip/v1/cards/{id}",
    strings.NewReader(`{
  "nickname": "差旅卡"
}`))
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/cards/{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("""
{
  "nickname": "差旅卡"
}
"""))
    .build();
// Use String / BigDecimal for amounts, not double.
$ch = curl_init('https://api.zinfra.vip/v1/cards/{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'
{
  "nickname": "差旅卡"
}
JSON,
]);
$res = curl_exec($ch);
// Use bcmath / strings for amounts, not floatval.
200
{
  "id": "crd_9f2c81a4",
  "nickname": "差旅卡"
}