Delete a Card
Permanently remove a card from a customer's account. This action is irreversible.
API Credentials
Request Parametersโ
Required - 2 fieldsPath Parameters
`id`STRING(required)
Customer ID (must be a valid customer ID starting with cust_).
`card_id`STRING(required)
Card ID to delete (must be a valid card ID starting with card_).
Responsesโ
200
Card deleted successfullyCard permanently removed from customer account.
Deletion effects:
- Card is permanently removed from customer
- Card details are no longer accessible
- Card cannot be used for future charges
- Past charges remain in records but card field becomes null
- If this was the default card, customer's default_card becomes null
- Deletion cannot be undone
400
Bad requestInvalid customer ID or card ID format.
Common causes:
- Invalid ID format
- IDs do not start with cust_ or card_
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Using public key instead of secret key
- Incorrect HTTP Basic Auth format
404
Not foundCustomer or card not found.
Common causes:
- Customer ID does not exist
- Card ID does not exist
- Card does not belong to the specified customer
- Card has already been deleted
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/customers/cust_test_5xuy4w91xqz7d1w9u0t/cards/card_test_5xuy4w91xqz7d1w9u0t \
-X DELETE \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
card = Omise::Card.destroy(
'card_test_5xuy4w91xqz7d1w9u0t',
customer_id: 'cust_test_5xuy4w91xqz7d1w9u0t'
)
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
customer = omise.Customer.retrieve('cust_test_5xuy4w91xqz7d1w9u0t')
card = customer.destroy_card('card_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const card = await omise.customers.destroyCard(
'cust_test_5xuy4w91xqz7d1w9u0t',
'card_test_5xuy4w91xqz7d1w9u0t'
);
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$customer = OmiseCustomer::retrieve('cust_test_5xuy4w91xqz7d1w9u0t');
$card = $customer->destroyCard('card_test_5xuy4w91xqz7d1w9u0t');
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Card card = client.customer("cust_test_5xuy4w91xqz7d1w9u0t")
.card("card_test_5xuy4w91xqz7d1w9u0t")
.destroy();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var card = await client.Customers.DestroyCard(
"cust_test_5xuy4w91xqz7d1w9u0t",
"card_test_5xuy4w91xqz7d1w9u0t"
);
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
deleted, _ := client.Cards().DestroyCard(
"cust_test_5xuy4w91xqz7d1w9u0t",
"card_test_5xuy4w91xqz7d1w9u0t",
)
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
bad_request | Invalid ID format | Check customer and card ID formats |
authentication_failure | Invalid API key | Verify your secret key is correct |
not_found | Customer or card not found | Verify IDs exist and card belongs to customer |
conflict | Cannot delete card in use | Wait for pending charges to complete |
Deletion Responseโ
| Field | Description |
|---|---|
object | Object type (always "card") |
id | ID of the deleted card |
deleted | Boolean flag (always true for successful deletions) |
livemode | Whether this was a live mode card |
Try it outโ
Required - 2 fields