Skip to content

Close Card

Permanently close a virtual card and withdraw remaining balance to wallet

Endpoint: PATCH https://api.uncash.io/api/v1/cards/{id}/close

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe card ID (UUID) to close

Response

Success Response

FieldTypeDescription
successbooleanIndicates if the card was closed successfully
messagestringSuccess message
timestampstringISO 8601 timestamp

Data Object

FieldTypeDescription
card_idstringCard ID (UUID) that was closed
balance_withdrawnnumberAmount withdrawn from card to wallet
transaction_idstringTransaction ID (UUID) for the balance withdrawal (null if no balance)
invoice_idnumberInvoice ID for the withdrawal transaction (null if no balance)
new_wallet_balancenumberNew wallet balance after withdrawal

Request Example

bash
curl -X PATCH https://api.uncash.io/api/v1/cards/card-id/close \
  -H "Authorization: Bearer uc_your_api_token_here"
javascript
const response = await fetch('https://api.uncash.io/api/v1/cards/card-id/close', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer uc_your_api_token_here'
  }
});

const data = await response.json();
python
import requests

url = "https://api.uncash.io/api/v1/cards/card-id/close"
headers = {"Authorization": "Bearer uc_your_api_token_here"}

response = requests.patch(url, headers=headers)
data = response.json()

Response Example

json
{
  "success": true,
  "message": "Card closed successfully",
  "data": {
    "card_id": "card-id",
    "balance_withdrawn": 15.00,
    "transaction_id": "tx-id",
    "invoice_id": 24929,
    "new_wallet_balance": 1434.14
  },
  "timestamp": "2025-11-22T11:25:30.456Z"
}

Behavior

  • Balance Withdrawal: Any remaining balance on the card is automatically withdrawn to your wallet
  • Provider Closure: The card is terminated at the provider level (irreversible)
  • Database Update: Card status is set to "closed" in the database
  • No Balance: If card has zero balance, no withdrawal transaction is created

Warning

Irreversible Action: Closing a card is permanent. The card cannot be reactivated after closure.

Validation Rules

  • Card must have a valid provider_id (not 'temp')
  • Card must not already be closed
  • 15-minute cooldown between withdrawal/closure operations

Error Responses

Card Already Closed

json
{
  "success": false,
  "message": "Card is already closed",
  "timestamp": "2025-11-22T10:00:00.000Z"
}

Card Not Ready

json
{
  "success": false,
  "message": "Card not ready for closure",
  "timestamp": "2025-11-22T10:00:00.000Z"
}

Cooldown Period

json
{
  "success": false,
  "message": "Please wait 15 minutes between withdrawals",
  "timestamp": "2025-11-22T10:00:00.000Z"
}

Provider Error

json
{
  "success": false,
  "message": "Failed to close card: Provider error message",
  "timestamp": "2025-11-22T10:00:00.000Z"
}

UnCash API Documentation