Freeze/Unfreeze
Use this endpoint to Freeze or Unfreeze a card
Last updated
Use this endpoint to Freeze or Unfreeze a card
Last updated
POST
https://api.krezypay.com/v1/sandbox/card/card_status
Headers
Name | Value |
---|---|
Body
Name | Type | Description |
---|---|---|
Response
{
"status": "success",
"message": "This card has been unfrozen successfully"
}
{
"error": "Invalid request"
}
See Examples Below
// Define the endpoint and the token
const endpoint = 'https://api.krezypay.com/v1/sandbox/card/card_status';
const bearerToken = 'your_bearer_token_here'; // Replace this with your actual Bearer token
// Define the request body
const requestBody = {
card_id: "c451ad689f414827abb0b6dc6ea96edb",
card_status: "active"
};
// Send an HTTP POST request
fetch(endpoint, {
method: 'POST', // The request method
headers: {
'Content-Type': 'application/json', // Tell the server the format of the body
'Authorization': `Bearer ${bearerToken}` // Add the Bearer token to the request headers
},
body: JSON.stringify(requestBody) // Convert the body object to a JSON string
})
.then(response => {
// Check if the response status is OK (2xx)
if (!response.ok) {
return response.json().then(errorData => {
throw new Error(`Error: ${errorData.message}`);
});
}
return response.json(); // Parse the JSON response
})
.then(data => {
console.log(JSON.stringify(data, null, 2)); // Log the response as formatted JSON
})
.catch((error) => {
console.error('Error:', error); // Handle any errors during the request
});
<?php
// Define the endpoint URL and the Bearer token
$endpoint = "https://api.krezypay.com/v1/sandbox/card/card_status";
$bearerToken = "your_bearer_token_here"; // Replace with your actual Bearer token
// Define the request body
$requestBody = [
"card_id" => "c451ad689f414827abb0b6dc6ea96edb",
"card_status" => "active"
];
// Initialize cURL session
$ch = curl_init();
// Set the cURL options
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// Set the headers, including the Authorization Bearer token
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $bearerToken",
"Content-Type: application/json"
]);
// Attach the JSON-encoded body to the request
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
// Execute the request
$response = curl_exec($ch);
// Check if there was an error with the request
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
exit;
}
// Get the HTTP response status code
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close the cURL session
curl_close($ch);
// Handle the response
if ($httpCode === 200) {
// Decode the JSON response if it's successful
$responseData = json_decode($response, true);
echo json_encode($responseData, JSON_PRETTY_PRINT); // Output the response as formatted JSON
} else {
// Handle error responses
$responseData = json_decode($response, true);
echo json_encode([
"status" => "error",
"message" => $responseData['message'] ?? "An error occurred.",
"http_code" => $httpCode
], JSON_PRETTY_PRINT);
}
import requests
import json
# Define the API endpoint and Bearer token
url = "https://api.krezypay.com/v1/sandbox/card/card_status"
bearer_token = "your_bearer_token_here" # Replace with your actual Bearer token
# Define the request payload (body)
payload = {
"card_id": "c451ad689f414827abb0b6dc6ea96edb",
"card_status": "active"
}
# Define the headers including the Authorization Bearer token
headers = {
"Authorization": f"Bearer {bearer_token}",
"Content-Type": "application/json"
}
# Make the POST request
response = requests.post(url, headers=headers, json=payload)
# Handle the response
if response.status_code == 200:
# If the request was successful, parse the JSON response
response_data = response.json()
print(json.dumps(response_data, indent=4)) # Pretty-print the JSON response
else:
# If an error occurred, print the status code and the response message
print(json.dumps({
"status": "error",
"message": response.json().get("message", "An error occurred"),
"http_code": response.status_code
}, indent=4))
Content-Type
application/json
Authorization
Bearer <token>
card_id
string
The card identifier
card_status
string
The status of the card. It must be "active" or "inactive".