Z Zise Developers

活期赎回(LIFO;定期不可提前赎回

POST /v1/earn/redemptions scope: earn:write
代会员调用 · 必带 x-on-behalf-of x-idempotency-key 动钱 · 理财账户 → 会员可用余额(本金 + 已计利息)
这个端点会动钱

失败处置见下方响应表。超时(504)用同一把幂等键重试——我方可能已经处理完;业务失败要换新键,同键会原样返回那次失败。

只对活期。定期没有赎回端点 —— 客户端不可提前赎回是产品决定,

凭空提供一个会让你以为这条路存在。定期到期由我方自动结本息。

赎回是 LIFO:先扣还没起息的那部分。所以「今天申购、今天赎回」

不会吃掉昨天已经在计息的本金,也拿不到利息。

⚠ 利息按小时精度分段积分算,只在派息那一刻取整,余数滚存。

所以 interest 可能是 0(还不够一个最小单位),这不是错误。

credited 才是真正回到可用余额的那个数(= principal + interest)。

别自己加,取这个字段。

⚠ 这个端点没有撤销:赎回成交那一刻钱已经在可用余额里了。

前置条件

  • 目标产品的 kindflexible(定期传进来直接拒)
  • 该会员在这个产品上有活期持仓,且赎回额不超过持仓本金
字段类型必填说明
x-on-behalf-of string 必填 代哪个会员赎回。
x-idempotency-key string 必填 UUID。同键重放拿回上一次的结果,不会赎回第二次。

请求体

字段类型必填说明
product_id string 必填 活期产品 id。带不带 ern_ 前缀都认。
amount string 可选 赎回本金。字符串定点,位数 = 该产品 ledger_scale。 传了 all: true 时这个字段被忽略。USDT 是 6 位,形如 500.000000
all boolean 可选 true = 全额赎回(本金清零、持仓关闭)。 ⚠ 判据是严格等于 true,字符串 "true" 不算。

响应

201已赎回。三个金额都是定点十进制串,位数 = 产品 ledger_scaleclosed = 这次赎回之后持仓是否已清空。 同键重放时多一个 duplicated: trueHTTP 仍是 201 (与兑换/转账的 200 不同 —— 别按状态码判是不是重放,按这个字段判)。
{
  "id": "err_2f80c5a7-6d19-4b3e-a0c8-4e91b7d25036",
  "principal": "500.000000",
  "interest": "0.412300",
  "credited": "500.412300",
  "closed": false
}
400已登记的对外码:invalid_request 金额格式 / 请求体不合法 · product_not_available 产品不存在 · state_invalid 这个产品是 定期,不支持赎回 · idempotency_key_required · idempotency_key_invalid · member_context_required · member_not_found还落在 500 api_error:这个会员在该产品上没有持仓 · 赎回额超过持仓本金 · 金额 ≤ 0。
409idempotency_key_reused · idempotency_in_progress
请求
curl -X POST 'https://api.zise.com/v1/earn/redemptions' \
  -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 '{
    "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
    "amount": "500.000000"
  }'
const res = await fetch("https://api.zise.com/v1/earn/redemptions", {
  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({
    "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
    "amount": "500.000000"
  }),
});
// 金额按字符串读,别让它变成 number
const data = await res.json();
import requests

res = requests.post(
    "https://api.zise.com/v1/earn/redemptions",
    headers={
        "x-auth-token": "Bearer $TOKEN",
        "x-on-behalf-of": "$MEMBER_ID",
        "x-idempotency-key": "$IDEMPOTENCY_KEY",
        "content-type": "application/json",
    },
    json={
      "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
      "amount": "500.000000"
    },
)
# 金额用 Decimal(str(...)),不要 float
data = res.json()
req, _ := http.NewRequest("POST", "https://api.zise.com/v1/earn/redemptions",
    strings.NewReader(`{
  "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
  "amount": "500.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)
// 金额字段用 string 接,不要 float64
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.zise.com/v1/earn/redemptions"))
    .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("""
{
  "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
  "amount": "500.000000"
}
"""))
    .build();
// 金额字段用 String / BigDecimal,不要 double
$ch = curl_init('https://api.zise.com/v1/earn/redemptions');
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'
{
  "product_id": "ern_3a91f0c2-5d17-4e88-b2a0-91c7d4e6b501",
  "amount": "500.000000"
}
JSON,
]);
$res = curl_exec($ch);
// 金额用 bcmath / 字符串,不要 floatval
201
{
  "id": "err_2f80c5a7-6d19-4b3e-a0c8-4e91b7d25036",
  "principal": "500.000000",
  "interest": "0.412300",
  "credited": "500.412300",
  "closed": false
}