Description
This endpoint allows you to update an existing customer’s information in the LatePoint system. You can modify any customer field including personal details, contact information, status, and custom fields.
Authentication
Your LatePoint API Key with write permissions
Path Parameters
Unique ID of the customer to update
Request Body
Customer’s email address (must be unique)
Status and Settings
Customer status Possible values:
active
- Active customer
inactive
- Inactive customer
pending_verification
- Pending email verification
blocked
- Blocked customer
Whether the customer is a guest (no account)
Country code (ISO 3166-1 alpha-2)
Internal notes about the customer
WordPress media ID for customer avatar
Custom fields as key-value pairs
Response
Indicates if the update was successful
Updated customer information Unique ID of the updated customer
Examples
curl -X PUT "https://your-site.com/wp-json/latepoint-api/v1/customers/123" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"first_name": "John",
"last_name": "Smith",
"phone": "+1-555-0199"
}'
Update Status and Email
curl -X PUT "https://your-site.com/wp-json/latepoint-api/v1/customers/123" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"email": "john.smith.new@example.com",
"status": "active"
}'
curl -X PUT "https://your-site.com/wp-json/latepoint-api/v1/customers/123" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"address": "456 Oak Street",
"city": "Los Angeles",
"state": "CA",
"zipcode": "90210",
"country": "US"
}'
Response Examples
Successful Update
{
"success" : true ,
"message" : "Customer updated successfully" ,
"data" : {
"id" : 123 ,
"first_name" : "John" ,
"last_name" : "Smith" ,
"email" : "john.smith.new@example.com" ,
"phone" : "+1-555-0199" ,
"status" : "active" ,
"updated_at" : "2024-01-15 14:30:25"
}
}
Validation Error
{
"code" : "customer_update_failed" ,
"message" : "Error updating customer: Email already exists" ,
"data" : {
"status" : 400
}
}
Customer Not Found
{
"code" : "customer_not_found" ,
"message" : "Customer not found" ,
"data" : {
"status" : 404
}
}
Error Codes
Code Status Description customer_not_found
404 Customer with specified ID doesn’t exist customer_update_failed
400 Validation error or update failed latepoint_not_available
503 LatePoint plugin not loaded server_error
500 Internal server error
JavaScript Example
// Update customer information
async function updateCustomer ( customerId , updateData ) {
try {
const response = await fetch ( `https://your-site.com/wp-json/latepoint-api/v1/customers/ ${ customerId } ` , {
method: 'PUT' ,
headers: {
'X-API-Key' : 'your_api_key_here' ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ( updateData )
});
const result = await response . json ();
if ( result . success ) {
console . log ( 'Customer updated:' , result . data );
return result . data ;
} else {
throw new Error ( result . message );
}
} catch ( error ) {
console . error ( 'Error updating customer:' , error );
throw error ;
}
}
// Usage examples
// Update basic info
const basicUpdate = {
first_name: 'Jane' ,
last_name: 'Doe' ,
phone: '+1-555-0123'
};
const updatedCustomer = await updateCustomer ( 123 , basicUpdate );
// Update status
const statusUpdate = {
status: 'active'
};
await updateCustomer ( 123 , statusUpdate );
// Update with custom fields
const customFieldsUpdate = {
notes: 'VIP customer' ,
custom_fields: {
preferred_time: 'morning' ,
special_requests: 'Quiet room'
}
};
await updateCustomer ( 123 , customFieldsUpdate );
PHP Example
<? php
// Update customer using WordPress HTTP API
function update_customer ( $customer_id , $update_data ) {
$url = 'https://your-site.com/wp-json/latepoint-api/v1/customers/' . $customer_id ;
$response = wp_remote_request ( $url , array (
'method' => 'PUT' ,
'headers' => array (
'X-API-Key' => 'your_api_key_here' ,
'Content-Type' => 'application/json'
),
'body' => json_encode ( $update_data )
));
if ( is_wp_error ( $response )) {
throw new Exception ( 'Request failed: ' . $response -> get_error_message ());
}
$body = wp_remote_retrieve_body ( $response );
$data = json_decode ( $body , true );
if ( ! $data [ 'success' ]) {
throw new Exception ( 'Update failed: ' . $data [ 'message' ]);
}
return $data [ 'data' ];
}
// Usage
try {
$updated_customer = update_customer ( 123 , array (
'first_name' => 'Updated Name' ,
'status' => 'active'
));
echo 'Customer updated: ' . $updated_customer [ 'first_name' ];
} catch ( Exception $e ) {
echo 'Error: ' . $e -> getMessage ();
}
?>
Important Notes
Email Uniqueness : The email address must be unique across all customers. If you try to update a customer with an email that already exists, you will receive a validation error.
Partial Updates : You only need to include the fields you want to update. Fields not included in the request will remain unchanged.
Status Changes : Changing a customer’s status may affect their ability to book appointments or access the customer portal.
Custom Fields : Custom fields are merged with existing ones. To remove a custom field, set its value to null
or an empty string.
WordPress User : If the customer has an associated WordPress user account, some changes (like email) may also update the WordPress user.