PUT
/
wp-json
/
latepoint-api
/
v1
/
customers
/
{id}
Update Customer
curl --request PUT \
  --url https://your-site.com/wp-json/latepoint-api/v1/customers/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '{
  "first_name": "<string>",
  "last_name": "<string>",
  "email": "<string>",
  "phone": "<string>",
  "status": "<string>",
  "is_guest": true,
  "address": "<string>",
  "city": "<string>",
  "state": "<string>",
  "zipcode": "<string>",
  "country": "<string>",
  "notes": "<string>",
  "avatar_image_id": 123,
  "custom_fields": {}
}'
{
  "success": true,
  "message": "<string>",
  "data": {
    "id": 123,
    "first_name": "<string>",
    "last_name": "<string>",
    "email": "<string>",
    "phone": "<string>",
    "status": "<string>",
    "updated_at": "<string>"
  }
}

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

X-API-Key
string
required
Your LatePoint API Key with write permissions

Path Parameters

id
integer
required
Unique ID of the customer to update

Request Body

Basic Information

first_name
string
Customer’s first name
last_name
string
Customer’s last name
email
string
Customer’s email address (must be unique)
phone
string
Customer’s phone number

Status and Settings

status
string
Customer statusPossible values:
  • active - Active customer
  • inactive - Inactive customer
  • pending_verification - Pending email verification
  • blocked - Blocked customer
is_guest
boolean
Whether the customer is a guest (no account)

Address Information

address
string
Street address
city
string
City name
state
string
State or province
zipcode
string
ZIP or postal code
country
string
Country code (ISO 3166-1 alpha-2)

Additional Information

notes
string
Internal notes about the customer
avatar_image_id
integer
WordPress media ID for customer avatar
custom_fields
object
Custom fields as key-value pairs

Response

success
boolean
Indicates if the update was successful
message
string
Success message
data
object
Updated customer information

Examples

Update Basic Information

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"
  }'

Update Address Information

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

CodeStatusDescription
customer_not_found404Customer with specified ID doesn’t exist
customer_update_failed400Validation error or update failed
latepoint_not_available503LatePoint plugin not loaded
server_error500Internal 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.