Delete Contact
DELETE /api/contacts/:id
Section titled “ /api/contacts/”Permanently deletes a contact from the database.
Path Parameters
Section titled “Path Parameters”Parameter | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique ID of the contact to delete |
Successful Response (200)
Section titled “Successful Response (200)”{ "message": "Contact successfully deleted", "deletedContactId": "contact-uuid-123"}
Possible Errors
Section titled “Possible Errors”Code | Description |
---|---|
400 | Invalid contact ID |
401 | Missing or invalid API Key |
404 | Contact not found |
409 | Contact cannot be deleted (has pending messages) |
500 | Internal server error |
Usage Examples
Section titled “Usage Examples”curl -X DELETE "https://app.sendme123.com/api/contacts/contact-uuid-123" \ -H "api-key: your-api-key-here" \ -H "Content-Type: application/json"
const deleteContact = async (contactId) => { try { const response = await axios.delete(`https://app.sendme123.com/api/contacts/${contactId}`, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Contact deleted:', response.data); return response.data; } catch (error) { console.error('Error deleting contact:', error.response?.data || error.message); throw error; }};
// UsagedeleteContact('contact-uuid-123');
import requests
contact_id = 'contact-uuid-123'headers = {'api-key': 'your-api-key-here', 'Content-Type': 'application/json'}
response = requests.delete('https://app.sendme123.com/api/contacts/' + contact_id, headers=headers)
if response.status_code == 200: result = response.json() print('Contact deleted:', result)else: print('Error:', response.status_code)
Use Cases
Section titled “Use Cases”Safe deletion with confirmation
Section titled “Safe deletion with confirmation”const safeDeleteContact = async (contactId) => { try { // First verify the contact exists const contact = await axios.get(`https://app.sendme123.com/api/contacts/${contactId}`, { headers: { 'api-key': 'your-api-key-here' } });
console.log(`Deleting contact: ${contact.data.name} ${contact.data.lastName || ''}`);
// Proceed with deletion const response = await axios.delete(`https://app.sendme123.com/api/contacts/${contactId}`, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Contact successfully deleted:', response.data); return response.data; } catch (error) { if (error.response?.status === 404) { throw new Error('Contact not found'); } console.error('Error deleting contact:', error.response?.data || error.message); throw error; }};
Bulk deletion with error handling
Section titled “Bulk deletion with error handling”const deleteMutlipleContacts = async (contactIds) => { const results = [];
for (const contactId of contactIds) { try { const response = await axios.delete(`https://app.sendme123.com/api/contacts/${contactId}`, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
results.push({ contactId, success: true, data: response.data }); } catch (error) { results.push({ contactId, success: false, error: error.response?.data || error.message }); } }
return results;};
Important Considerations
Section titled “Important Considerations”- Irreversible action: Deleted contacts cannot be recovered
- Message dependencies: If the contact has pending or recent messages, deletion might be prevented
- Cascade effects: Associated message history might be affected
- Best practice: Consider deactivating contacts instead of deleting them for better data integrity