Update Contact
PATCH /api/contacts/:id
Section titled “ /api/contacts/”Partially updates information for an existing contact.
Path Parameters
Section titled “Path Parameters”Parameter | Type | Required | Description |
---|---|---|---|
id | string | Yes | Unique ID of the contact to update |
Request Body
Section titled “Request Body”All fields are optional. Only sent fields will be updated.
{ "name": "John Carlos", "lastName": "Doe Garcia", "phone": "3001234567", "countryCode": "57", "status": "INACTIVE", "birthDate": "1990-01-15T00:00:00.000Z", "tagIds": ["tag1-uuid", "tag2-uuid"], "customValues": [ { "id": "existing-value-uuid", "value": "New value", "customFieldId": "field-uuid" } ]}
Updatable Fields
Section titled “Updatable Fields”Field | Type | Description |
---|---|---|
name | string | Contact name |
lastName | string | Contact last name |
email | string | Email address |
phone | string | Phone number |
countryCode | string | Country code |
status | enum | Contact status: ACTIVE , INACTIVE , BLOCKED |
birthDate | datetime | Birth date |
tagIds | array | Tag IDs to associate |
customValues | array | Custom field values |
Successful Response (200)
Section titled “Successful Response (200)”{ "id": "contact-uuid-123", "name": "John Carlos", "lastName": "Doe Garcia", "phone": "3001234567", "countryCode": "57", "status": "INACTIVE", "birthDate": "1990-01-15T00:00:00.000Z", "origin": "API", "organizationId": "org-uuid", "customValues": [ { "id": "existing-value-uuid", "value": "New value", "customFieldId": "field-uuid" } ], "tags": [ { "id": "tag1-uuid", "name": "VIP Client", "description": "Important clients", "color": "#FF5722" } ], "createdAt": "2024-01-01T10:00:00.000Z", "updatedAt": "2024-01-15T14:30:00.000Z"}
Possible Errors
Section titled “Possible Errors”Code | Description |
---|---|
400 | Invalid data in request |
401 | Missing or invalid API Key |
404 | Contact not found |
409 | Phone number already exists |
422 | Validation errors |
500 | Internal server error |
Usage Examples
Section titled “Usage Examples”curl -X PATCH "https://app.sendme123.com/api/contacts/contact-uuid-123" \ -H "api-key: your-api-key-here" \ -H "Content-Type: application/json" \ -d '{ "name": "John Carlos", "email": "[email protected]", "status": "INACTIVE" }'
const updateContact = async (contactId, updateData) => { try { const response = await axios.patch(`https://app.sendme123.com/api/contacts/${contactId}`, updateData, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Contact updated:', response.data); return response.data; } catch (error) { console.error('Error updating contact:', error.response?.data || error.message); throw error; }};
// UsageupdateContact('contact-uuid-123', { name: 'John Carlos', status: 'INACTIVE'});
import requestsimport json
contact_id = 'contact-uuid-123'headers = {'api-key': 'your-api-key-here', 'Content-Type': 'application/json'}data = { 'name': 'John Carlos', 'status': 'INACTIVE'}
response = requests.patch('https://app.sendme123.com/api/contacts/' + contact_id, headers=headers, data=json.dumps(data))
if response.status_code == 200: contact = response.json() print('Contact updated:', contact)else: print('Error:', response.status_code)
Use Cases
Section titled “Use Cases”Update contact status
Section titled “Update contact status”const deactivateContact = async (contactId) => { try { const response = await axios.patch(`https://app.sendme123.com/api/contacts/${contactId}`, { status: 'INACTIVE' }, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Contact deactivated:', response.data); return response.data; } catch (error) { console.error('Error deactivating contact:', error.response?.data || error.message); throw error; }};
Update multiple fields
Section titled “Update multiple fields”const updateContactInfo = async (contactId, newInfo) => { try { const response = await axios.patch(`https://app.sendme123.com/api/contacts/${contactId}`, { name: newInfo.name, lastName: newInfo.lastName, email: newInfo.email, phone: newInfo.phone }, { headers: { 'api-key': 'your-api-key-here', 'Content-Type': 'application/json' } });
console.log('Contact information updated:', response.data); return response.data; } catch (error) { console.error('Error updating contact info:', error.response?.data || error.message); throw error; }};