Skip to content

Close Card ​

Submits an irreversible close (cancellation) request for an active virtual card. The call is accepted synchronously — the card immediately enters status=4 (closing) and stays there until the closure completes — while the actual closure and the balance refund complete asynchronously via webhook + platform review.

  • Only cards owned by the current AppID account and of a virtual card type are accepted.
  • Only status=2 (active) cards can be closed; a frozen(6) card must be unfrozen first.
  • The remaining card balance is refunded to your wallet after platform review, per the card package's close-fee rules — the refund is not instant.

Endpoint ​

ItemValue
MethodPOST
Path/api/v1/openapi/card/close
AuthHMAC
IdempotencyNot required

No Idempotency-Key needed

Close is protected by the card state machine: retrying returns 40000 card_is_closing (in progress) or 40000 card_already_closed (done) rather than double-applying. The submission itself moves no money.

Request Fields ​

FieldTypeRequiredDescription
card_idstring✅card_<id> — must belong to your account and be a virtual card

Example Request ​

json
{ "card_id": "card_12345" }

Response Fields ​

FieldTypeDescription
card_idstringEcho of the card ID
statusintCard status after acceptance — always 4 (closing) on success
status_descstringEnglish status description — closing
successbooltrue when the close request was accepted
messagestringFixed English acceptance note (not localized — do not parse)

Example Response ​

json
{
  "code": 0,
  "message": "Success",
  "data": {
    "card_id": "card_12345",
    "status": 4,
    "status_desc": "closing",
    "success": true,
    "message": "Card closure request submitted, processing in progress"
  }
}

Lifecycle after acceptance ​

  1. Acceptance — this call returns status=4 (closing) and /card/info reports 4 from that moment until completion. The card can no longer be used for payments, and top-ups are rejected with card_is_closing. A card.status_changed webhook (active → closing) is delivered.
  2. Provider closure / clearing — the upstream provider confirms the closure asynchronously. Most card types complete shortly after the request (timing depends on the provider). virtual_s921 goes through a provider clearing period of about one day: during it the card stays closing (4) and /card/info keeps showing its balance unchanged.
  3. Completion — you receive the card.closed webhook; /card/info reports status=5 (closed) with balance 0. Since v1.5, card.closed is delivered for every completed closure — including cards that had a zero / negative balance at close and refunds automatically rejected for a currency mismatch (before v1.5 these were silently missing). Duplicate provider callbacks do not re-deliver it. (If the provider reports the closure through a status push instead of its close callback, it arrives as card.status_changed with to_status: "closed" — treat either event as completion.)
  4. Refund review — the remaining balance (minus the package's close fee) enters the platform's refund review:
    • Approved → credited to your wallet. No card webhook is sent for this step.
    • Rejected by a platform reviewer → the card is restored to active (2) and a card.status_changed webhook (closed → active) is delivered.
    • Rejected automatically by risk rules → no refund; the card stays closed.

Closes initiated by the platform (admin, risk control, system jobs) follow the same lifecycle and also emit card.status_changed (active / frozen → closing).

v1.5 fix — closing cards no longer flip back to active

Before v1.5 a provider status push or a recharge attempt could flip a closing card back to active (2), so a merchant could see "active, full balance" after closing it. A closing card now only moves to closed, or back to active through an explicit rollback that is always notified via card.status_changed.

Preconditions & Rules ​

  1. Ownership — card_id must belong to the authenticated account, else 404 card_not_found.
  2. Card type — only virtual cards (virtual_l / virtual_p / virtual_v / virtual_r / virtual_g / virtual_a / virtual_s921). A virtual_s921 card enters closing(4) on close and its balance is settled — with card.closed delivered — only after a clearing period of about one day.
  3. State — only status=2 (active); frozen(6) must be unfrozen first (card_frozen_cannot_close); repeat calls hit card_is_closing / card_already_closed.
  4. Irreversible — once accepted the closure cannot be cancelled by you.

Common Errors ​

Business errors come back with HTTP 200 and a non-zero code — always check code (0 = success) and branch on error_key.

HTTPcodeerror_keyDescription
20040001validation_failedRequest body cannot be parsed
20040000openapi_invalid_card_idcard_id missing or malformed (expected card_<number>)
20040000openapi_card_type_not_supportedCard is not a virtual card type
20040000card_is_closingA close request is already in progress
20040000card_already_closedCard is already closed
20040000card_frozen_cannot_closeCard is frozen — unfreeze first
20040000card_status_cannot_closeCard is not active (e.g. pending / failed); cannot be closed
20040000close_not_accepted_by_upstreamProvider did not accept the closure; the card has been restored to active — retry later
20040000card_upstream_closed_pending_reconcileCard was already closed directly by the provider and awaits manual refund reconciliation — do not close here
20040000card_config_not_found / card_type_mismatch / operation_not_supportedConfiguration / card-type problems
40140100openapi_invalid_credentialsAuth failure
40440400card_not_foundCard not found / not owned
42942900too_many_requestsRate limited — honor Retry-After
20050000openapi_close_card_failedServer error, or the provider call failed. When the provider call failed the card has normally been restored to active — check /card/info before retrying

A rejected request (any error above) changes nothing visible to you: no card.status_changed is sent.

Integration pitfalls & best practices ​

Read before integrating

Close is the highest-consequence card operation: irreversible, provider-bound, and money moves later via review.

  1. Synchronous, provider-bound call — allow up to ~60 s. The submission calls the upstream provider inline. Set your HTTP client timeout to ≥ 60 s for this endpoint.
  2. A client-side timeout does NOT mean the close failed. On any timeout / network error, reconcile via /card/info: status=4/5 → accepted (do not resubmit as a "new" close); status=2 → not applied (safe to retry).
  3. Completion signal is asynchronous. Treat the card.closed webhook (or polling until status=5) as completion — the synchronous response only means "accepted". For virtual_s921 expect about one day.
  4. Refund is not instant and not guaranteed to equal the last seen balance. It passes platform review and deducts the package close fee; a reviewer's rejection restores the card to active (card.status_changed closed → active). Reconcile your books against the wallet credit, not against the pre-close card balance.
  5. close_not_accepted_by_upstream auto-rolls back. The card is already restored to active when you receive this error — no cleanup needed on your side, just retry later.
  6. Treat card_is_closing / card_already_closed as "already in the desired state", not hard errors, when retrying.

Released under MIT-equivalent terms.