/api/qmail/contacts/delete
DELETERemove a contact from your QMail address book by serial number.
DELETE /api/qmail/contacts/delete
Description
The /api/qmail/contacts/delete endpoint permanently removes a contact from your address book. The contact is identified by its CloudCoin serial number. If no contact exists with the given serial number, the API returns a 404 error.
Permanent Deletion
This operation cannot be undone. Once a contact is deleted, you will need to add them again using the contacts/add endpoint if you want to restore them.
Parameters
Send parameters as form data or query string values:
| Parameter | Type | Required | Description |
|---|---|---|---|
serial_number |
string/int | Yes | CloudCoin serial number of the contact to delete (1 - 16,777,216). |
Response
Returns a JSON object indicating the result of the delete operation.
Success Response Properties
success
boolean
Always
true on success.
message
string
"Contact deleted".
serial_number
integer
The serial number of the deleted contact.
Example Success Response
{
"success": true,
"message": "Contact deleted",
"serial_number": 1234567
}
Error Response Properties
success
boolean
Always
false on error.
message
string
Human-readable error description.
error
string
Machine-readable error code string.
Example Error Response (400 Bad Request)
{
"success": false,
"message": "Missing required parameter: serial_number",
"error": "invalid_request"
}
Example Error Response (404 Not Found)
{
"success": false,
"message": "Contact not found",
"error": "not_found"
}
Try It Out
Examples
cURL
# Delete a contact by serial number
curl -X DELETE "http://localhost:8080/api/qmail/contacts/delete?serial_number=1234567"
# Using form data
curl -X DELETE "http://localhost:8080/api/qmail/contacts/delete" \
-d "serial_number=1234567"
JavaScript (fetch)
const API_BASE = 'http://localhost:8080/api';
async function deleteContact(serialNumber) {
try {
const params = new URLSearchParams({
serial_number: serialNumber
});
const response = await fetch(
`${API_BASE}/qmail/contacts/delete?${params}`,
{ method: 'DELETE' }
);
const result = await response.json();
if (result.success) {
console.log('Contact deleted successfully!');
console.log('Serial Number:', result.serial_number);
} else if (response.status === 404) {
console.error('Contact not found:', result.message);
} else {
console.error('Failed to delete contact:', result.message);
}
} catch (error) {
console.error('Error deleting contact:', error);
}
}
deleteContact('1234567');
Python
import requests
API_BASE = 'http://localhost:8080/api'
def delete_contact(serial_number):
try:
params = {'serial_number': serial_number}
response = requests.delete(
f'{API_BASE}/qmail/contacts/delete',
params=params
)
result = response.json()
if result.get('success'):
print('Contact deleted successfully!')
print(f'Serial Number: {result["serial_number"]}')
elif response.status_code == 404:
print(f'Contact not found: {result["message"]}')
else:
print(f'Failed to delete contact: {result["message"]}')
except Exception as e:
print(f'Error deleting contact: {str(e)}')
delete_contact('1234567')