Skip to content

錯誤碼

Coinepay OpenAPI 錯誤響應同時包含:

  • code:與 HTTP 狀態碼相同(200/400/401/404/409/429/500)
  • message:根據請求頭 Accept-Language 返回中文或英文
  • message_key:穩定的英文 key,程式判斷用這個
json
{
  "code": 400,
  "message": "Idempotency-Key 衝突",
  "message_key": "openapi_idempotency_key_conflict",
  "data": null
}

HTTP 狀態碼語義

HTTP含義
200成功(含"冪等返回"和"已入隊")
400引數錯 / 業務規則不滿足(看 message_key 區分)
401鑑權失敗(一律 openapi_invalid_credentials,不區分原因)
403鑑權透過但所請求的特性受限(如敏感卡資訊的二次驗證缺失/未透過、卡未啟用)
404資源不存在 / 不屬於當前賬號
409冪等鍵衝突(同 key 不同 body)
429限流
500服務端異常

完整 message_key 字典

鑑權與憑證

message_keyzh-CNen-USHTTP
openapi_invalid_credentials無效的 OpenAPI 憑證Invalid OpenAPI credentials401

ID 校驗

message_keyzh-CNen-USHTTP
openapi_invalid_header_idheader_id 不合法(缺字首 / 錯字首 / 不存在)Invalid header_id400
openapi_invalid_package_idpackage_id 不合法Invalid package_id400
openapi_invalid_card_idcard_id 不合法Invalid card_id400

冪等

message_keyzh-CNen-USHTTP
openapi_idempotency_key_required缺少 Idempotency-Key 請求頭Missing Idempotency-Key header400
openapi_idempotency_key_too_longIdempotency-Key 超長(最大 128 字元)Idempotency-Key too long400
openapi_idempotency_key_invalid_charsIdempotency-Key 含非法字元Invalid characters400
openapi_idempotency_key_conflictIdempotency-Key 衝突Idempotency-Key conflict409

業務規則

message_keyzh-CNen-USHTTP
openapi_card_type_not_supported暫不支援該卡型別,僅虛擬卡Not supported (virtual cards only)400
account_manager_bind_required該卡頭需繫結客戶經理後才能開通Account-manager-controlled header; bind an account manager first400
account_manager_unavailable繫結的客戶經理已失效,請聯絡客服Your account manager is no longer active; contact support400
account_manager_open_disabled您的客戶經理尚未對該賬號開放此卡頭 / 套餐Header / package not opened for your account by your account manager400
amount_requiredamount 為必填amount is required400
card_not_found卡片不存在 / 不屬於當前賬號Card not found404
insufficient_balance餘額不足Insufficient balance400
kyc_required請先完成實名認證Please complete identity verification first400
kyc_not_approvedKYC 未透過KYC not approved400
virtual_g_name_invalid(G 卡)持卡人姓名不滿足 ASCII 字母 / 單空格 / ≤40 字元規則(G card) cardholder name fails the rule400
virtual_g_required_fields_missing(G 卡)開卡資料不完整(G card) apply payload incomplete400
virtual_a_required_fields_missing(A 卡)first_name / last_name 缺失或為空白,或開卡資料不完整(A card) name missing/blank or apply payload incomplete400

首充(自定義金額)

/card/apply(作為 message_key,HTTP 400)與 /card/first_deposit/preview(作為 200 響應體內的 invalid_reason)返回,表示自定義 first_deposit_amount 不可受理。

message_keyzh-CNen-USHTTP
invalid_first_deposit_amountfirst_deposit_amount 必須是非負整數first_deposit_amount must be a non-negative integer400
first_recharge_below_base首充低於配置底額First deposit below the config base400
first_recharge_exceeds_max超額超過最大充值Excess exceeds max recharge400
first_recharge_limit_exceeded超額超過充值限額Excess exceeds the recharge limit400
first_recharge_asset_mismatch開卡費資產與充值資產不一致Open-fee asset differs from recharge asset400
first_recharge_excess_too_small超額扣費取整後過小Excess too small after fee + rounding400

