PUT
/
wp-json
/
latepoint-api
/
v1
/
bookings
/
{id}
Update Booking
curl --request PUT \
  --url https://your-site.com/wp-json/latepoint-api/v1/bookings/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '{
  "service_id": 123,
  "agent_id": 123,
  "location_id": 123,
  "start_date": "<string>",
  "start_time": "<string>",
  "duration": 123,
  "status": "<string>",
  "customer_id": 123,
  "customer.first_name": "<string>",
  "customer.last_name": "<string>",
  "customer.email": "<string>",
  "customer.phone": "<string>",
  "price": "<string>",
  "notes": "<string>",
  "send_notification": true
}'
{
  "status": "error",
  "error": {
    "code": "booking_not_found",
    "message": "Booking with ID 123 was not found"
  }
}

Description

This endpoint allows you to update an existing booking. You can modify any booking field, including schedules, status, customer information, and notes.

Authentication

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

Path Parameters

id
integer
required
Unique ID of the booking to update

Request Body

Booking Fields

service_id
integer
Service ID (requires availability verification if changed)
agent_id
integer
Agent ID (requires availability verification if changed)
location_id
integer
Location ID
start_date
string
New booking date (format: YYYY-MM-DD)
start_time
string
New start time (format: HH:MM in 24-hour format)
duration
integer
Custom duration in minutes
status
string
Booking statusPossible values:
  • pending - Pending
  • approved - Approved
  • cancelled - Cancelled
  • completed - Completed
  • no_show - No show

Customer Information

customer_id
integer
Change to a different customer (customer ID)
customer.first_name
string
Update customer first name
customer.last_name
string
Update customer last name
customer.email
string
Update customer email
customer.phone
string
Update customer phone

Additional Fields

price
string
Custom price for this booking
notes
string
Public booking notes
send_notification
boolean
default:"false"
Whether to send notification to customer about changes

Response

Successful Response (200 OK)

status
string
Response status (“success”)
data
object
Updated booking object with all fields

Examples

Change Booking Status

curl -X PUT "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings/16" \
  -H "X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "15:30",
    "duration": 90,
    "status": "approved",
    "notes": "Tiempo extendido por solicitud del cliente"
  }'

Error Codes

{
  "status": "error",
  "error": {
    "code": "booking_not_found",
    "message": "Booking with ID 123 was not found"
  }
}

Validations

Automatic Validations

  1. Availability: If you change date, time or agent, availability is verified
  2. Valid States: Only allows valid status transitions
  3. Dates: Does not allow changing to past dates
  4. Unique Email: Verifies that email is not in use by another customer
  5. Permissions: Verifies that you have permissions to modify the booking

Status Transition Rules

Current StatusAllowed States
pendingapproved, cancelled
approvedcompleted, cancelled, no_show
cancelledpending, approved
completedcancelled (special permissions only)
no_showapproved, cancelled

Common Use Cases

1. Confirm Pending Booking

// Confirm a booking that was pending
async function confirmBooking(bookingId) {
  const response = await fetch(`/wp-json/latepoint-api/v1/bookings/${bookingId}`, {
    method: 'PUT',
    headers: {
      'X-API-Key': 'your_api_key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      status: 'approved',
      send_notification: true
    })
  });
  
  if (response.ok) {
    const result = await response.json();
    console.log('Booking confirmed:', result.data.booking_code);
    return result.data;
  }
  
  throw new Error('Error confirming booking');
}

2. Reschedule with Availability Check

// Reschedule a booking by checking availability first
async function rescheduleBooking(bookingId, newDate, newTime, agentId, serviceId) {
  // First check availability
const availabilityResponse = await fetch(
`/wp-json/latepoint-api/v1/availability?service_id=${serviceId}&agent_id=${agentId}&date=${newDate}&duration=${duration}`
);
  
  const availability = await availabilityResponse.json();
  
  if (!availability.data.available_slots.includes(newTime)) {
    throw new Error('The requested time slot is not available');
  }
  
  // Proceed with rescheduling
  const response = await fetch(`/wp-json/latepoint-api/v1/bookings/${bookingId}`, {
    method: 'PUT',
    headers: {
      'X-API-Key': 'your_api_key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      start_date: newDate,
      start_time: newTime,
      send_notification: true,
      notes: 'Rescheduled by customer request'
    })
  });
  
  return await response.json();
}