Send SMS
Send a text message
POST
https://api.krezypay.com/v1/sandbox/services/send_sms
Body
Name
Type
Description
userID
string
This is your account identifier indicating whether you are in production or in test
label
string
The name of the company or the product label
phone
string
The number that will receive the SMS
content
string
The content of the SMS
Response
{
"status": "success",
"message": "SMS sent successfully"
}
{
"error": "Invalid request"
}
// Define the endpoint URL
const url = "https://api.krezypay.com/v1/sandbox/services/send_sms";
// Create the request body
const requestBody = {
userID: "pwowhL5g0v9Sx1m3qlcrj1o8Z5J2Acb8kad5E7f3gmau9iye8zuPUV6MhtRIFqnQ7p6OjzdC10Wk24bs....",
phone: "+182938516..",
label: "TEST",
content: "Welcome to TEST COMPANY"
};
// Make the POST request
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(requestBody)
})
.then(response => {
// Check if the response is okay
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Parse the JSON response
return response.json();
})
.then(data => {
// Log the success message
console.log("Success:", data);
})
.catch(error => {
// Log any errors that occurred
console.error("Error:", error);
});
<?php
// Define the URL of the endpoint
$url = "https://api.krezypay.com/v1/sandbox/services/send_sms";
// Create the request body as an associative array
$requestBody = [
"userID" => "pwowhL5g0v9Sx1m3qlcrj1o8Z5J2Acb8kad5E7f3gmau9iye8zuPUV6MhtRIFqnQ7p6OjzdC10Wk24bs....",
"phone" => "+182938516..",
"label" => "TEST",
"content" => "Welcome to TEST COMPANY"
];
// Initialize cURL
$ch = curl_init($url);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_POST, true); // Specify that this is a POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json" // Set the content type to JSON
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody)); // Encode the request body as JSON
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
// Log the error
echo "cURL Error: " . curl_error($ch);
} else {
// Decode the JSON response
$responseData = json_decode($response, true);
// Log the success response
echo "Success: " . print_r($responseData, true);
}
// Close cURL
curl_close($ch);
?>
import requests
import json
# Define the URL of the endpoint
url = "https://api.krezypay.com/v1/sandbox/services/send_sms"
# Create the request body as a dictionary
request_body = {
"userID": "pwowhL5g0v9Sx1m3qlcrj1o8Z5J2Acb8kad5E7f3gmau9iye8zuPUV6MhtRIFqnQ7p6OjzdC10Wk24bs....",
"phone": "+182938516..",
"label": "TEST",
"content": "Welcome to TEST COMPANY"
}
# Make the POST request
response = requests.post(url, headers={"Content-Type": "application/json"}, data=json.dumps(request_body))
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
response_data = response.json()
# Log the success response
print("Success:", response_data)
else:
# Log the error response
print("Error:", response.status_code, response.text)
Last updated