敏感卡片資訊

下列錯誤碼由 /openapi/card/infowith_sensitive=true 前提不滿足時)與 /openapi/card/sensitive/send_code 返回。敏感欄位要求卡處於 status=2 (active),並透過使用者二次驗證或憑證免驗證特權二者之一。

message_keyzh-CNen-USHTTP
email_code_required請輸入郵箱驗證碼Please enter email verification code403
sms_code_required請輸入簡訊驗證碼Please enter SMS verification code403
pin_required請輸入 PIN 碼Please enter PIN403
2fa_code_required請輸入 2FA 驗證碼Please enter 2FA code403
invalid_email_code郵箱驗證碼錯誤Invalid email verification code403
invalid_sms_code簡訊驗證碼錯誤Invalid SMS verification code403
invalid_pinPIN 碼錯誤Invalid PIN403
invalid_2fa_code2FA 驗證碼錯誤Invalid 2FA code403
email_not_verified郵箱未驗證Email not verified403
phone_not_verified手機號未驗證Phone not verified403
no_usable_auth_method無可用的認證方式No usable authentication method403
card_sensitive_access_banned透過 API 獲取敏感卡片資訊的許可權已被管理員關閉Sensitive card info access via API has been disabled by the administrator403
openapi_sensitive_card_only_active僅啟用狀態的卡片可獲取敏感資訊Sensitive card info is only available for active cards.403
too_many_requests請求過於頻繁(驗證鎖定 / 發碼冷卻,遵循 Retry-AfterToo many requests (verification locked / send cooldown; honor Retry-After)429
send_code_failed驗證碼傳送失敗(冷卻已釋放,可立即重試)Failed to send verification code (cooldown released, retry allowed)500

openapi_sensitive_card_info_disabled(403)不再返回:未開通免驗證特權的憑證現在會落入使用者二次驗證路徑,而不是被直接拒絕。

卡列表過濾

message_keyzh-CNen-USHTTP
openapi_conflicting_card_filtersusable_only 與 statuses 不能同時傳usable_only and statuses cannot be used together400
openapi_invalid_status_valuestatuses 含非法狀態值(僅允許 1-6)statuses contains an invalid value (only 1-6 allowed)400
invalid_min_balance最小余額必須是合法非負數字(如 0 或 10.5)min_balance must be a valid non-negative number400
invalid_max_balance最大余額必須是合法非負數字max_balance must be a valid non-negative number400
min_balance_exceeds_max_balance最小余額不能大於最大余額min_balance must not exceed max_balance400
invalid_date_format日期格式必須是 YYYY-MM-DDdate must be in YYYY-MM-DD format400

交易明細過濾

/transactions/list/card/transactions/list 返回。

message_keyzh-CNen-USHTTP
invalid_date_format交易時間格式必須為 YYYY-MM-DD HH:MM:SStransaction_time_from/to must be YYYY-MM-DD HH:MM:SS400
invalid_params引數無效(如金額格式錯誤)Invalid parameters (e.g. bad amount format)400

凍結 / 解凍

/card/freeze/card/unfreeze 返回。

message_keyzh-CNen-USHTTP
card_already_frozen卡片已被凍結Card is already frozen400
card_status_cannot_freeze當前卡狀態不可凍結Current card status does not allow freezing400
card_not_frozen卡片未被凍結Card is not frozen400
card_type_mismatch卡型別與配置不匹配Card type does not match400
operation_not_supported該操作不支援Operation not supported for this card type400
recharge_unfreeze_disabled該卡不允許透過充值自動解凍Recharge-based unfreeze is not available400
unauthorized_unfreeze_admin該卡片被管理員凍結,使用者無法自行解凍Frozen by admin — cannot self-unfreeze403
unauthorized_unfreeze_risk該卡片被風控凍結Frozen by risk control — cannot self-unfreeze403
unauthorized_unfreeze_system該卡片被系統凍結Frozen by system — cannot self-unfreeze403

銷卡

/card/close 返回(v1.3 —— 端點自 v1.2 起已上線但此前未收錄文件)。

message_keyzh-CNen-USHTTP
card_is_closing卡片正在註銷中Card is being closed400
card_already_closed卡片已註銷Card is already closed400
card_frozen_cannot_close卡片已凍結,無法註銷Card is frozen and cannot be cancelled400
card_status_cannot_close當前卡狀態不可註銷Current card status does not allow cancellation400
close_not_accepted_by_upstream銷卡未被上游受理,卡片已恢復為可用狀態,請稍後重試Closure not accepted by the provider; card restored to active — retry later400
card_upstream_closed_pending_reconcile該卡已被上游直接註銷,正在等待人工對賬退款Card already closed by the provider; awaiting manual refund reconciliation400
card_config_not_found卡配置不存在Card configuration not found400
openapi_close_card_failed銷卡失敗Failed to close card500

服務端異常

message_keyzh-CNen-USHTTP
openapi_internal_errorOpenAPI 內部錯誤OpenAPI internal error500
openapi_list_card_headers_failed查詢卡頭列表失敗Failed to list card headers500
openapi_list_card_configs_failed查詢卡配置列表失敗Failed to list card configs500
openapi_apply_card_failed申請虛擬卡失敗Failed to apply virtual card500
openapi_first_deposit_preview_failed首充預覽失敗Failed to preview first deposit500
openapi_recharge_failed充值失敗Failed to recharge500
openapi_get_card_info_failed獲取卡片資訊失敗Failed to get card info500
openapi_list_cards_failed查詢卡列表失敗Failed to list cards500
openapi_list_webhook_events_failed查詢 Webhook 事件歷史失敗Failed to list webhook events500
openapi_list_transactions_failed查詢交易明細失敗Failed to list transactions500
openapi_freeze_card_failed凍結卡片失敗Failed to freeze card500
openapi_unfreeze_card_failed解凍卡片失敗Failed to unfreeze card500

程式處理建議

python
def handle_response(resp):
    code = resp.get('code', 500)
    key = resp.get('message_key', '')

    if code == 200:
        return resp['data']
    if code == 401:
        # 永遠是 openapi_invalid_credentials
        raise AuthError("憑證無效或已過期,請檢查 AppID/Secret/時鐘")
    if code == 403:
        # 鑑權透過但所請求的特性受限
        if key.endswith('_required'):
            raise PermissionError(f"缺少二次驗證憑據({key})—— "
                                  "先呼叫 /openapi/card/sensitive/send_code 再重試")
        if key.startswith('invalid_'):
            raise PermissionError(f"二次驗證未透過: {key}")
        if key == 'openapi_sensitive_card_only_active':
            raise RuntimeError("卡未啟用,不能請求敏感欄位")
        raise PermissionError(f"特性受限: {key}")
    if key == 'insufficient_balance':
        raise BalanceError("餘額不足")
    if key == 'kyc_not_approved' or key == 'kyc_required':
        raise KYCError("KYC 未透過")
    if key.startswith('openapi_invalid_') and key.endswith('_id'):
        raise ValueError(f"ID 格式錯或不存在: {key}")
    if key == 'openapi_idempotency_key_conflict':
        # 不應自動重試 —— 業務側需檢查 body
        raise IdempotencyConflict()
    if code == 429:
        raise RateLimited()
    if code >= 500:
        raise ServerError(resp.get('message', '內部錯誤'))

    raise ApiError(code, key, resp.get('message'))

多語言

透過請求頭 Accept-Language 控制 message 的語言:

http
Accept-Language: en-US
取值行為
不傳預設中文
zh-CN / zh中文
en-US / en英文
其他回退到預設

message_key 不受 Accept-Language 影響,永遠穩定。

採用 MIT 等價條款釋出